U
Uri Guttman
XC> In article <[email protected]>,
XC> Yes. I think we can hammer at this distinction all night long
XC> without letting any more light into the room. I've tried to make
XC> it abundantly clear that an alias is not, as Perl defines it, a
XC> ref(erence). However, Perl does implement param passing via
XC> call-by-reference, generally speaking. Otherwise, it would not be
XC> possible to do anything within a sub that could clobber a param
XC> within the calling context.
the light needs to be shown inside your head. no one else has a problem
with how perl handles sub args. so stop making claims that make no
sense.
XC> Somebody at this point might say that an evil demon might pass a param
XC> *value*, then look to see if $_[$i] had been changed and if so, go back
XC> and put the new value back in the old mailbox. I don't know anything
XC> about Perl internals but I'll bet a dollar to a doughnut that this is
XC> not the case. Rather, I'll bet that $_[$i] points directly to the
XC> mailbox itself. Please correct me if I'm wrong.
*boggle*
XC> At this, my chosen level of abstraction, there are only two ways to pass
XC> a param to a sub: call-by-reference or call-by-value. Perl does the
XC> former. Am I mistaken? If so, how?
you chosen level is wrong. you write perl code as if it was always call
by value. you pass refs if you want call by ref. sometimes you can use
the alias nature of @_ to do call by ref but that IS NOT THE COMMON
CASE. so drop it already and ignore that case. it doesn't matter to
almost all the perl code out there. a very very tiny fraction uses @_ as
a call by ref. and hopefully only by those who understand why it is
useful
XC> It is deliberate (on the part of the Perl maintainers) and it is all the
XC> time. When somebody writing code in Perl fails to understand this
XC> mechanism he may, by accident, screw up -- and if foolish, blame Perl,
XC> if wise, study and learn. When somebody who understands it makes
XC> deliberate use of it, he may thank Larry Wall, wisely, or compliment
XC> himself, foolishly.
no. most perl coders never see that nor will that. most coders are
taught to copy @_ to lexical vars and that is call by value. simple and
safe and proper.
XC> ... and so it is. It is crystal clear in my mind -- both that params are
XC> not automatically refs, as defined by Perl; and that @_ is a list of
XC> parameters that are passed by the mechanism of call-by-reference. One
XC> thing is not the other; I don't know how to make it any clearer. I've
XC> done my best and I'm sorry if I've still come up short.
no you have made it clear you understand the difference. what you have
not made clear is whether you understand that the alias nature of is NOT
IMPORTANT. no one calls perl a pass by ref lang. its common style is
pass by value. that is what matters not how it is implemented.
XC> May the heavens guide the poor man who stumbles onto this thread,
XC> thinking about passing a Perl ref as a param. It certainly can be done
XC> (and often is) and this has nothing to do with the alias nature of @_.
no. they will see our replies to you and realize that common perl is
pass by value.
XC> If you copy the value, that doesn't make the calling mechanism
XC> call-by-value. A language that implements parameter passing via
XC> call-by-value will not (by default) pass anything to the sub that will
XC> allow it to modify anything outside the sub (except, perhaps, global
XC> variables and a return value, neither of which are enabled by the
XC> parameter passing mechanism). That is:
if you code in a pass by value style which is the recommended and taught
style it is a pass by value language. you have obviously never used PL/I
or algol or lisp or other pass by ref langs but which were largely used
in a pass by value style.
XC> A language that implements pass-by-reference will print 47. That's all;
XC> there is no in-between. An alias is a high-level abstraction that
XC> encapsulates a reference -- not a Perl ref, not something that can be
XC> interpreted as a Perl ref or explicitly dereffed. An alias is implicitly
XC> dereffed when used.
not if you copy from the alias first as is always taught and commonly
done. that is what matter. language conventions are just as important as
syntax and implementation. no language lives alone. perl is a pass by
value language because that is the convention. period. end of
discussion. nothing you say matters about this.
XC> Let me say again (in case it helps) that my primary orientation is way
XC> down the ladder. When a sub invokes in most languages, it pops its
XC> params off the stack. Now, at the moment of the pop, that word popping
XC> off the stack is either the value that the calling routine had in "mind"
XC> when deciding to call the sub; or that popped word is a pointer into the
XC> heap or possibly another part of the stack, at which location the actual
XC> value is found. The first case is call-by-value; the second
XC> call-by-reference.
it doesn't matter what you think or how it is implemented. it is pass by
value by convention. rinse. repeat.
XC> I've read others of this gentleman's posts and while it's not clear to
XC> me whether he knows his stuff or not, he *seems* to me to lean rather
XC> hard into other posters who don't appear to speak his language, his way.
XC> Either way, I certainly don't want to insult him -- or anyone else. Yet
XC> I would appreciate being allowed the same courtesy and I'm afraid I'm
XC> not going to get it.
which gentleman?
XC> Am I right, in which case I should from now on ignore him? Or am I a
XC> babbling fool? I leave it to the group to set me straight.
you an ignore anyone you want. most will be ignoring you. few ignore me
or maybe more should. but i do know what call by value is and how perl
is a call by value language no matter how it is implemented
underneath. and i also said @_ is aliased for SPEED and RAM reasons but
copies are made of the args for SAFETY reasons. perl is both a floor wax
and a dessert topping.
uri
XC> Yes. I think we can hammer at this distinction all night long
XC> without letting any more light into the room. I've tried to make
XC> it abundantly clear that an alias is not, as Perl defines it, a
XC> ref(erence). However, Perl does implement param passing via
XC> call-by-reference, generally speaking. Otherwise, it would not be
XC> possible to do anything within a sub that could clobber a param
XC> within the calling context.
the light needs to be shown inside your head. no one else has a problem
with how perl handles sub args. so stop making claims that make no
sense.
XC> Somebody at this point might say that an evil demon might pass a param
XC> *value*, then look to see if $_[$i] had been changed and if so, go back
XC> and put the new value back in the old mailbox. I don't know anything
XC> about Perl internals but I'll bet a dollar to a doughnut that this is
XC> not the case. Rather, I'll bet that $_[$i] points directly to the
XC> mailbox itself. Please correct me if I'm wrong.
*boggle*
XC> At this, my chosen level of abstraction, there are only two ways to pass
XC> a param to a sub: call-by-reference or call-by-value. Perl does the
XC> former. Am I mistaken? If so, how?
you chosen level is wrong. you write perl code as if it was always call
by value. you pass refs if you want call by ref. sometimes you can use
the alias nature of @_ to do call by ref but that IS NOT THE COMMON
CASE. so drop it already and ignore that case. it doesn't matter to
almost all the perl code out there. a very very tiny fraction uses @_ as
a call by ref. and hopefully only by those who understand why it is
useful
XC> It is deliberate (on the part of the Perl maintainers) and it is all the
XC> time. When somebody writing code in Perl fails to understand this
XC> mechanism he may, by accident, screw up -- and if foolish, blame Perl,
XC> if wise, study and learn. When somebody who understands it makes
XC> deliberate use of it, he may thank Larry Wall, wisely, or compliment
XC> himself, foolishly.
no. most perl coders never see that nor will that. most coders are
taught to copy @_ to lexical vars and that is call by value. simple and
safe and proper.
XC> ... and so it is. It is crystal clear in my mind -- both that params are
XC> not automatically refs, as defined by Perl; and that @_ is a list of
XC> parameters that are passed by the mechanism of call-by-reference. One
XC> thing is not the other; I don't know how to make it any clearer. I've
XC> done my best and I'm sorry if I've still come up short.
no you have made it clear you understand the difference. what you have
not made clear is whether you understand that the alias nature of is NOT
IMPORTANT. no one calls perl a pass by ref lang. its common style is
pass by value. that is what matters not how it is implemented.
XC> May the heavens guide the poor man who stumbles onto this thread,
XC> thinking about passing a Perl ref as a param. It certainly can be done
XC> (and often is) and this has nothing to do with the alias nature of @_.
no. they will see our replies to you and realize that common perl is
pass by value.
XC> If you copy the value, that doesn't make the calling mechanism
XC> call-by-value. A language that implements parameter passing via
XC> call-by-value will not (by default) pass anything to the sub that will
XC> allow it to modify anything outside the sub (except, perhaps, global
XC> variables and a return value, neither of which are enabled by the
XC> parameter passing mechanism). That is:
if you code in a pass by value style which is the recommended and taught
style it is a pass by value language. you have obviously never used PL/I
or algol or lisp or other pass by ref langs but which were largely used
in a pass by value style.
XC> A language that implements pass-by-reference will print 47. That's all;
XC> there is no in-between. An alias is a high-level abstraction that
XC> encapsulates a reference -- not a Perl ref, not something that can be
XC> interpreted as a Perl ref or explicitly dereffed. An alias is implicitly
XC> dereffed when used.
not if you copy from the alias first as is always taught and commonly
done. that is what matter. language conventions are just as important as
syntax and implementation. no language lives alone. perl is a pass by
value language because that is the convention. period. end of
discussion. nothing you say matters about this.
XC> Let me say again (in case it helps) that my primary orientation is way
XC> down the ladder. When a sub invokes in most languages, it pops its
XC> params off the stack. Now, at the moment of the pop, that word popping
XC> off the stack is either the value that the calling routine had in "mind"
XC> when deciding to call the sub; or that popped word is a pointer into the
XC> heap or possibly another part of the stack, at which location the actual
XC> value is found. The first case is call-by-value; the second
XC> call-by-reference.
it doesn't matter what you think or how it is implemented. it is pass by
value by convention. rinse. repeat.
XC> I've read others of this gentleman's posts and while it's not clear to
XC> me whether he knows his stuff or not, he *seems* to me to lean rather
XC> hard into other posters who don't appear to speak his language, his way.
XC> Either way, I certainly don't want to insult him -- or anyone else. Yet
XC> I would appreciate being allowed the same courtesy and I'm afraid I'm
XC> not going to get it.
which gentleman?
XC> Am I right, in which case I should from now on ignore him? Or am I a
XC> babbling fool? I leave it to the group to set me straight.
you an ignore anyone you want. most will be ignoring you. few ignore me
or maybe more should. but i do know what call by value is and how perl
is a call by value language no matter how it is implemented
underneath. and i also said @_ is aliased for SPEED and RAM reasons but
copies are made of the args for SAFETY reasons. perl is both a floor wax
and a dessert topping.
uri