Alf said:
* Kai-Uwe Bux:
Alf said:
* Kai-Uwe Bux:
Alf P. Steinbach wrote:
* Stefan Ram:
»An object is a region of storage that has a type.«
Not in C++.
»An object is a region of storage. [...] An object has a type«
ISO/IEC 14882:2003(E), 1.8
Sorry, a region of storage does not have a type.
The proposed definition of "object" does not entail the claim that any
region of storage has a type. It says that an object is a region of
storage that has a type.
You're contradicting yourself.
If a region of storage does not have a type, it would not
qualify as an object according to the proposed definition.
I think that's true.
So it's not compatible with C++.
That sentence only talks about those regions of storage that are not
object. But if x is an object and objects are regions of storage, then
some region of storage _is_ the object x. In that case, that region of
storage has a type since the object x has a type.
That's a category error. The atoms you're constituted of don't smell good
even if you've put on cologne.
(a) Your analogy is slightly misleading. I never claimed that the units of
memory comprising the region of storage have a type. The region as a whole
can still have a type (that is, the chunk of matter that is me can
definitely smell good if it puts on cologne even though the atoms don't).
(b) Nonetheless, it still would be a category error if "object" and "region
of storage" were on conceptually different levels. However, [1.8/1]
precludes that (not because it makes an identification statement, but
because it does so in the context of a definition).
The standard, on the other hand, is very clear that some regions of
storage have types (namely those regions of storage that happen to be
objects).
Chapter & verse please.
You have already been given the necessary quotes:
[1.8/1]: An object is a region of storage. ["object" in italics]
Note that this is a conceptual stipulation that identifies objects with
regions of storage.
Note that it's not.
Of course it is. That is what "a is b" definitions do: they identify
concepts. In this case, the concept of "object" is identified with "region
of storage". I really don't see any wiggleroom in the wording; and it is
meant as a definition of the term "object".
Consequently, all attributes of an object become
attributes of the region of storage that this object happens to be (there
is no conceptual distinction between the object and the region of storage
that it _is_).
C.E.
Therefore, when the standard goes [in the same clause] to say that
objects have storage duration, lifetime, and type it _follows_ that
certain regions of storage (namely those that happen to be objects) have
storage duration, lifetime, and type.
C.E.
Your C.E. marks here are misplaced. As pointed out above, "object"
and "region of storage" are not on conceptually different levels. However,
that is (as I will agree below) a rather unfortunate state of affairs.
In short: the C.E. marks are whishfull thinking (and I share the wish
.
Shall we discuss angels & their sizes?
Unfortunately, I have not much to contribute to that discussion since I
have no experience with angels whatsoever. But please feel free to share
any insight you might have.
I hope I'll never encounter a materialist or a non-materialist for real,
if it's true they are folks who agree that such an inference would be
valid.
I'm somewhat frightened by insane people.
It's not at all insane. It's just the way identity statements generally
work. If X=Y, you can infer p(Y) from p(X). If you want to avoid the
conclusion, the correct way is not charging people making the inference
with insanity; the correct way is to rephrase the hypotheses so that
unwelcome conclusions are avoided. This goes even more if the hypotheses
are just definitions.
BTW: there are some cases where X=Y and p(X) does not imply p(Y). For
instance, at some point I believed that the number of planets orbiting the
sun is 9. Now, science tells us that it is 10 (or whatever the current
number is). Of course, I did not believe that 9 is 10. This phenomenon is
known: certain words such as "believe" span special contexts.
A region of storage may be part of many objects, with different types.
Yes, and nothing in the proposed definition of "object" would
contradict that.
It does.
How so? Let's say you have an object x of type T which has a member x.a
of type S. Also, suppose that x_ptr is a char* so that
[x_ptr, x_ptr+sizeof(T) )
_is_ the object X and a_ptr is a char* so that
[a_ptr, a_ptr + sizeof(S) )
_is_ the object x.a. Then the region [a_ptr, a_ptr+sizeof(S) ) has type S
and the region [x_ptr, x_ptr + sizeof(T) ) has the type T. Of course,
that even goes when the two regions of storage coincide. BTW: in that
case, x and x.a _are_ the same(!) object according to the standard (which
makes more sense that one might think at first: after all any change to x
will affect a).
Think about what you have ended up with: two different objects of
different types, created at different times, that are or are not
identically the same object depending on whether their sizes are the same.
You might also wish to think about what that means for construction and
automatic destructor calls.
It really makes a mess of that.
Thinking about it more, I had come to similar conclusions. I started
worrying mostly about life-time issues because although one could live with
object (as regions of storage) having multiple types, it would be much
harder to deal with the same object having different life-times.
No, a statement that has a reasonable general interpretation does not
necessarily mean an unreasonable special case interpretation.
Then, what is your interpretation of the _definition_ "an object is a region
of storage". I can see many nice interpretations of such a statement that
would avoid the above consequences, however, none of those interpretations
qualifies as a _definition_; and that is what makes it tricky. Definitions
fix the meanings of terms, that is, they are conceptual stipulations. If
you put "is" into a definition, you should mean it
Even if some
politicians think that's possible. "I did not have sex with that woman",
hey, must be generally true, because it's true according to my own very
special case interpretations of "sex" and "that" and "woman".
However, it doesn't matter, for it goes only to the practical reason why
regions of storage are not regarded as having types.
Understanding the difference between storage (untyped) and object
(typed) is
fundamental. For example, a void* doesn't point to storage of type void.
But it's no big deal to take that untyped storage and make an object out
of it via e.g. placement new.
I think it's wrong of you to try to sow confusion about this
distinction.
You may not like the conceptual identification of objects with regions of
storage, but the italics in the standard [1.8/1] make it very clear that
the statement "An object is a region of storage" is meant as a definition
of the term object.
Yes. Although that does not hold for all uses of italics, nor of all the
places where they forgot them.
Since it is supposed to be a definition, it makes an
identification on the conceptual level (for better or worse).
C.E.
Huh?
I can see the kind of understanding that motivated the C.E. marks above.
However, the statement
if "a is b" is put forth as a definition it makes an identification
on the conceptual level
is not a category error. (It still might be too bold or general and
therefore false, but that is a different matter.)
Now you're talking, except that the proposed wording is nearly just as bad
as the one we're discussing, which is due to a faulty conceptual
foundation. The static type is not associated with the region (a runtime
concept). The static type is associated with a name in the source code
(compile time). Concentrate on that before starting to veer off into
dynamic type. Essentially, "storage" is wholly and only a runtime concept,
while the "object" concept is a bridge over to the compile time view, how
we choose to think of the storage in one particular context, including
(the type) restrictions on possible operations.
Well, the notion of "object" that you are proposing is certainly attractive.
It is not the one put forth in [1.8/1], but I think it would make perfect
sense to rework [1.8/1] in that direction.
BTW: I don't think the identification is actually all that harmful. The
standard is not a book to teach C++ but just a specification that should
allow one to deduce the observable behavior of C++ programs. I do not
(yet) see how that [1.8/1] or my interpretation of it negatively impacts
on that.
Having a conceptual foundation that leads to incorrect conclusions (such
as your identification of two different objects as the same object),
It's not an incorrect conclusion, it's an unwelcome consequence. Don't shoot
the messanger
and
that precludes forming some correct conclusions, and that stands in the
way of insights and general understanding, as well as understanding what
the heck other people are talking about, and learning new stuff, is
ungood.
Well, it's even more ungood if it stands in the way of making sense of the
rest of the standard. And at least with regard to life-time, it seems to do
exactly that.
Best
Kai-Uwe Bux