develooper Front page | perl.perl6.language | Postings from July 2006

optimizing with === immutable comparitor

Thread Next
From:
Darren Duncan
Date:
July 14, 2006 00:31
Subject:
optimizing with === immutable comparitor
Message ID:
p06230902c0dcf455ca61@[192.168.1.101]
This may go without saying, but ...

If $a === $b means what I think it does, then I believe that a 
not-premature implementation optimization of === would be that it 
always $a := $b if it was returning true, so that any future === of 
$a and $b or aliases thereof could short-circuit with a =:= test even 
if they weren't created as aliases, and Perl would be automatically 
more memory efficient without those extra storage copies.

I know that was an implementation issue, but I think that it stands 
to be explicitly stated anyway, as it is a very simple and effective 
way to make Perl programs more resource efficient, possibly by orders 
of magnitude, over not doing so.

(The only time this may not work is if so-called immutable types are 
tied to external resourses, but then I'm not sure how often this 
would happen in practice so it could just be an exception if 
necessary.  The above-stated rule would still stand for any resources 
managed by Perl itself.)

-- Darren Duncan

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