lua-users home
lua-l archive

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


On Tue, Mar 8, 2011 at 10:17 PM, Eric Wing <ewmailing@gmail.com> wrote:
> I haven't reviewed the string.format() implementation, but it seems to
> be reasonable to expect __tostring to be invoked on userdata when the
> %s token is found. Certainly as a user, I expect this.

It's the same with table.concat, and the argument is that these are
low-level fast primitives that throw errors rather than trying to make
a coercion that might not make sense (e.g. a function or a plain table
should not be rendered as a string).

>> Maybe Lua should add a new modifier to string.format() that would call the
>> __tostring() metamethod in every case.

Now that makes sense, when the user asks for it - maybe %u ?

steve d.