lua-users home
lua-l archive

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



在 2011-7-1 下午1:17,"Lorenzo Donati" <lorenzodonatibz@interfree.it>写道:
>
> Hi All!
>
> This is an attempt to both satisfy a curiosity of mine and
> start a discussion on a topic that seems recurring lately and (IIRC) pops up from time to time.
>
> More specifically, I happened to notice in various threads that there could be a need for a way in Lua to delay the evaluation of expressions.
>
> Lately, in particular, it has been mentioned in the context of error management to avoid building a complex error message when the error actually doesn't occur.
>
> What I wonder now is whether the possibility of delaying the evaluation of an _expression_ would be useful also in other contexts.
>
> If it would, then maybe it is worth considering what should be done to add to Lua such a feature (or a more general one that could comprise it) and what could be the consequences (pros and cons) and if the feature could be general enough to be in "Lua spirit".
>
> Thanks for any contribution.
>
> Cheers.
> -- Lorenzo
>
I have posted a proposal about a new data type of "macro", that macro is same with function except its argument only calculate when they occur in the body of macro, like this:

macro assert(cond, ...)
    if not cond then error (...) end
    return ...
end

The cond only calculate in if, as ... only calculate in error or return.

Is that OK ?