Dear Damian,
Thanks for replying. But I have a few followup questions,
interspersed.
> -----Original Message-----
> From: Damian Conway [mailto:[EMAIL PROTECTED]]
> Sent: Thursday, July 05, 2001 12:43 PM
> To: [EMAIL PROTECTED]
> Subject: [Boston.pm] Re: array and hash slices in Perl 6
>
> [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]
Here you use square brackets after the hash name, but below
you use curly braces. Which is it?
> > Will it be possible to automatically translate the Perl
> 5 to Perl 6?
>
> 95% possible, yes. Certainly standard slices will translate.
I hope these examples are in the 95%. DO you have any
examples of what it might do wrong, so I can be aware of
what not to code in the next year or two.
> > 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 );
(The line above is where you used curly brace after the hash name,
as mentionned earlier.)
> 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
>
A general question: I think in principle we could remove the
@ from @foo[something] without loss of information -- the square
braces tell us that foo is an array. Is this true?
If so has any thought been given to making the @ and %
optional in certain contexts?
I mentionned in my originalk poost that in Perl 5 one cannot have
a reference to a slice. Is this still true?
Hopefully helpfully yours,
Steve
--
Steven Tolkin [EMAIL PROTECTED] 617-563-0516
Fidelity Investments 82 Devonshire St. V10D Boston MA 02109
There is nothing so practical as a good theory. Comments are by me,
not Fidelity Investments, its subsidiaries or affiliates.
P.S. to Damian and Ronald, If Damian replies to me
I can forward to the list. Or your can handle Ronald if you
prefer.