You are viewing a plain text version of this content. The canonical link for it is here.
Posted to modperl@perl.apache.org by Ken Williams <ke...@forum.swarthmore.edu> on 2000/06/17 01:06:55 UTC

$r->print(\$var) (WAS: Re: Slightly OT - Content-length)

perrin@primenet.com (Perrin Harkins) wrote:
>Incidentally, the $r->print() method conveniently lets you pass the string
>you want to send by reference.

I know this debate has been had before, but I think here's something new
to say.  I think this behavior is very strange, and actually
unnecessary.  It's unnecessary because in Perl *all* function arguments
are actually passed by reference, though we almost never notice (or
know) this.  For instance:

       {
         my $var = 7;
         &blah($var);
         print "$var\n";
       }

       sub blah { $_[0] = 9 }
       ---------------------------------
       Output: 9


It seems like $r->print() could easily take advantage of this behavior
just by being careful not to copy its arguments into new string
variables.  Then it would be unnecessary to ever pass by explicit
reference.

Just trying to make the point - I don't think it was made last time
around (and for some reason our list archive isn't searching recent
messages, so I couldn't actually check).


  -------------------                            -------------------
  Ken Williams                             Last Bastion of Euclidity
  ken@forum.swarthmore.edu                            The Math Forum