Re: run-once code

2004-01-14 Thread A. Pagaltzis
* Luke Palmer <[EMAIL PROTECTED]> [2004-01-14 19:03]: > Let's not mention that that has way more overhead than a > short-circuiting test, but I guess "the idea's the important > thing". How about a calculated goto? *grin* -- Regards, Aristotle "If you can't laugh at yourself, you don't take li

Re: run-once code

2004-01-14 Thread Luke Palmer
David Storrs writes: > On Wed, Jan 14, 2004 at 11:57:05AM +, Richard Nuttall wrote: > > > How about > > > > $test = sub > > { > > if ( some_expensive_lookup_function() >= $MAX_RECORDS ) > > > >mark_that_we_have_reached_max_records(); > > > >$test = sub{}; > > }; >

Re: run-once code

2004-01-14 Thread Melvin Smith
At 09:31 AM 1/14/2004 -0800, David Storrs wrote: On Wed, Jan 14, 2004 at 10:59:52AM -0500, Melvin Smith wrote: > I think Perl6 will allow a hint like so: > > my int $max_reached; > > The important thing is that $max_reached is used simply as a conditional, > and you don't pass it to a routine or o

Re: This week's summary

2004-01-14 Thread Dan Sugalski
At 12:36 PM -0500 1/13/04, Uri Guttman wrote: > "TP6S" == The Perl 6 Summarizer <[EMAIL PROTECTED]> writes: TP6S> Congratulations Dan TP6S> Melvin Smith offered his congratulations to Dan for the TP6S> first commercial use of Parrot. I think I can safely say we TP6S> al

Re: run-once code

2004-01-14 Thread David Storrs
On Wed, Jan 14, 2004 at 11:57:05AM +, Richard Nuttall wrote: > 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; Neat.

Re: run-once code

2004-01-14 Thread David Storrs
On Wed, Jan 14, 2004 at 10:59:52AM -0500, Melvin Smith wrote: > I think Perl6 will allow a hint like so: > > my int $max_reached; > > The important thing is that $max_reached is used simply as a conditional, > and you don't pass it to a routine or otherwise use it in a way to cause it > to be p

Re: run-once code

2004-01-14 Thread David Storrs
On Tue, Jan 13, 2004 at 10:16:48PM -0700, Luke Palmer wrote: > sub mark_that_we_have_reached_max_records() { > $max_reached = 1; > } > > if !$max_reached && some_expensive_lookup_function() > $MAX_RECORDS { > mark_that_we_have_reached_max_records(); > return; >

Re: run-once code

2004-01-14 Thread Melvin Smith
At 10:16 PM 1/13/2004 -0700, Luke Palmer wrote: David Storrs writes: > 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 condit

Re: run-once code

2004-01-14 Thread Luke Palmer
Jonathan Scott Duff writes: > On Tue, Jan 13, 2004 at 10:16:48PM -0700, Luke Palmer wrote: > > So, let's say you have something like: > > > > $x = 100_000; > > my $seen; > > while $x --> 0 { > > Don't do that! I had to look at this twice before I decided that > perl6 didn't get a new

Re: run-once code

2004-01-14 Thread Dan Brook
On Tue, 13 Jan 2004 20:37:21 -0800 David Storrs <[EMAIL PROTECTED]> 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

Re: run-once code

2004-01-14 Thread Richard Nuttall
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 fro