lua-users home
lua-l archive

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


I had an idea like this once, but instead of the intent being to
create bytecode without upvalues, mine was a simple way to create
isolated chunks. For example,

begin
  do something
end

Would be equivalent to:

function ()
  do something
end

The main advantages of this are for using Lua as a DSL, where the
'function ()' syntax is awkward looking and confusing to people who
might not really be familiar with programming. (It would also be
passable as the sole argument to function calls without parens, like
string and table literals are now.) For example:

-- choose your own adventure game
intro = page begin
  write 'It is pitch dark. You are likely to be eaten by a grue.'
  choice 'grue' 'North' -- using currying here, by the way
  choice 'grue' 'South'
  choice 'grue' 'East'
  choice 'grue' 'West'
end

grue = page begin
  write 'You walk right into the slavering fangs of a lurking grue.'
  return false -- Game Over
end

I was just sharing that. Your idea is pretty good, too. Maybe they
could both be in, except that would be too many keywords. :-)

-- Leaf
"There are 10 types of people in the world - those who understand
binary and those who don't."