lua-users home
lua-l archive

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


Dirk Laurie <dpl@sun.ac.za> writes:

> The following syntax:
>
>     ('a,b,c')('a+b+c') == function(a,b,c) return a+b+c end
>
> is available after doing this chunk:
>
>     getmetatable("").__call = 
>       function(arg,res)
>         if #arg>0 then return load(arg.."=...; return "..res)
>         else return load("return "..res)
>         end
>       end
>
> Dirk
> (Apologies if someone has already pointed out this obvious trick.  
> I started reading the discussion somewhere in the middle.)

It won't exactly work well in the context of closures.

-- 
David Kastrup