Table of Contents

# $EPIC: lval.txt,v 1.1 2007/08/06 21:25:50 jnelson Exp $

Lvalues (aka lvals)

An lvalue is the token on the left hand side of an assignment operation. More broadly speaking, an lvalue is a thing that may be assigned to.

There are several places where you use an lvalue:

/assign lval stuff Global variable to be assigned a value
/local lval stuff Local variable to be assigned a value
@ lval = stuff Global variable to be assigned a value
/stub assign lval filename Global variable to be loaded on demand
$unshift(lval stuff) Prepending to a global variable
/unshift lval stuff Prepending to a global variable
$push(lval stuff) Appending to a global variable
/push lval stuff Appending to a global variable
$shift(lval stuff) Prepending to a global variable
/shift lval stuff Prepending to a global variable
$pop(lval stuff) Prepending to a global variable
/pop lval stuff Prepending to a global variable
$aliasctl(SET lval …)
@ lval++
@ lval
Any math operator that does an assignment
$splice(lval stuff)
$shiftbrace(lval)
$sar(r/old/new/lval)
$msar(r/old/new/lval)
$getopt(…)
/fe (…) lvals {…}
/fe :lval (…) lvals {…}
Arglists

What an lvalue looks like

An lvalue may be prefixed with zero, one, or two colons:

An lvalue contains any number of characters:

Followed by any number of array subexpressions, which are any text expression surrounded by square brackets. There are no restrictions on what may be inside an array subexpression.

Examples:

/assign myvar one
/echo $myvar                  

Will output “one”

/local myvar two
/echo $myvar                  

Will output “two” because local variables overrule global variables

/echo $::myvar

Will output “one” because two colons forces the global variable to be used.

/assign :othervar one

Creates a local variable, because one colon is prefixed.

/assign ::othervar two

Creates a global variable, because two colons are prefixed.

/assign othervar three

Changes the local variable, because local variables overrule global vars.

@ myvar$testing = [one]

Invalid because $'s are not allowed in variable names

@ myvar[$testing] = [one]

Allowed, because array subexpressions can contain any text expression. Please note that array subexpressions are part of the lval and are always treated as text, even in an expression!

@ myvar.$function() = [one]

Invalid, because no $'s are permitted

@ myvar[$function()] = [one]

Permitted, because the array subexpression can contain any text.