lua-users home
lua-l archive

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

Reuben Thomas wrote:
> Motivation for the patch: I don't like automatic casting; it hides bugs.
> I also think it rarely[1] helps users, and if it does (e.g. in a config
> file), then you can do the auto-casting yourself (e.g. read a config
> file, and call "to<type>(v)" on each value you read).
> [1]For example, print is one function I've left alone. This is an
> example of the fine line in Lua between auto-casting and intentionally
> calling a tostring method.

Nice to know that I'm not the only one who dislikes the implicit
coercion-- however I don't think the line you mention is that fine.  The
print function is intended for debugging (e.g. dumping a given object),
and it makes sense to call tostring() on its arguments.  That's a
documented behavior performed explicitly by the function, and very
different from the implicit coercion taking place in an expression like
(5 + "5").

To resolve Mark's issue with string.format in another post, I think the
existing %s should run tostring() on its argument.  There's no want or
need for a strict string format type.