lua-users home
lua-l archive

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


On Thu, Dec 3, 2009 at 12:27 PM, Francesco Abbate <gslshell@gmail.com> wrote:
> a usuful clean notation that could have its place in Lua.

Exactly, an alternative, not compulsory.

While dealing with Lua syntax extensions, it would occaisionally be
very useful to be able to drop the parentheses when calling functions
with a single argument which is an anonymous function, in the same way
as with string literals and table constructors.

E.g. Orbit's htmlify trick involves changing the function environment
so that unknown functions are assumed to represent HTML tags:

render = htmlify (function(web)
  return html {
    head { },
    body { h2 'hello there' }
   }
end)

That 'end)' is a little awkward, but this could be written so:

render = htmlify function(web)
  return html {
    head { },
    body { h2 'hello there' }
   }
end

Then together with 'short lambda' we get:

render = htmlify |web| html {
  head { },
  body { h2 'hello there' }
}

I'm not particularly attached to this notation, but it is consistent
(Lua already allows leaving out of parens in some cases; why not
another?)

steve d.