in reply to Re: Style Question: Throwaway Objects
in thread Style Question: Throwaway Objects

I absolutely agree on the with-block issue. Something like the multiple method calls against the same object (f.ex GUI programming) snippet I've written for myself is a useful crutch for these cases, but it's still a crutch. I wish there was a better way to deal with this.

Makeshifts last the longest.

  • Comment on Re^2: Style Question: Throwaway Objects

Replies are listed 'Best First'.
Re: Re^2: Style Question: Throwaway Objects
by demerphq (Chancellor) on Dec 09, 2002 at 18:38 UTC
    Interestingly it has been pointed out to me that for() can be used as a with, but it doesnt quite do it for me...
    for ($some->{complex}[$object]{that}{we}[$need]{to}[$use]) { $_->foo; $_->bar; }
    And a proper with construct allows the compiler opportunities to optimize far beyond what any other solution allows as it explicitly states that the object will be immutable for the duration of the with. *sigh*

    :-)

    --- demerphq
    my friends call me, usually because I'm late....

      You do save all the duplicate lookup work in this case, if that's what you mean. Anyway, the Perl compiler is pretty simpleminded as far as optimization goes, so performance is hardly an argument for having a with construct at this point.

      Makeshifts last the longest.