go ahead... be a heretic | |
PerlMonks |
Re^6: can sub check context for lvalue vs rvalue context?by perl-diddler (Chaplain) |
on May 10, 2018 at 18:54 UTC ( [id://1214349]=note: print w/replies, xml ) | Need Help?? |
I have a feeling we are not using the same terms as having the same meaning.
When I return an lvalue, in my mind, I'm returning the address of an object so that the compiler/interpreter can put something in it (has happens to the left side of an assignment). Vs. if I return an rvalue, In my terminology, I'm only returning the value that was in that address -- so the compiler/interpreter can't assign a new value into the variable location. If I return an lvalue, the compiler can store a new value. But it can also propagate that value to another lvalue. No problem: I don't care. What I care about is detecting that my lvalue sub has been assigned to (whether or not the value changes is irrelevant). The rvalue context I would detect in a statement like: would allow me to return an actual value and not a tied var. It's the 'lvalue' case where I need to presume that the value in 'url might change, and thus return a more expensive (ex. tied) version so I can update the url's component values. I don't see how that is problematic.
In Section
Seekers of Perl Wisdom
|
|