[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: upcoming changes in Lua 5.2 [was Re: Location of a package]
- From: Diego Nehab <diego@...>
- Date: Wed, 20 Feb 2008 13:27:02 -0500 (EST)
Hi,
Yes, luaL_tostring will invoke the __tostring metamethod (like
'tostring' does currently). (But I fail to see how this would allow for
strings not managed by Lua, unless there are other changes. After
all, the final result of the __tostring metamethod should be a string.)
I see what you mean. In the end, for Lua to use the string,
a string would have to be created. Nonetheless, this would
allow for somewhat "lazy" strings. A library would return
userdata that can be automatically converted to strings by
functions such as print(), *if* the user passes such
userdata to print(). The library itself, on the other hand,
would be able to completely skip such conversion.
This brings up the question of non-interned strings. I
thought about this some time ago but gave up. We'd need a C
metamethod that can obtain a pointer and a length from a
userdata (or a non-interned string object). Since userdata
can change through time, the semantics becomes too
complicated, especially when indexing tables. So I gave up
on it.
Regards,
Diego