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

Re: Arrays: is computed

From:
Leopold Toetsch
Date:
January 30, 2003 22:50
Subject:
Re: Arrays: is computed
Message ID:
3E3A1B61.5070702@toetsch.at
Michael Lazzaro wrote:

> 
>> gregor@focusresearch.com wrote:
>>
>>> Shouldn't access to 'is computed' arrays be read-only?

> In general, I would hope that 90% of them would be, but it's been stated 
> that it won't be a requirement.  


If you want such 'is computed' thingy, then tie it or wrap it in your 
own - IMHO. Everyone seems to need different things, so the simplest and 
by far the safest way is to make this explicit in your code.


> Hmm... real vs. fake undef... a difference between null-PMC and 
> PMC-null, autofill with null-PMC, but assigning undef writes PMC-null... 
> is that enough to make it work w/out speed penalty?  Dan/Leopold?


The array starts filled with zero's. A default value would mean, to fill 
each allocated array slot with a PerlUndef PMC (or a specific value 
respectively) which is expensive.

On reading a NULL this gets converted to a new PerlUndef on the fly. I 
don't see, what more is necessary - and:

my $val = @a[5] or $my_default;

> But making C<undef @a[n]> and C<@a[n] = undef> do very different things, 
> that's still scary.  Powerful, but scary.  People really, really want 
> that, huh?


This sould be really the same. But I could imagine to have something 
like @a.nullify(5);


> On Thursday, January 30, 2003, at 02:30  PM, Nicholas Clark wrote:
> 
>> I think there is a lot of scope for creating tied objects for all of this
>> complex behaviour. Everyone has different ideas about what would be 
>> useful,


Yep, exactly.


> Agreed.  Very, very agreed.  :-)  DAMN, I want to start using this NOW.
> 
> MikeL

leo




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