in reply to [Perl 6] Re: Passing two arrays to a subroutine
in thread Passing two arrays to a subroutine

Well I liked the reply from moritz, it was a bit of fun and that's good (I gave him a ribbing on a /msg though).

Back to the question. Correct me if I'm wrong (I know you will), but isn't the Perl 6 solution using references as well? To quote Apocalyse 6:
"All positional parameters regardless of their type are considered scalars, and imply scalar context for the actual arguments. If you pass an array or hash to such a parameter, it will actually pass a reference to the array or hash, just as if you'd backslashed the actual argument.

So Perl 6 still passes references, its just that the syntax no longer requires the \.
  • Comment on Re: [Perl 6] Re: Passing two arrays to a subroutine

Replies are listed 'Best First'.
Re^2: [Perl 6] Re: Passing two arrays to a subroutine
by moritz (Cardinal) on Sep 29, 2010 at 08:36 UTC
    To quote Apocalyse 6

    Please note that the Apocalypses are mostly historical documents. S06 is what you should consider.

    but isn't the Perl 6 solution using references as well?

    Yes. Under the hood, every argument passing uses references, unless the parameter is decorated with the is copy trait. Unlike in Perl 5, these references are write protected by default.

    So Perl 6 still passes references, its just that the syntax no longer requires the \.

    Not only the backslash, but also the dereferencing inside the subroutine. Since (nearly) everything in Perl 6 is a reference, references are transparent, and don't require special syntax on either side.

    Perl 6 - links to (nearly) everything that is Perl 6.
Re^2: [Perl 6] Re: Passing two arrays to a subroutine
by chromatic (Archbishop) on Sep 28, 2010 at 20:34 UTC
    So Perl 6 still passes references, its just that the syntax no longer requires the \.

    It's slightly more accurate to say (from the language design point of view) that Perl 6 passes these values by reference. Unfortunately, then things get complex with other parameter traits and so on and so forth.