lua-users home
lua-l archive

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


That seems very elegant, precisely because it is a simple
transformation, very much in the spirit of the generalized
for-statement.

But, should 'in' be 'let', maybe? Do we need an extra keyword 'done'?

let Animal = class do
     function name() .. end
     function eats_grass() .. end
     ...
end

The beauty of this (as you point out) is that it is a generalized
mechanism, not just for classes!

steve d.

On Jan 15, 2008 2:52 PM, Mildred <ml.mildred593@online.fr> wrote:
>
> Excuse me, I didn't had time to read your e-mail entirely. But what
> you're saying reminds me something I proposed here on the list quite
> some time ago:
>
> http://lua-users.org/lists/lua-l/2006-11/msg00547.html
>
> The proposition is to introduce a new syntaxic sugar that would
> transform any expression like:
>
>
> [local] in [ var_a1, ..., var_an = ] var_b1, var_b2, ..., var_bn do
>         inst_1
>         ...
>         inst_n
> end
>
>
> in
>
>
> [[local] var_a1, ..., var_an = ] var_b1(function()
>         inst_1
>         ...
>         inst_n
> end,
> var_b1, var_b2, ..., var_bn)