David Storrs wrote:

Given this code:
if ( some_expensive_lookup_function() >= $MAX_RECORDS ) {
mark_that_we_have_reached_max_records(); return;
}


After I enter that block once, I never want to evaluate the condition
again--I want the code to completely disappear from the bytecode (or,
at least, be jumped around). How would I do that in Perl 6?


How about

$test = sub
{
    if ( some_expensive_lookup_function() >= $MAX_RECORDS )

mark_that_we_have_reached_max_records();

$test = sub{};
};


Then call &$test() as needed;

R.
--
Richard Nuttall
Nuttall Consulting
www.nuttall.uk.net




Reply via email to