develooper Front page | perl.perl5.porters | Postings from May 2003

Re: slice autoextending ? still another revised doc patch; COW

Thread Previous | Thread Next
david nicol
May 14, 2003 15:04
Re: slice autoextending ? still another revised doc patch; COW
Message ID:
On Tue, 2003-05-13 at 16:38, Nicholas Clark wrote:
> On Tue, Apr 22, 2003 at 10:05:02PM -0500, david nicol wrote:
> > Do we have copy-on-write assignment yet?  I know it's been discussed
> > here before. What's its current status?  I guess COW_ALIAS
> What do you mean by copy-on-write assignment (in this context)?
> blead can have copy-on-write optionally compiled in, but it only copies
> PVIVs (or greater) that have a string but no numeric flags set, when the
> wind is in the right direction (er, or some other specific favourable
> conditions, but I forget exactly what. It's quite choosy)
> Nicholas Clark

In a context of talking about slices, I think I was imagining using COW
to optimize away the copying of the data within the array by hiding
 aliases to the first array.

	@second = splice @first, $offset, $length

does, I believe with a less than 100% confidence, do an elementwise
copy of the desired items -- a fetch on each, and a store.  If @second
was some kind of magic array that hides the fact that it stores
 references instead of values until fetching time, the FETCHes could
be deferred.  

The problem is that writing to @first needs to replace instead of
overwrite, to avoid corrupting @second.  Working that out is what
I meant by COW.

	tie my @second, nonexistent::AoR,
	  { \$first[$_] }
	  ($offset .. $offset + $length);

might work, if someone wanted to write that TIE module instead
of makingthis happen internally.

David Nicol, independent consultant and contractor
have a nice day, really. 

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