lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


On June 30, 2019 at 5:42 PM, Andrew Gierth <andrew@tao11.riddles.org.uk> wrote:

>>>>>> "Tom" == Tom Sutcliffe <tomsci@me.com> writes:
> 
> Tom> I've tracked this down to the fact that the test - not the
> Tom> production code :) - was relying on the tostring representation of
> Tom> a full userdata 0xABCD being the same as the lightuserdata
> Tom> representation of the same pointer - they were both "userdata:
> Tom> 0x1234" on 5.3
> 
> er... no? 

> 
> In 5.3, the tostring representation of something that's not a number,
> string, boolean or nil and which has no __tostring metamethod is:


Well, this is interesting. The project I was porting originally used 5.3.3 (plus keeping an eye on subsequent security bugs). In 5.3.3 the behaviour very definitely was as I described. Looking through the commit history, it appears this changed in 5.3.4.
 
> 
> Tom> I couldn't find anywhere in the manual that this was mentioned -
> Tom> in particular __name is mentioned solely in the docs for
> Tom> luaL_newmetatable which states "The entry __name is used by some
> Tom> error-reporting functions" - and this change has broadened the
> Tom> scope of what __name is used for. I realise that the exact
> Tom> formatting of tostring is not defined in the API but previously
> Tom> changes like that of tostring(2.0) in 5.3 were at least mentioned
> Tom> in the "Changes in the Language" section - could we do the same
> Tom> here?
> 
> It's presumably not documented as a change because it didn't actually
> change.


Not when I originally thought, but it did change :) It's not a huge issue, but the precedent of mentioning things which aren't technically breaks but nevertheless could trip people up, was established with the float string formatting notes in the 5.3 docs, and it would've been nice to have had a similar note here. Of course, since it changed during the 5.3 era that ship has now sailed.

To put it another way, everything else I had to change in this project to go from 5.3.x to current master branch was something mentioned in section 8 of the work manual - so it seemed worthwhile to raise it on the list.

Besides, how/when __name is used by the Lua core is somewhat inadequately documented, whenever it’s current behaviour was introduced.

Edit: ninja’d by Daurnimator

Regards,

Tom