lua-users home
lua-l archive

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


Personally I prefer parenthesis free calls. It's like the colon syntax: New
programmers tend to stumble over it, but somehow I think it helps to understand
what functions actually are and how they work. 
I like that lua allows me to do stuff like this:

class "Foo" : extends "Bar"

Or like the sample from Alexander 

foo "name"
{
  bar "bar";
  baz "baz";
}


For me, the whitespaces are helping me to focus on more important hints what the
code is doing. Parentheses are giving me more cues that that function is
actually more complex. 

But of course it's arguable - however: I have stopped counting the times I have
explained the colon syntax even to experienced programmers who were puzzled. I
don't think that there exists a syntax that helps the beginners. May there be
parentheses or not - the beginner/intermediate/advanced programmer will stumble
when he/she is learning a new programming language. 

Eike

> Luiz Henrique de Figueiredo wrote:
> > Eric Tetz wrote:
> >> I just posted a small patch to the wiki that allows C-style string
> >> lexing, where string literals separated by whitespace are collected
> >> as a single string.
> > This will break expressions like f "A" "B", which is interpreted as
> > f("A")("B"). The program below prints "A<TAB>and<TAB>B". Try it in your
> 
> The patch definitely breaks this Lua feature.
> 
> Like Asko, I haven't really missed C-style concatenation since Lua has
> '[[ ]]' and '..'. As David points out, constant folding in the
> interpreter could make Lua's form of concatenation result in a single
> constant (in fact, I was under the mistaken impression that it already
> did so!), though there is this thread
> (http://lua-users.org/lists/lua-l/2007-02/msg00209.html) to consider.
> 
> But I dislike the omitted parentheses in function calls. 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"'.
> 
> I have a vague memory of another post where 'f "A"' would be broken by a
> proposed modification to the language. I looked for it in the archives
> but could not find it. But there was a post just this month about
> extending this syntactical form to numbers
> (http://lua-users.org/lists/lua-l/2008-01/msg00303.html). It's natural
> to ask 'Why this type and not another?' These instances make me think
> that there's cause for re-evaluation of the trade-offs for this feature.
> 
> Is there a reason for 'f "A"' (and 'f{}') other than saving keystrokes?
> Does that reasoning apply to other Lua types?
> 
> I know from Lua's early history and from my own early Lua programming
> that 'f{}' can be useful, especially in configuration files. But over
> the years I shed my "Wow! This is neat!" view and replaced it with one
> that is 'purer'. Now I nearly always use 'f({})' and 'f("A")'; I see the
> parentheses as a clearer, more consistent indication of what is actually
> happening - a function call.
> 
> My future vision of Lua sees these forms in the same way that I view the
> old 'n' field for arrays ('#' is more elegant). I suppose the forms will
> stay until there is another more compelling form that is syntactically
> mutually exclusive. The key thing being 'more compelling', which I don't
> believe is true for this particular patch.
> 
> Doug
> 
> -- 
> Innovative Concepts, Inc. www.innocon.com 703-893-2007 x220
>