[% setvar title Data: Multi-dimensional arrays/hashes and slices %]

This file is part of the Perl 6 Archive

Note: these documents may be out of date. Do not use as reference!

To see what is currently happening visit http://www.perl6.org/


Data: Multi-dimensional arrays/hashes and slices


  Maintainer: Ilya Zakharevich <ilya@math.ohio-state.edu>
  Date: 15 Sep 2000
  Mailing List: perl6-language-data@perl.org
  Number: 231
  Version: 1
  Status: Developing


This RFC


Observation1: it is enough to define the interface which tie()d arrays can use. Then *if judged useful*, this semantic can be optionally supported by the builtin arrays/hashes.

Observation2: current supports for multi-dimensional objects and slicing clash between themselves (at least visually):

   @slice = @hash{$ind1,$ind2};
   @slice = @arry[$ind1,$ind2];
   $elmnt = $hash{$ind1,$ind2};

moreover, the analogue for arrays

   $elmnt = $arry[$ind1,$ind2];

is not supported (syntax error).

Observation3: comma operator has 3 different meanings: one in list context, one in scalar context, one inside an index for a hash/array.

The following proposals move the special meaning from , to ;, introduce a new meaning for ... inside indices, 4 new tie()ed methods, and 4 new utility functions in a module tie::multi. An optional OO access to slices, an optional iterator, and an optional support for builtin arrays complement the proposal.


Without the optional proposal 8 only "a" stands.


With the exception of Proposals 9 and 10 should be straightforward. 9 and 10 require some dexterity with building optrees on the fly.


RFC 205: New operator ';' for creating array slices.