lua-users home
lua-l archive

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


On Jul 8, 2012 10:46 PM, "Coda Highland" <chighland@gmail.com> wrote:
>
> > For me, I would be a much happier Lua coder if coercion to strings
> > were automatic in more places. Concatenation, table.concat,
> > string.format("%s"), and others should all call (__)tostring
> > (metamethod), IMO. As for Lua core string <-> number coercions, I'd be
> > happy to see that go.
>
> Speaking as a Python developer, I agree with you. Things should coerce
> *to* strings much more readily than they should coerce *from* strings.
>
> /s/ Adam
>

+1, I've expressed a few times that functions expecting strings as input should call [__]tostring. It'd make life easier when dealing with objects that may or may not be strings but can be converted to them. The C API is where this bugs me most, as few libraries bother to do it themselves.