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 operator :)
That was Damian's favorite trick for a while. I liked it and adopted it. :-) > > [ loop unroll + currying example elided ] > > Not sure I like the currying, but if that's what works, so be it. I've been trying to stress this as an undertone in all my posts about optimization: Perl isn't going to optimize for you! It's going to help, but if you want real speed, you're probably going to have to work for it. Computers just aren't smart enough to do it for you -- especially in a language like Perl. In fact, I'd like it to stay back and let me decide what needed speed. If I care enough, I'll tell it. I remember a project I did recently that made extensive use of backward chaining. For instance, you'd have: rule '$age' => sub { print "What is your age? "; $age = <STDIN>; } rule '$main' => sub { $age; # Force the backward chain $main = "done"; } But the line with just $age got optimized away by Perl, much to my discontent, and I was unable to disable this "feature". So I ended up saying: sub null { } ... $age && null; To force the evaluation. This I consider a hack, and would rather that Perl 6 not force me to do this. I don't mind something like a no optimize; Though. </rant> Luke