lua-users home
lua-l archive

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


On Fri, Jul 1, 2011 at 8:28 AM, Lorenzo Donati
<[email protected]> wrote:
> it being cheap enough. Reading the objections that occasionally come up to
> that idiom, I got the feeling that people don't think it is so cheap
> (relatively speaking).

If you have a lot of assertions, then it's true that every such
assertion will generate a new closure. It ain't pretty - whether it is
a problem for a particular application is something that only
profiling can tell.

Here's one little extension which could make life easier in a natural
way, borrowed from Perl:

do_something() or fail "something failed!"

That is, to allow expressions as statements[1].  Because of boolean
operator short-circuiting, anything after 'or' will only be evaluated
when something bad happens.

steve d.
[1] http://lua-users.org/wiki/ExpressionsAsStatements