[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: String represents arrays of characters.
- From: Dirk Laurie <dpl@...>
- Date: Mon, 13 Dec 2010 22:44:36 +0200
The title of this post is a quote from the Lua Reference Manual,
Section 2.2 in Lua 5.1, Section 2.1 in Lua 5.2. Stare at it
again.
String represents arrays of characters.
In the light of that statement, one can't be blamed for expecting
that s[i] means the i-th character of a string. At present, s[i]
is nil, even if i is in the range 1 to #s -- another gotcha.
In some previous threads, various ways to achieve this in Lua were
suggested. I was flamed for "writing a dialect" and failing to
think in Lua instead of Pascal..
But really, if Roberto himself says "String represents arrays of
characters" then it can't be un-Lua-like to wish to write s[i].
And who knows? It may yet sneak into a future Lua ...
Dirk