On Tue, Nov 14, 2006 at 10:15:42PM -0500, Vincent Foley wrote:
: Hello everyone,
: 
: I was toying around with Pugs and I tried the following Perl 5 list 
: assignment
: 
:  my ($a, undef, $b) = 1..3;
: 
: Which gave me the following error message:
: 
:  Internal error while running expression:
:  ***
:      Unexpected ","
:      expecting word character, "\\", ":", "*" or parameter name
:      at <interactive> line 1, column 14
: 
: I had a quick discussion on #perl6 with TimToady++ during my lunch
: hour, and he said that assignment to undef was no longer valid.  His
: suggestion was to use the whatever operator (*) instead.

FWIW, I think we should follow gaal++'s suggestion and just use $ instead.
Now that I think about it some more, the * is likely to be confused with
the slurpy *, at least by readers if not by the parser.

: Now, this isn't implemented and my Haskell skills and knowledge of
: Pugs' internals aren't really advanced enough to implement this
: feature, however I can surely contribute the tests.  Here's what I
: have right now in my working copy, let me know if this seems
: reasonable.

(assuming * replaced by $ here)

:    my @a = 1..3;
:    my ($one, *, $three) = @a;
:    is(~($one, $three), "1 3", "list assignment my ($, *, $) = @ works");

Why not just interpolate: "$one $three"

:    my (*, $two) = @a;
:    is($two, 2, "list assignment my (*, $) = @ works");
:    my (*, *, $three) = @a;
:    is($three, 3, "list assignment my (*, *, $) = @ works");

Note that this "my $three" is declaring the same $three lexical,
unlike in Perl 5, which would warn about a redeclaration.  That's part
of why it's customary to put each test chunk in its own bare block
to prevent such accidental collisions.

:    my (*, @b) = @a;
:    is([EMAIL PROTECTED], "2 3", "list assignment my (*, @) = @ works");

Other than that, looks good to me.

Larry

Reply via email to