An
lvalue is an expression that you can write on the left hand side of an assignment statement - in other words an expression that defines a specific memory address of a variable.
The most common lvalues are simple variables or array / list / hash / dictionary members ... for example
$hello = "Hello World";
$greet[5] = "Hello World";
$greet{"UK"} = "Hello World"; # all these in Perl
val = 15;
jolly[posn] = 27; # These two in C
There are some surprises until you think about it.
In Perl you can write
$lhs[$n+4] = 17; but not
$lhs+4 = 17;. Yet in C, if vvv is a pointer to an array you can write
vvv+4 = 15; quite happily - altering the fifth element of the array.
You'll find the term
lvalue come up most usually for the programmer in a compiler error message -
"invalid lvalue" you will be told. What the compiler
really means is that the twit who wrote the code is trying to save a value into an expression that doesn't actually define the memory address of a variable.
(written 2008-03-18)
Associated topics are indexed under
C212 - C and C based languages - Memory Management [3416] Storing Tcl source code encoded, and running via your own C program - (2011-09-02)
[3386] Adding the pieces together to make a complete language - C - (2011-08-11)
[3144] Setting up arrays in C - fixed size at compile time, or dynamic - (2011-01-24)
[3118] Arrays of arrays - or 2D arrays. How to program tables. - (2011-01-02)
[2848] C course - final course example puts it all together - (2010-07-02)
[2669] Efficient use of dynamic memory - C and realloc - (2010-03-10)
[1845] Passing a table from Lua into C - (2008-10-18)
[1670] Dynamic Memory Allocation in C - (2008-06-09)
[1589] Dynamic Memory Allocation in C - calloc, realloc - (2008-03-22)
[1497] Training Season Starts again! - (2008-01-07)
P301 - Variables in Perl [3430] Sigils - the characters on the start of variable names in Perl, Ruby and Fortran - (2011-09-10)
[3059] Object Orientation in an hour and other Perl Lectures - (2010-11-18)
[2972] Some more advanced Perl examples from a recent course - (2010-09-27)
[2877] Further more advanced Perl examples - (2010-07-19)
[2374] Lead characters on Perl variable names - (2009-08-24)
[2241] Perl references - $$var and \$var notations - (2009-06-15)
[1946] Variable Types in Perl - (2008-12-15)
[975] Answering ALL the delegate's Perl questions - (2006-12-09)
Some other Articles
Well House Consultants / Manor - StaffUsing Structs and Unions together effectively in CBusinesses in West Wiltshire - networkingRuby, C, Java and more - getting out of loopsWhat is an lvalue? (Perl, C)Congratulations, Martin and MartaRome, and the faith of RomePlease don't shout at me!Spring and early summer training coursesMaking PHP and MySQL training relevant to the course delegates