Write-only variables

Rick Schubert rns at se-sd.NCR.COM
Wed Sep 20 05:34:14 AEST 1989


In article <1989Sep14.183749.12753 at jarvis.csri.toronto.edu> flaps at dgp.toronto.edu (Alan J Rosenthal) writes:
>% humourously, in ansi C, not all lvalue expressions in C have meaning as
>lvalues (namely, array names).

This is true if your definition of "lvalue" is something that can be assigned
to (i.e. appear as the left-hand side of an assignment operator);
however, this is not how ANSI C defines `lvalue'.  From 3.2.2.1:
______________________________________________________________________________
           An `lvalue' is an expression (with an object type or an
      incomplete type other than |void|) that designates an object.*
      When an object is said to have a particular type, the type is
      specified by the lvalue used to designate the object.
      A `modifiable lvalue' is an lvalue that does not have array
      type, does not have an incomplete type, does not have a
      const-qualified type, and if it is a structure or union,
      does not have any member (including, recursively, any member
      of all contained structures or unions) with a const-qualified
      type.
      ________________
      * The name "lvalue" comes originally from the assignment expression
        E1 = E2, in which the left operand E1 must be a (modifiable)
        lvalue.  It is perhaps better considered as representing an
        object "locator value."  What is sometimes called "rvalue" is in
        this Standard described as the "value of an expression."
      
        An obvious example of an lvalue is an identifier of an object.
        As a further example, if E is a unary expression that is a
        pointer to an object, *E is an lvalue that designates the object
        to which E points.
______________________________________________________________________________

-- Rick Schubert (rns at se-sd.sandiego.NCR.COM)



More information about the Comp.lang.c mailing list