On Fri, Aug 13, 2010 at 8:11 PM, Jon Murray <perlsm...@gmail.com> wrote:

> My understanding from synopses was that you get the Perl 5 behaviour if
> you omit the signature on your function declaration (though I
> unfortunately can't check as I don't have Rakudo installed):
>
> sub foo { @_[0] = 1 }
> my $a = 0;
> foo($a);
> say $a; # 0
>
>

Nope. In fact, as you indicated in the comment you left in, that prints 0
just like the first example. In neither case is $a modified. In Perl 5, on
the other hand, the passed value can be modified:

$ ./perl6 -e 'sub foo { @_[0] = 1 } ; my $a = 0; foo($a); say $a'
0
$ perl -le 'sub foo { $_[0] = 1 } my $a = 0; foo($a); print $a'
1

You might well be correct about how it's supposed to work, but that's
certainly not the current behavior.


On Fri, 2010-08-13 at 12:06 -0400, Aaron Sherman wrote:
> > On Fri, Aug 13, 2010 at 11:27 AM, Jonathan Worthington
> > <jonat...@jnthn.net>wrote:
> >
> > >
> > >>
> > > I saw a video camera in the room, but not sure when we'll be seeing the
> > > footage from that. In the meantime, the slides are at:
> > >
> > > http://www.jnthn.net/papers/2010-yapc-eu-signatures.pdf
> > >
> > >
> > Nice talk! One minor nit, and perhaps I'm just misunderstanding some
> subtle
> > use of the terminology, but you say:
> >
> > "In Perl 5, you get a copy of the arguments to work with in @_."
> >
> > However, this isn't true (again, unless I'm misunderstanding you). @_ is
> a
> > by-reference list of positional parameters (Perl 5 only has positionals)
> > which are all read-write, which it's interesting to note, is impossible
> in
> > Perl 6... well, at least in Rakudo, as I'm not sure what the behavior is
> > supposed to be, but a slurpy positional list in Rakudo that's declared
> "is
> > rw" does not change the values passed in:
> >
> > sub foo(*...@_ is rw) { @_[0] = 1 }
> > my $a = 0;
> > foo($a);
> > say $a; # 0
> >
> > Kind of interesting that you can't easily emulate Perl 5's parameter
> > passing...
> >
>
>
>


-- 
Aaron Sherman
Email or GTalk: a...@ajs.com
http://www.ajs.com/~ajs

Reply via email to