lua-users home
lua-l archive

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

Asko Kauppi wrote:
> I took my first lesson on touching Lua source
> internally, and it wasn't hard!

Yup, Lua is very readable/hackable. Here's a 3 line patch that allows
'do' wherever 'function' is accepted, and makes function parameter
lists optional.

  <   check(ls, '(');
  >   if (testnext(ls, '(')) {
  >   }
  >     case TK_DO:

You can then say:

  function a(v) print(v) end
  function a print('c') end
  a = function print('c') end
  do print('e') end
  a = do print('c') end
  a = do(c) print(c) end
  call = function(f) f() end
  call( function print('function') end )
  call( do print('do') end )