lua-users home
lua-l archive

Re: Are parenthesis-free calls a Good? (was Re: patch: C-style string

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


>It seems like
>an unnecessary extension of Lua's beautiful tiny grammar, an exception
>that brings minor advantage but carries with it hidden disadvantages.
>Among these are a deterrent to other language modifications and the
>less-than-obvious-without-the-BNF 'f "A" .. "B"' is 'f("A") .. "B"'.
Not quite.
 f "A" .. "B"
will raise a syntax error, presumably to reduce confusion.
The shortcut syntax for tables in particular is the basis of a lot of object
orientated schemes - it hides the function call in a nice little table. Eg a
scheme might work like this:
local newclass = class{
 inherits = someotherclass,
 repaint = function()
 end
}
and allow instancing of a class like this:
 local window1 = Window{ width = 10, height = 20 }
Obviously that's just one way to implement classes, but you'll find
tables-as-sole-argument pop up a lot if you browse different oo schemes for lua.
The parenthesis would make the schemes look far less like a language built-in,
which is the illusion they currently provide.
It logically follows to support strings too, eg
 print "Hello"
To see strings as sole arguments in style, just take a peek at RiciLake's AsciiMenu:
 http://lua-users.org/wiki/AsciiMenu
It would be a great shame, and a very current-program-breaking one to disallow
implicit sole arguments..
- Alex

AltStyle によって変換されたページ (->オリジナル) /