Re: contiguity of arrays
From: Wojtek Lerch (Wojtek_L_at_yahoo.ca)
Date: 10/05/04
- Next message: Mike Wahler: "Re: Reply"
- Previous message: Dave: "Re: C++ array relative C question"
- In reply to: David Hopwood: "Re: contiguity of arrays"
- Next in thread: David Hopwood: "Re: contiguity of arrays"
- Reply: David Hopwood: "Re: contiguity of arrays"
- Reply: Keith Thompson: "Re: contiguity of arrays"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Tue, 5 Oct 2004 10:31:37 -0400
"David Hopwood" <david.nospam.hopwood@blueyonder.co.uk> wrote in message
news:s6p8d.210978$hZ3.162938@fe2.news.blueyonder.co.uk...
> Wojtek Lerch wrote:
>> "David Hopwood" <david.nospam.hopwood@blueyonder.co.uk> wrote in message
>> news:SV68d.154584$U04.107170@fe1.news.blueyonder.co.uk...
>>>Wojtek Lerch wrote:
>>>>"David Hopwood" <david.nospam.hopwood@blueyonder.co.uk> wrote:
>>>>
>>>>>to perform an access via a given pointer, say of type T, you need to be
>>>>>able to infer that it currently points to a region that *can* hold an
>>>>>object
>>>>>of type T. The memory allocation functions are a special case that
>>>>>return
>>>>>pointers to regions able to hold objects of any type.
>>>>
>>>>That is not a very accurate wording: regions of memory don't hold
>>>>objects, they are objects.
>>>
>>>No. Objects are typed; memory regions aren't.
>>
>> No. Objects are regions of memory; lvalues that designate objects are
>> typed. "When an object is said to have a particular type, the type is
>> specified by the lvalue used to designate the object."
>
> That isn't actually consistent with how the standard uses the term
> "object".
No, the standard doesn't seem consistently pedantic about consistency, does
it. In some cases, it says "the type" of an object when talking about the
object's declared type.
> If you search for "object" you'll see that in most cases the usage depends
> on objects (and *not* just lvalue expressions) having a type. For example:
That's because in most cases, objects are talked about in the context of a
declaration or an expression.
> # 3.2
> # alignment
> # requirement that objects of a particular type be located [...]
Nothing wrong here: objects (i.e. regions of memory) accessed through an
lvalue of a particular type must be aligned appropriately to the type.
> # 3.5
> # bit
> # unit of data storage in the execution environment large enough to
> # hold an object that may have one of two values
I don't think they really meant an "object" here. A C object can't be
smaller than eight bits, can it?
> [memory regions cannot have values; objects can only have values because
> they have a type]
The contents of memory regions (i.e. objects) represent values when
interpreted according to a type.
> # 3.7.3
> # wide character
> # bit representation that fits in an object of type wchar_t [...]
This is not really a good definition, is it?... A wide character is not a
bit representation. It's an integer value of type wchar_t.
> # 3.15
> # parameter [...]
> # object [...] that acquires a value on entry to the function
>
> [again, objects can only have values because they have a type]
The contents of objects represent values. The standard often says "value"
when it really means "contents". For instance, 6.5p7 says, "An object shall
have its stored value accessed only by an lvalue expression that has one of
the following types..."
> # 5.1.2 Execution environments
> # [...] All objects with static storage duration shall be /intialized/
> (set
> # to their initial values) before program startup. [...]
>
> [there is no lvalue expression involved in this case]
No, but they have a declared type.
> etc., etc.
Don't forget about this one:
# 3.14
# object
# region of data storage in the execution environment, the contents of which
can represent values
>>>>An allocated object can be given any effective type by using an lvalue
>>>>of
>>>>that type to store a value in the object.
>>>
>>>More accurately, an allocated region can be accessed as an object of any
>>>given effective type, by using an lvalue expression that designates an
>>>object of
>>>that type to store a value in that object.
>>
>> Even more accurately, the effective type of an allocated object can be
>> *changed* to any given type by using an lvalue of that type to store a
>> value
>> in the object.
>
> This is not a more accurate statement of the same thing; it's an entirely
> different semantics. C implementations actually implement what I said.
Maybe; I have to admit that I don't understand what you mean by "object".
If it's not a region of memory, or an lvalue that designates a region of
memory, or a value, then what is it?
- Next message: Mike Wahler: "Re: Reply"
- Previous message: Dave: "Re: C++ array relative C question"
- In reply to: David Hopwood: "Re: contiguity of arrays"
- Next in thread: David Hopwood: "Re: contiguity of arrays"
- Reply: David Hopwood: "Re: contiguity of arrays"
- Reply: Keith Thompson: "Re: contiguity of arrays"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|