lua-users home
lua-l archive

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


steve donovan <steve.j.donovan@gmail.com> writes:
> Perhaps the issue here is that those two little lines are easy to get
> lost in the otherwise keyword-driven syntax of Lua?

I think that's the _point_ -- "function (..) return ... end" is _too_
noticeable, and so obscures the actual important bits in situations
which the || notation is intended for.

Compare

   some_fun (foo, function (x) return x*x end)

with

   some_fun (foo, |x| x*x)

the latter is far more readable because the important parts aren't
obscured by the heavyweight syntax of the normal function syntax.

Of course, good style would probably indicate that you should use the
normal syntax in cases where the body of the function is large.

-miles

-- 
I'd rather be consing.