lua-users home
lua-l archive

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


By changing the whitespace, you can make the current syntax much easier to read:

function(x, y, z)    return x + y + z   end

or, perhaps,

function(x, y, z)   return(x + y + z)   end


Chris


Philippe Lhoste wrote:
On 04/12/2009 11:12, Luiz Henrique de Figueiredo wrote:
And one possible syntax could be
    function (x,y,z)=x+y*z

Or:
  function (x, y, z) x + y * z end

which isn't much longer (even more looking at the proposed -> alternative...), remains close of current syntax and clearly defines where the expression ends. Actually, it only makes 'return' optional, which isn't unlike JavaFX (which might have taken the idea from some other language(s)) which considers that the last expression of a function is the return value of that function.

People will find 'function' still too verbose, but I am not fan of |x| or \x syntaxes within Lua which doesn't abuse of such notations (they are fines in themselves, of course).

So perhaps we can reuse some keyword in a different context (I might miss some syntactic ambiguity, though), eg.:

  do: (x, y, z) x + y * z end