develooper Front page | perl.perl6.language | Postings from June 2005

Optimisations (was Re: How much do we close over?)

Thread Previous | Thread Next
Paul Johnson
June 13, 2005 05:38
Optimisations (was Re: How much do we close over?)
Message ID:
On Mon, Jun 13, 2005 at 11:24:07AM +0000, Luke Palmer wrote:

> I just have to say that it's really annoying running into
> optimizations when I don't want them.

Isn't the whole point of optimisations that you shouldn't have to worry
about whether you hit one or not, otherwise the optimisation would seem
to be broken.

>                                        Back when I wrote an
> back-chaining system in perl, I used tied variables in order to
> determine when I needed to solve for something.  A standard idiom was:
>     rule \$var, sub {
>         $a and $b and $c;
>         $var = 1;
>     };
> And damnit, $c would never be solved for, because it was optimized
> away by Perl.

I'm not sure that short circuiting operators can be called an
optimisation.  Aren't they more part of the language definition?  I
assume Perl 6 isn't doing away with short circuiting operators.

>                I ran into that problem rather quickly, and I knew a
> "no optimizations" would do the trick, if it existed.  But no such
> luck, so I always had to add an "and 1" on the end.  Funny thing is,
> that should have been optimized away too, but it wasn't, because Perl
> wasn't that good at optimizations.  So now I have to know about the
> capabilities of the language I'm using in order to program.

I'm not sure about the premise, but I agree with the conclusion.

> To sum up, optimizations are nice, and it's nice to have optimizations
> on by default for PR reasons, but you have to be able to turn them
> off.

One of the things that has been on the Perl 5 wishlist for a while is a
way to turn off the optimisations, but really that would only be for the
benefit of people and modules that mess with the op tree.  Again, I
submit that an optimisation that changes normal behaviour is broken and
that, in general, programmers shouldn't need to worry about what
optimisations are going on under the covers.

Paul Johnson -

Thread Previous | Thread Next Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About