develooper Front page | perl.perl5.porters | Postings from August 2010

Re: Order of evaluation of terms (was peephole optimiser couldprune more dead code)

Thread Previous | Thread Next
From:
Abigail
Date:
August 19, 2010 09:48
Subject:
Re: Order of evaluation of terms (was peephole optimiser couldprune more dead code)
Message ID:
20100819165018.GF22963@almanda
On Fri, Aug 06, 2010 at 12:24:36PM +0000, Ævar Arnfjörð Bjarmason wrote:
> 
> I don't think the point is that we should *guarantee* that FETCH will
> only be called once per "logical access". But that we shouldn't make
> any guarantees *at all*.
> 
> I.e. explicitly document that if you write a tie class you shouldn't
> depend on how many times FETCH and friends are called, since they may
> be called by the core at unexpected times, and those times may change
> without warning in future releases.


Well, that may be the easy way out, but does that improve the usefulness
of the language? I'm sure it makes it easier for a language implementation
if

    f () OP g ()

does not make any promises how often f() and g() are called when evaluating
the expression. But one has to question whether that's useful for an imperative
language. 

IMO, if $x and $y are tied, 

    $x OP $y

should just be a shortcut for

    (tied ($x) -> FETCH) OP (tied ($y) -> FETCH)


I don't think many people will argue you should write f() and g() in such a
way that Perl is free to call f() and g() as many times as it pleases
when writing

    f () OP g ();


And I fail to see why tied variables should be except.


Abigail

Thread Previous | Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About