How to "reset" an object

A

Alf P. Steinbach /Usenet

* Juha Nieminen, on 27.06.2010 15:24:
Define "object".

In C++ an object is a (not necessarily contiguous) region of memory.


Cheers & hth.,

- Alf
 
K

Keith H Duggar

* Juha Nieminen, on 27.06.2010 15:24:



In C++ an object is a (not necessarily contiguous) region of memory.

It is a region of /storage/ that satisfies /certain properties/. Those
properties are with regard to lifetime, type, etc.

1.7 The C++ object model [intro.object]

1 The constructs in a C++ program create, destroy, refer to, access,
and
manipulate objects. An object is a region of storage. An object
is
created by a definition (_basic.def_), by a new-
expression
(_expr.new_) or by the implementation (_class.temporary_) when
needed.
The properties of an object are determined when the object is
created.
An object can have a name (_basic_). An object has a storage
duration
(_basic.stc_) which influences its lifetime (_basic.life_). An
object
has a type (_basic.types_). The term object type refers to the
type
with which the object is created. Some objects are
polymorphic
(_class.virtual_); the implementation generates information
associated
with each such object that makes it possible to determine
that
object's type during program execution. For other objects, the
inter-
pretation of the values found therein is determined by the type of
the
expressions (_expr_) used to access them.

KHD
 
A

Alf P. Steinbach /Usenet

* Keith H Duggar, on 28.06.2010 16:27:
It is a region of /storage/

I do not for a moment doubt that you understand that memory and storage is the
same thing in this context. Thus, your emphasis that indicates a contradiction,
is an attempt at misleading some non-programmer uninformed readers, unless
you're somewhere at the moron level, which I strongly doubt. So, it is a lie,
and it is a pretty stupid lie. I'm getting tired of your blatant dishonesty.

that satisfies /certain properties/.

Likewise, I have no doubt whatsoever that you understand that a region of memory
that satisfies certain properties, is a region of memory.

Those
properties are with regard to lifetime, type, etc.

1.7 The C++ object model [intro.object]

1 The constructs in a C++ program create, destroy, refer to, access,
and
manipulate objects. An object is a region of storage.

Note that last sentence.


Cheers & hth.,

- Alf
 
K

Keith H Duggar

* Keith H Duggar, on 28.06.2010 16:27:



I do not for a moment doubt that you understand that memory and storage is the
same thing in this context. Thus, your emphasis that indicates a contradiction,

It was a /generalization/ of your word choice not a contradiction.
Likewise, I have no doubt whatsoever that you understand that a region of memory
that satisfies certain properties, is a region of memory.

It was a /specialization/ of your word choice not a contradiction.
It served to connect your sentence to the section of the standard
that followed that spelled out the definition in greater detail.
Those
properties are with regard to lifetime, type, etc.
1.7 The C++ object model [intro.object]
1 The constructs in a C++ program create, destroy, refer to, access,
and
manipulate objects. An object is a region of storage.

Note that last sentence.

Note that is a /part of/ not the /whole of/ the definition. There
is more, and a very important more, to the C++ definition of object.
Thinking of it only as a region of storage can and very recently did

http://groups.google.com/group/comp.lang.c++/msg/3a3d3ce5a78f5432

lead to erroneous thinking. In fact, it was that thread, very fresh
in my mind, that prompted me to refine your statement by connecting
it to the complete definition in the standard.
is an attempt at misleading some non-programmer uninformed readers, unless
you're somewhere at the moron level, which I strongly doubt. So, it is a lie,
and it is a pretty stupid lie. I'm getting tired of your blatant dishonesty.

I hope the explanation above along with the crystal clear supporting
evidence makes it clear to you that my post was not personal attack
aimed at you as you seem to have taken it. It was simply a technical
/clarification/ motivated by a very recent misunderstanding in this
same group on nearly the same topic.

KHD
 
A

Alf P. Steinbach /Usenet

* Keith H Duggar, on 29.06.2010 07:03:
It was a /generalization/ of your word choice not a contradiction.

