lua-users home
lua-l archive

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


(A related question was posed in a different manner back in 2007 but the discussion didn't go anywhere after noting a grammar conflict that IMHO is not relevant for useful use cases. [1])

When is a string not a string?  When it's string literal.

Here's a trivial example adapted from a different context[2]:

> function string:alike(other) return self:lower() == other:lower() end
> s = "WomBat"
> s:alike"wombat"
true
> "wombat":alike(s)
stdin:1: unexpected symbol near '"wombat"'

Since according to the manual there is one metatable for strings and the string library sets it, we're missing the opportunity to write:
 io.write("This is the value: '%d'\n":format(x))

There are other useful cases, but this is the one I think is best (that is, useful and clear) should be enough for people to tell me this is a bad idea :-)

Opinions please: Why is letting a string literal be more like a string a good or bad idea?

Thanks,
Ken


[1] http://lua-users.org/lists/lua-l/2007-05/msg00059.html
[2] http://lua-users.org/lists/lua-l/2007-03/msg00493.html