in reply to Are common access expressions optimized?

No, it doesn't. Perl's "optimizer" is really pretty dim. The best you can do for exists tests is
my $very_deep_nested = $very->{deeply}{nested}; $very_deeply_nested->{hash} = $something unless exists $very_deeply_nested->{hash};
or as I prefer,
exists $_->{hash} and $_->{hash} = $something for $very->{deeply}{nested};

Makeshifts last the longest.

Replies are listed 'Best First'.
Re: Re: Are common access expressions optimized?
by John M. Dlugosz (Monsignor) on Dec 23, 2002 at 16:20 UTC
    Thanks. I'm looking forward to "given" in Perl 6. I thought about that yesterday when I had a similar temporary that was only needed for the next two lines. Emulating with a one-iteration foreach is probably too obtuse.

      It's what Larry advertises. :) (Look for Topicalization.)

      I don't think it's obtuse at all - you might be surprised the first time you see it, but did you really have any problem reading it? I think it's immediately obvious what is happening.

      Makeshifts last the longest.

Re: Re: Are common access expressions optimized?
by paulbort (Hermit) on Dec 24, 2002 at 19:05 UTC
    Aristotle,
    Thank you; I now have a better understanding of the word sublime. That's high art. I'm going to go read the LW link in your other reply now.
    --
    Spring: Forces, Coiled Again!