|
|
| The stupid question is the question not asked | |
| PerlMonks |
Passing a reference by value is somewhat equivalent to call by referenceby stefp (Vicar) |
| on Sep 24, 2001 at 11:55 UTC ( [id://114291]=note: print w/replies, xml ) | Need Help?? |
This is an archived low-energy page for bots and other anonmyous visitors. Please sign up if you are a human and want to interact.
It is only possible to pass scalars by reference to a sub.
Parameters are passed by value in Perl. But we have an operator, the backslash, that returns reference to any variable (scalar or composite). So the net result is that we have a mechanism to pass parameter by reference. Admittedly, this not very clean, because the formal parameter is declared as a scalar even if it is a reference to a non scalar. I guess that was the point that tried to convey the sentence: It is only possible to pass scalars by reference to a sub.
tilly messages me: another example of how to pass arrays by reference is by using prototypes. Unlike using \ in user code, that is transparent.. So Perl has call by reference after all (even if it was quite a late addition?). -- stefp
In Section
Seekers of Perl Wisdom
|
|
||||||||||||||||||||||||