On Fri, Jul 08, 2005 at 03:17:42PM -0400, Chip Salzenberg wrote:
: Larry on p6i? I didn't expect some kind of Perlish Exposition!
Hey, I'm the chief Lurky Turkey around here...
: Incidentally, under the "appropriate amount of fun" topic: An
: interesting Parrot/Perl6 intersection problem with named parameters
: is the representation of <==. Given
:
: foo('a' => 1) <== ('b' => 2, ...)
:
: It's necessary to _somehow_ pass the first pair distinctly from the
: second pair without knowing the _name_ of the user-declared slurpy
: parameter of &foo. I suppose the Perl 6 compiler will have to settle
: on a pseudo-parameter-name that will be used to represent a <== style
: list. Assuming that name is '_', the above call could be compiled to:
:
: foo('a' => 1, '_' => ('b' => 2, ...))
:
: or something similar. It would then be the responsibility of a Perl 6
: function preamble to bind the contents of the '_' argument, if any, to
: the user-declared slurpy parameter, if any. Non-Perl6 functions would
: perhaps see the '_' parameter and have to deal with it.
Yes, that should work, though in fact the Perl 6 binder has to do
more work even than that, since once it sees the _ parameter, it has
to decide whether it's binding multiple pipes or semicolons, and if
so, whether the target slurpy type wants to treat the pipe/semicolon
boundaries multidimensionally or as a flat list. To a non-Perl 6
function it would appear to be a list of lazy lists, but Perl 6 is
trying to keep semicolons from becoming accidental sublist builders
*except* in contexts that are expecting multiple sublists (such
as subscripts that are lists of slices, or zip-like operators that
are processing multiple lists in parallel). Accidental semicolons
tend to happen at the ends of lists, and it's really antisocial to
retroactively wrap a [...] around the entire list merely because of
a trailing semicolon.
Plus it settles the whole issue of what to do with multiple pipes into
the same function. But I don't think Parrot has to worry about that,
as long as Perl 6 can hook the binding of the slurpy sufficiently well
to think about it.
Larry