develooper Front page | perl.perl6.language | Postings from January 2003

Re: Arrays: Default Values

From:
Aaron Sherman
Date:
January 30, 2003 08:52
Subject:
Re: Arrays: Default Values
Message ID:
1043945522.1151.92.camel@localhost.localdomain
On Wed, 2003-01-29 at 17:50, Spider Boardman wrote:
> On 29 Jan 2003 14:29:52 -0500, Aaron Sherman wrote (in part):
> 
> ajs> As for the argument that testing for true non-existentness is a
> ajs> burden, check out the way Perl5 does this.  Hint: there's a central
> ajs> sv_undef, and that's not what array buckets are initialized to....
> 
> Either you're dead wrong, or you typo'd there.  After
> 
> 	my @a;
> 	$a[4] = 1;
> 
> The array buckets @a[0..3] most certainly ARE initialized to &PL_sv_undef

This has changed since I last (long ago) looked at the source for av.c.
It once was the case that av_fetch could return NULL for uninitialized
cells, which is why it returns an C<SV**> instead of an C<SV*>. It now
looks like you're right and newly allocated cells are given a default
"undeffing".

None the less, the point is valid. We do not HAVE to fill newly
allocated arrays with undef. That yeilds a perfectly respectable
non-existent case.

The question is, do we *want* to do that and is it suitable to the
current Parrot implementation?

-- 
Aaron Sherman <ajs@ajs.com>
This message (c) 2003 by Aaron Sherman,
and granted to the Public Domain in 2023.
Fight the DMCA and copyright extension!





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