lua-users home
lua-l archive

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

I compiled Lua with the LUA_NOCVTN2S (no coercion from numbers to
string) and LUA_NOCVTS2N (same, but from string to numbers).

In my code, 6 places needed patching, all of them n->s.

In mobdebug, the number of edits was... all over. The vast majority
were n->s and I only remember one that was s->n.

It being only a week, these are my reactions, more than my thoughts:

1: n->s felt tedious, when patching mobdebug. I imagine that most
people will find this to be "not worth it", but it wasn't too bad.

2: "Auto finding" all of the problem spots is beyond my ability, but
it also wasn't worth thinking about, because the effort to do it by
hand was not large enough.

3: It struck me that, with some probably-not-acceptable changes to the
rules of metatables, __tostring and the math metamethods could combine
forces to do the same thing, but more slowly. This seems somewhat
Lua-esque to me, but the change is not worth it, given that coercion
is cheaper to do, the way it is and there are good reasons for why
metatables work as they do.

4: I don't use a tremendous amount of outside libraries, but I think I
use many of the more popular ones (or maybe I think they're popular,
because I use them?): LPeg, Pnelight, LuaSocket, mobdebug( and
whatever else that ZeroBraneStudio uses), luacheck, luassert, lxsh and

5: I like programming with it and will always have it turned on.

6: My 4.5 day conclusion is: When writing module code, both should be
on. When writing scripts for specific applications, number to string
coercion should on and  string ->number... I think it should be off.

I like it because I suffer from *Abstraction Anxiety*: A general fear
of abstractions, especially ones that perform magic tricks without
explicit instructions to do so. (I'm still working on that
definition... I think it's very common amongst Lua folks)

Another source of comfort is that thinking about my code is a good
thing. If I'm forced to type `.. tostring(n) ..` I'm adding a tiny bit
of documentation to that part of the code and acknowledging with much
more of my conscientiousness that something is being converted here,
so that it may be presented in a different form.

For newbies: It's easier to explain why something must be done, than
to much later explain that something was being done for them and that
they now need to care about that coercion, because they're in a
different context or it's not working.



PS: I am an inexperienced programmer, that loves to think about the
art and studies it often. Those with more experience would have
different observations and perhaps more valid ones.