[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Disabling assert function
- From: steve donovan <steve.j.donovan@...>
- Date: Thu, 20 May 2010 16:02:06 +0200
On Thu, May 20, 2010 at 3:45 PM, Romulo <romuloab@gmail.com> wrote:
> In some recents projects I have implemented an interpolated version of
> assert, in which it justs comstructs the error message if the
> expression evaluates to false.
That is cute. The basic problem is how to 'quote' an operation so
that it can be executed later.
At the risk of stirring things up, this is where the short-lambda form
can be useful:
assertc (mob:isalive(), || "the mob "..mob.name.." must be alive")
function assertc(condn,fun)
if not condn then assert(false,fn()) end
end
The cost? Lots of little closures.
Increasingly thinking that this is one of the few places where those
unfashionable things, macros, are actually useful.
steve d.