lua-users home
lua-l archive

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


Hi all,

I'm new to Lua but well aware of the conundrum regarding the short
lambda syntax.

I couldn't refrain myself from proposing my own suggestion, though, so
here it is:

   function(eat,food) return eat( food ) end

becomes

   (kick,ass): => kick( ass ) ::

If you turn : and :: into tokens, the syntax is not ambiguous as far
as I can tell, even if you put spaces between the closing paren and
the column. It may add a little overhead on the parser for determining
whether it is ambiguous or not, since it would have to read up to the
(lack of) column to be sure it isn't.

It presents several advantages:

* It's meaningful: The ":" introduces the block like it introduces a
sentence in European languages, and :: looks like big period. This is
actually inspired by Why the Lucky Stiff's Potion language (now
abandoned, sadly. The Potion VM was in part inspired by Lua, btw)
* => as a synonym for return is also explicit.
* It stands out, without looking alien (in my opinion, but it's of
course a matter of taste).
* It's easy to type on my (Belgian) keyboard layout... The arrow is a
bit less fluid on US qwerty, though.


Furthermore, if you tilt your head to the right a bit,

    (o): --[[ Eeeeek! ]]

it looks like a screaming monkey, and that's important for two reasons:

- Hacking in Lua is fun. Lua itself is fast and LuaJIT makes it screaming fast!
- It would be a nice tribute to all the code monkeys in the world.


Have a nice day,
--  Pierre-Yves