lua-users home
lua-l archive

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

On Wednesday 01 September 2004 14:08, Andreas Falkenhahn wrote:
> Maybe someone finds this useful. I have not tested it much and it was
> implemented rather quickly, so no guarantee for whatsoever. But if you find
> bugs, please notify me.

I may be being a killjoy, but:

	[0] = function ()

	[1] = function ()
}[value] or function ()

Admittedly, this will probably generate a fair bit of garbage, but it is O(1).

Is the compiler clever enough to optimise function closures that take no 
parameters and never leave the parent function?

+- David Given --McQ-+ "There is one thing a man must do // Before his
|    | life is done; // Write two lines in APL // And make
| ( | the buggers run."
+- --+ --- The Devil's DP Dictionary