Slash Boxes
NOTE: use Perl; is on undef hiatus. You can read content, but you can't post it. More info will be forthcoming forthcomingly.

All the Perl that's Practical to Extract and Report

The Fine Print: The following comments are owned by whoever posted them. We are not responsible for them in any way.
More | Login | Reply
Loading... please wait.
  • Man, that "is copy" is really annoying. Maybe it just takes some getting used to, but this strikes me as a default that's set wrong. Btw, why does everyone seem to enjoy writing everything backward-style in Perl 6? It seems like most of the code samples I see are of the form: @foo.rotate($x).perl.say Is there, within every Perl programmer, a Ruby/Smalltalk lover waiting to get out?
    • Why is it backwards?

      • In Perl 5, people almost always do either this:

        sub foo {
            my $param = shift;
            # ...

        or this:

        sub foo {
            my ( $param ) = @_;
            # ...

        In both cases, you work on a copy. Almost never do people work directly with the values in @_. And that works out very well, because you almost never want to pass parameters by reference, almost always by value.

        But the Perl 6 setup defaults to giving you named aliases (as opposed to the array of aliases you get with Perl 5), which you’re then expected to work on directly. If you want Perl 5 style effective behaviour, it’s actually easier to write it exactly the same way as in Perl 5, ie. my ( $foo, $bar, $baz ) = @_;, than to do it the Perl 6 way by parrotting is copy after each parameter: ( $foo is copy, $bar is copy, $baz is copy ).

        So the default is definitely wrong.

        • I actually meant "Why do you say that chained method calls are backwards?" I try to stay out of the perpetual pass by value/pass by reference wars. (I need some sort of self-discipline somewhere.)

          • While I knew what you were referring to, I do agree with Aristotle. In trying to work out the "99 Problems", I'm finding "is copy" is getting very annoying. I would be nice to have a simple syntax which would allow this, when it's appropriate.

            Now if only I knew someone on the Perl 6 design team to explain that too ... :)