lua-users home
lua-l archive

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

With regards to your last note about accessing characters through s[i], you can actually already do this by setting the metatable for all strings; like so:

mt = {}
mt["__index"] = function(str, i)
    if (type(i) == "number") then
        return string.sub(str, i, i)
        return string[i]

debug.setmetatable("", mt)

str = "abc"
print(str:sub(2, 2))

This will output two 'b's.  Just thought you might like to know :)

Regards, James.

On Wed, Nov 24, 2010 at 8:44 PM, Dirk Laurie <> wrote:
What I like about Lua is just the same thing I like about Pascal:
it is immediately readable, especially when syntax highlighted in
a good editor, and you can code in Lua quite rapidly because while
typing long words like 'function' and statements requiring two keywords
like 'if'...'then', your brain is racing ahead.

What puts me off from the current spate of lightweight syntax
proposals is just the same thing I hate about C and Perl: they
are cryptic and the saving in keystrokes now is not worth the
brain pain later.

The Pascal model has served Lua well so far: keep the language
itself simple and sweet, and put all the power into libraries.

The only lightweight syntax I would be prepared to support is one
that is in Pascal but not in Lua: s[i] == s:sub(i,i) for strings,
not because it saves six characters, but because it enhances