We use modify-by-reference in CGI::Application to prevent copying large HTML documents into the "postrun" routine.
This is a technique that should be used sparingly, as returning explicit values creates for clearer code flow.
Perl6 helps promotes good programming practices in two ways in this regard. 1. You have explicitly turn on modify-by-reference for a subroutine argument, and 2. This explicitness makes it clear that this trick is being employeed. Let's a take a look at the syntax:
Was: sub foo {...}; foo(\$bar)
Now: sub foo ($bar is rw); foo($bar)
Perl6 is
If you want a copy of the value passed, Perl6 covers that too:
sub foo ($bar is copy);
Aspects of this may seem formal compared to the looseness of Perl5. So far I've generally liked these changes, as compactness and clarity often come with them.
CGI::App to Perl6: Another improvement for references 0 Comments More | Login | Reply /