[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: assignment in conditional expression?
- From: lhf@... (Luiz Henrique de Figueiredo)
- Date: Tue, 8 Dec 1998 18:35:03 -0200 (EDT)
>From: David Jeske <[email protected]>
>
>I propose the following idea for making a block of code which runs
>inside the local-scope of the caller, but is otherwise similar to a
>function and evaluates as such:
>
>macro for(from,to,code)
> local i = from
>
> while (i<to) do
> code(i);
> i = i 1;
> end
>end
>
>
>for(1,2, macro (x)
> print("iteration: ".. tostring(x));
>end);
I'm probably missing something here, but how is this different from a function?
What you can write right now (and it works!) is just
function for(from,to,code)
local i = from
while (i<to) do
code(i);
i = i 1;
end
end
for(1,2, function (x)
print("iteration: ".. tostring(x));
end)
How would macros be different?
--lhf