develooper Front page | perl.perl6.language.data | Postings from September 2000

Re: RFC 231 (v1) Data: Multi-dimensional arrays/hashes and slices

Thread Previous
From:
Ilya Zakharevich
Date:
September 19, 2000 13:59
Subject:
Re: RFC 231 (v1) Data: Multi-dimensional arrays/hashes and slices
Message ID:
20000919165930.C6394@monk.mps.ohio-state.edu
On Tue, Sep 19, 2000 at 08:41:34AM +1200, Christian Soeller wrote:
> > Finally as an overload expert what do you think about the proposals
> > to make arrays overloadable objects so one can say things like:
> > 
> > @x = 3 * @y;
> 
> Is this where RFC 231's suggestion for OO slicing comes in (see quote)?
> 
> > For example, 
> > 
> >        $matrix1->[2..5; 2..4] * $matrix2->[1,3,5; 11..64];
> > 
> >      would denote: create two new objects for the specified submatrices, apply (overloaded) multiplication to these objects. Such a
> >      request is illegal for untie()d arrays; for tie()d arrays it is converted to a call to FETCH_SLICE in a scalar context.
> >      (Alternative: introduce two new tie()d methods: FETCH_SUBOBJECT, STORE_SUBOBJECT.) 
> 
> or is this supposed to be othogonal?

Note the contexts: in my $matrix1->... proposals the things we
multiply are objects (scalars!).  This C<*> in my example is the "usual"
overloaded C<*>.

While in 

  @x = 3 * @y;

C<*> is some strange "array-context multiplication".

> Another questing re RFC 231. Is it really required to make the
> syntactical distinction between ranges (..) and bi_ranges (...)? Some
> more explanation would be appreciated.

I do not see how else one can do it.

  a) We want @arr[ $start .. $start + $items - 1 ] work for $items==0
     too, right?

  b) We want @arr[ 0 .. -1 ] to get all the elements of the array, right?

I see no way to distinguish these two situations except by using
different syntax...

Ilya

Thread Previous


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