🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.std.c
Article #61

Re: on "use", and the lvalue-ness of string literals

#61
From: Barry Margolin
Date: Tue, 03 Nov 1992 22:07
35 lines
2122 bytes
In article <FRANL.92Nov3115154@draco.centerline.com> franl@centerline.com (Fran Litterio) writes:
>linden@diskus.Eng.Sun.COM (Peter van der Linden) writes:
>
>> Blair asks:
>> > It's an LVALUE.  This means that,
>> >   "foo" = "bar";
>> > is legal.  Right?
>> 
>> Wrong.   ANSI C defines and draws a distinction between l-values
>> and modifiable l-values.  A string literal (in fact any array) is
>> the former, but not the latter.
>
>Was the term "non-modifiable l-value" invented by ANSI, or was it
>"prior art"?  I was always taught that the 'l' in "l-value" comes from
>the idea that an l-value is what can appear on the left-hand-side of
>an assigment expression.

The term comes from the fact that anything that can appear as the target of
an assignment is an l-value; however in some languages (such as C) there
are also l-values that cannot appear on the lhs of an assignment.

>A non-modifiable l-value sounds a lot like an r-value to me.

Not really.  An l-value is a value that has a fixed storage location.  In
languages that don't have the notion of read-only storage, all l-values can
be assigned to.  But in languages like C, there are other operations that
only make sense for l-values, whether they're modifiable or not.  The most
obvious one in C is the & operator.  You can't have &(foo+bar) because the
result of addition is an r-value; however, given the declaration "const int
foo" you can have &foo because foo is an unmodifiable l-value.
-- 
Barry Margolin
System Manager, Thinking Machines Corp.

barmar@think.com          {uunet,harvard}!think!barmar
Technical Details
Message-ID: <1d6t7fINN6at@early-bird.think.com>
Path: arc1-ca.pugleaf.net!sparky!uunet!caen!sdd.hp.com!think.com!barmar
References: <1992Nov2.162310.10094@ichips.intel.com> <lfb087INN8na@exodus.Eng.Sun.COM> <FRANL.92Nov3115154@draco.centerline.com>

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!sparky!uunet!caen!sdd.hp.com!think.com!barmar
From: barmar@think.com (Barry Margolin)
Newsgroups: comp.std.c
Subject: Re: on "use", and the lvalue-ness of string literals
Date: 3 Nov 1992 22:07:43 GMT
Organization: Thinking Machines Corporation, Cambridge MA, USA
Lines: 35
Message-ID: <1d6t7fINN6at@early-bird.think.com>
References: <1992Nov2.162310.10094@ichips.intel.com> <lfb087INN8na@exodus.Eng.Sun.COM> <FRANL.92Nov3115154@draco.centerline.com>
NNTP-Posting-Host: telecaster.think.com