I'll choose to believe that you believed that. OK then, it's dumb but possible.
But then it's a case of thinking there is some subtlety intended, where the
standard intends no such: "storage" here means *exactly the same* as "memory".

"Storage" or "memory" in a context referring to memory just means one or more
sequences of contiguous bytes. The standard uses a mixture of the words
"storage" and "memory" in §1.7, where it defines this, talking about "storage
unit" (a byte), and elsewhere it mainly just uses "storage". Which is a bit
inconsistent, yeah. And formally undefined. But it's meant for common sense. I
guess the crucial insight is that the C++ standard is not a mathematical
document, it's a document that often employs words that just mean what you'd
think they mean, although on occasion some words have unusual defined meanings
(this is not the case with "storage", though, which is not specially defined).

In some other contexts such as when talking about "storage duration" the word
"storage" refers to the dynamic allocation of memory, not that the memory wears
out or something. E.g., you cannot meaningfully talk about "memory duration".
This is again a matter of the standard requiring common sense to be applied to
choose the appropriate meaning; for example, the standard's phrase "to allocate
storage" means to allocate memory, not to allocate a memory allocation.

Likewise, I have no doubt whatsoever that you understand that a region of memory
that satisfies certain properties, is a region of memory.

It was a /specialization/ of your word choice not a contradiction.
It served to connect your sentence to the section of the standard
that followed that spelled out the definition in greater detail.
Those
properties are with regard to lifetime, type, etc.
1.7 The C++ object model [intro.object]
1 The constructs in a C++ program create, destroy, refer to, access,
and
manipulate objects. An object is a region of storage.

Note that last sentence.

Note that is a /part of/ not the /whole of/ the definition. There
is more, and a very important more, to the C++ definition of object.
Thinking of it only as a region of storage can and very recently did

http://groups.google.com/group/comp.lang.c++/msg/3a3d3ce5a78f5432

lead to erroneous thinking. In fact, it was that thread, very fresh
in my mind, that prompted me to refine your statement by connecting
it to the complete definition in the standard.
is an attempt at misleading some non-programmer uninformed readers, unless
you're somewhere at the moron level, which I strongly doubt. So, it is a lie,
and it is a pretty stupid lie. I'm getting tired of your blatant dishonesty.

I hope the explanation above along with the crystal clear supporting
evidence makes it clear to you that my post was not personal attack
aimed at you as you seem to have taken it. It was simply a technical
/clarification/ motivated by a very recent misunderstanding in this
same group on nearly the same topic.

OK, sorry for blowing your hat off. As I wrote, I very strongly doubted that you
could fail to understand that "storage" and "memory" mean exactly the same in
this context (see above), and like you I was influenced by an earlier
discussion. I think, when a person bumps into me once, OK accident, and I just
say hey, watch where you're going; twice, in a short time, I think it's
intentional and give a good shove back; three times, I don't know, but one
possible reaction is a hopefully painful kick. Learning that the person has
reduced sight and was robbed of his cane and dog, nothing to show the problem,
one could then perhaps feel ashamed. But when something's the right thing to do
then it's the right thing to do no matter if it turns out wrong. I think.


Cheers & hth.,

- Alf
 
Ö

Öö Tiib

But when something's the right thing to do
then it's the right thing to do no matter if it turns out wrong. I think.

Yes, but defining that "object is a region of memory" is somewhat like
defining "elephant is an animal". Technically not wrong but can not be
taken as full definition in discussion of techniques of resetting an
object (or feeding an elephant)?

I am not sure why Keith emphasized difference between "storage" and
"memory location" however.
 
A

Alf P. Steinbach /Usenet

* Öö Tiib, on 29.06.2010 15:40:
Yes, but defining that "object is a region of memory" is somewhat like
defining "elephant is an animal". Technically not wrong but can not be
taken as full definition in discussion of techniques of resetting an
object (or feeding an elephant)?

True, but the context was just whether a raw array is an object in C++. It is.

I am not sure why Keith emphasized difference between "storage" and
"memory location" however.

Cheers,

- Alf
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Staff online

Members online

Forum statistics

Threads
473,776
Messages
2,569,603
Members
45,197
Latest member
ScottChare

Latest Threads

Top