lua-users home
lua-l archive

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


On Wed, Nov 24, 2010 at 11:44:14AM +0200, 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.  

I'd like to add another observation. I'm used to functional languages,
where anonymous functions are pervasives, and I like them, but Lua has 
not a "functional" syntax, i.e. expressions and statements are not the
same. 

More to the point, the benefit of being able to omit "return" and
possibly use a shorter token like "\" or "lambda" to introduce the
anonymous function is limited, in my opinion, by the fact that you can't
return a stement, only an expression. 

For example you can't write something like that

  function(x,y) return if x < y then x else y end

and consequently you will not be allowed to write something like
  
  \x,y.(if x < y then x else y)

In these cases you are forced to write explicitly the return
statement in every if branch

  function(x,y) if x < y then return x else return y end

but a simple syntatic trick that just inserts the "return" for you at
the beginning of the anonymous function body would not work in general.

Cheers.
-- 
Enrico Tassi