[forwarded submission from a non-member address -- rjk]


From: Damian Conway <[EMAIL PROTECTED]>
Date: Fri, 6 Jul 2001 02:41:32 +1000 (EST)
Subject: Re:  array and hash slices in Perl 6
To: Boston Perl Mongers <[EMAIL PROTECTED]>,
   "Tolkin,
    Steve" <[EMAIL PROTECTED]>

   > I would have tried to ask Damian the following technical questions.
   > Perhaps someone else can ask it, or ever answer it here in email.
   > 
   > Larry says the syntax for hash slices and array slices will
   > change in Perl 6. Does anyone know at this point what the new 
   > syntax for array slices and hash slices looks like?  

Very probably like I described in Exegesis 2:

        @array[@indices]

        %hash[@keys]


   > Will it be possible to automatically translate the Perl 5 to Perl 6?

95% possible, yes. Certainly standard slices will translate.


   > I have a program that makes heavy use of this very powerful feature.   
   > Here are some excerpts.  First is a simple example of hash slice usage:
   >
   >     @f{@mff_feed_cols} = split(/\|/, $line );

This will become:

         %f{@mff_feed_cols} = split(/\|/, $line );

Whilst:

   >     if ( join( $sep, @{$fields[old]}[@{$compareindexlist[old]}] ) eq
   >          join( $sep, @{$fields[new]}[@{$compareindexlist[new]}] ) )

will become:

         if ( join( $sep, @{@fields[old]}[@{@compareindexlist[old]}] ) eq
              join( $sep, @{@fields[new]}[@{@compareindexlist[new]}] ) )

or perhaps even just:

         if ( join( $sep, @fields[old][@compareindexlist[old]] ) eq
              join( $sep, @fields[new][@compareindexlist[new]] ) )

(if Larry decides that array refs will auto-derefence everywhere)

Damian

Reply via email to