in reply to Are lvalue methods (as properties) a good idea?

I didn't know what lvalues were when I read this post, so I did a little research and found:

Definition of lvalue: A reference to a location, an expression which can appear as the destination of an assignment operator indicating where a value should be stored. For example, a variable or an array element are lvalues but the constant 42 and the expression i+1 are not.

http://www.google.de/search?q=cache:h6MRIOsNjKwJ:www.hyperdictionary.com/computing/lvalue+lvalue&hl=de

thomas.

Replies are listed 'Best First'.
Re: Definition of lvalue
by theorbtwo (Prior) on Jan 16, 2005 at 14:46 UTC

    That's a somewhat confusing defintion of lvalue. A lvalue, quite literally, is something that can appear on the left hand side of an = operator -- that is, something that can be assigned to. In perl, that includes assignable variables (read: almost all variables), and calls to lvalue subroutines (including lvaluable builtins like substr, and user-defined subroutines with the :lvalue attribute). (The first half of that includes, of course, any expression that results in an assignable variable, such as $foo->{bar}{baz}{quux}[-1].) The 42 in 42=1; is a non-lvalue in a slot that needs an lvalue. Note that there are places that need an lvalue other then the right-hand-side of a = operator, such as all the *= operators, ++ and --, and some sub arguments, sometimes only in some situations. In general, if an operation is going to modify something, that something must be an lvalue -- which is another defintion of lvalue: "something that can be modified".


    Warning: Unless otherwise stated, code is untested. Do not use without understanding. Code is posted in the hopes it is useful, but without warranty. All copyrights are relinquished into the public domain unless otherwise stated. I am not an angel. I am capable of error, and err on a fairly regular basis. If I made a mistake, please let me know (such as by replying to this node).