Release Notes for 476

Notes for Release 476

49 Likes

Client Difference Log

API Changes

Added Property string PlayerEmulatorService.DEPRECATED_SerializedEmulatedPolicyInfo {RobloxScriptSecurity} [Hidden]

Changed the category of Property BasePart.CustomPhysicalProperties 
	from: "Part "
	  to: "Part"

Changed the category of Property BasePart.Elasticity 
	from: "Part "
	  to: "Part"

Changed the category of Property BasePart.Friction 
	from: "Part "
	  to: "Part"

Changed the category of Property BasePart.ReceiveAge 
	from: "Part "
	  to: "Part"

Changed the category of Property BasePart.RootPriority 
	from: "Part "
	  to: "Part"

Changed the category of Property BasePart.Size 
	from: "Part "
	  to: "Part"

Changed the category of Property FormFactorPart.FormFactor 
	from: "Part "
	  to: "Part"

Changed the category of Property Part.Shape 
	from: "Part "
	  to: "Part"

Changed the category of Property TrussPart.Style 
	from: "Part "
	  to: "Part"

Changed the security and value-type of Property PlayerEmulatorService.SerializedEmulatedPolicyInfo 
	from: {RobloxScriptSecurity} string
	  to: {RobloxSecurity} BinaryString

(Click here for a syntax highlighted version!)

22 Likes

Is there a functionality difference between RobloxSecurity and RobloxScriptSecurity? Or does it mean something else?

8 Likes

It is a higher security tag than RobloxScriptSecurity.

7 Likes

image

Uh oh. I never got into the habit of using tostring assuming that this behaviour would be permanent.

Are there any specific cases where this new print behaviour may throw different or unexpected results than now or where it may error? As far as I’m aware all my old crusty code prints pretty much every Lua datatype except for function. Nothing should break (and even if it does, well, it doesn’t matter).

image

Approximately how small are we talking and would this improvement be considered negligible or significantly better? Additionally, could this margin be bumped up by using table.create to preallocate the table’s size if you aren’t prefilling it with elements?

5 Likes

print will no longer call the tostring global function, but does something equivalent to the default tostring function. Basically setting to the global tostring will no longer affect print (because it doesn’t look at the environment to get the tostring function).

tostring = function()return"2"end
print"1" -- used to print 2, now prints 1

I don’t think this is a breaking change, the Lua 5.1 manual states

print (¡¡¡)
Receives any number of arguments, and prints their values to stdout, using the tostring function to convert them to strings. print is not intended for formatted output, but only as a quick way to show a value, typically for debugging. For formatted output, use string.format.

using the tostring function doesn’t imply if it calls the tostring function by getting the global or by getting it stored somewhere else (that isn’t modifiable by Lua code).

11 Likes

RobloxScriptSecurity = only Roblox scripts can access it, RobloxSecurity = no scripts can access it at all, it only exists for use by the C++ code in replication / serialization.

7 Likes

This is amazing for one of my current projects.
image
At the moment I’ve had to get around this using coroutines which is a really ugly hack. (It’s already a really ugly hack to be fair since I’m modifying fenvs a lot but still, happy to see this) I’m curious to know if this might positively impact performance when using lots of print calls.

I am also very excited about this:
image
Is this faster than using normal “newindexing”?

local list = table.create(5)
table.insert(list, "abc")

-- vs

local list = table.create(5)
list[#list + 1] = "abc"

And which of the below would be faster?

local list = table.create(5)
table.insert(list, knownIndex, "abc")

-- vs

list[knownIndex] = "abc"

I’m wondering if table.insert is able to achieve better performance or might in the future because I might use any of the above and usually they can be switched out easily, so, knowing which should be used for performance would be really useful to me.

2 Likes

Thought I’d mention this here, print no longer using the global tostring also applies to warn which isn’t mentioned here. error doesn’t use the same mechanism and treats non numeric/string values like nil from what I could tell which I think is the same behaviour as before the update, so, it doesn’t access the global tostring before or after this change.

This makes debugging a lot of my sandbox work much easier going forward which I am happy about.

2 Likes

error works fine with non numeric/string values for me

local s,r = pcall(error,{x=1})
print(s) --> false
print(r.x) --> 1

Also, why would error ever call tostring? error doesn’t output anything (something else prints the error).

1 Like

Nothing is wrong with error, that’s not what I was saying. I was just pointing out that it doesn’t use the same mechanism as print/warn and doesn’t use tostring for non string values. It still does string conversion, e.g. for number values.

Technically error doesn’t output anything but the mechanism that does output something is still doing string conversion since number values show up fine, that, or error is doing string conversion before emitting the error. That mechanism doesn’t rely on the global tostring, which is what I was saying, and, that’s how I recall it working before this update.

1 Like

This is what he means:

local x = {}
setmetatable(x, {__tostring = function() return "foo" end})
print(x) --> foo
error(x) --> Error occurred, no output from Lua.  
2 Likes

You are correct. I always forget warn exists.

error by itself can work with any error type. What you will see though is that in some Roblox code that interfaces with Luau, errors are expected to be strings, e.g. the top-level code that runs scripts wants to print an error to standard output and only supports strings at the moment. But if you use pcall/etc. this doesn’t impact your ability to catch errors of the correct type.

3 Likes

table.insert is the preferred alternative to t[#t + 1] = v. It’s a bit faster.

When you know the index already, you should use list[index] = v; table.insert with an index shifts the entire trailing portion of the table by 1, which isn’t particularly fast, but it’s fundamentally a different operation. If you need to do that then table.insert is the fastest way to do that, but if you don’t you should just assign the value.

4 Likes

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.