On Fri, 4 Jul 2003, Damian Conway wrote:

> > Will it be possible (or sane even) to bind a variable to an array slice
> It *should* be, since it's possible (if ungainly) to do it in Perl 5:

Ouch, blatant abuse of perl5's aliasing with @_ and globs ;) Can I also
assume that you can also pass around a 'reference' to an array slice e.g

  sub array_slice(Array @ar, int $begin, int $end) {
    ## does the binding syntax := exist in unary form?
    ## or would this be better suited to bound at the lvalue end?
    return [EMAIL PROTECTED] $begin .. $end ];
  }

  my @array = << un deux trois quatre cinq six >>;
  my @slice = array_slice( @array, 2, 4 );

  @slice    = << san shi go >>;
  print @array;

  __output__

  un deux san shi go six

As opposed to an explicit binding assignment, or is this perhaps a step
too far (in which direction is left to the discretion of the reader)?

Dan Brook

Reply via email to