Unfortuantely I must miss the mongers meeting Monday
(despite having RSVP'd yes earlier).
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?
Will it be possible to automatically translate the Perl 5 to Perl 6?
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:
# The next line uses a hash slice. This is equivalent to e.g.
# ($f{'field1'}, $f{'field2'}, ... $f{'fieldN'}) = split(...);
@f{@mff_feed_cols} = split(/\|/, $line );
Here is the key place I use array slices:
# Since the list of compare fields tends to be long it is more efficient
# to do one string compare than many field compares in a loop.
# But maybe later use the loop, as that would permit being sensitive
# to string vs. numeric type.
if ( join( $sep, @{$fields[old]}[@{$compareindexlist[old]}] ) eq
join( $sep, @{$fields[new]}[@{$compareindexlist[new]}] ) )
Later in the same program I lament the lack of a feature.
Will this be fixed in Perl 6?
# You cannot have a reference to an array slice, so instead of passing
# these to a subroutine we just do the compare inline.
Reference:
Larry Wall says, in "Apocalypse Two" May 03, 2001
http://www.perl.com/pub/a/2001/05/03/wall.html
<quote>
We're definitely killing Perl 5's slice syntax, at least as far as
relying on the initial character to determine the context of the
subscript. There are many ways we could reintroduce a slicing syntax,
some of which are mentioned in this RFC, but we'll defer the decision
on that till Apocalypse 9 on Data Structures, since the interesting
parts of designing slice syntax will be driven by the need to slice
multidimensional arrays.
For now we'll just say that arrays can have subscript signatures much
like functions have parameter signatures. Ordinary one-dimensional
arrays (and hashes) can then support some kind of simple slicing
syntax that can be extended for more complicated arrays, while
allowing multidimensional arrays to distinguish between simple slicing
and complicated mappings of lists and functions onto subscripts in a
manner more conducive to numerical programming.
On the subject of hash slices returning pairs rather than values, we
could distinguish this with special slice syntax, or we could
establish the notion of a hashlist context that tells the slice to
return pairs rather than just values. (We may not need a special slice
syntax for that if it's possible to typecast back and forth between
pair lists and ordinary lists.)
</quote>
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.