Re: C objects

From: Keith Thompson (kst-u_at_mib.org)
Date: 08/13/04


Date: Thu, 12 Aug 2004 23:57:45 GMT


"E. Robert Tisdale" <E.Robert.Tisdale@jpl.nasa.gov> writes:
> Keith Thompson wrote:
> > E. Robert Tisdale writes:
> >> The type defines
> >> *all* of the values that an object of that type may have
> >> so an object *must* be initialized to one of those values
> >> if it is to be called an object of that type.
> >
> > Perhaps, but it doesn't have to be initialized to be called an object.
> > An object is a "region of data storage in the execution environment,
> > the contents of which can represent values" (C99 3.14).
> >
> > And, of course, the term "object" as used in C
> > has nothing at all to do with object-oriented programming.
>
[Humpty Dumpty quotation deleted'
>
> What do you think the term 'object" means
> in the phrase 'object-oriented programming'?

I don't have a good answer to that. All I can say (and all I care to
say) is that the usual meaning of "object" in the context of
object-oriented programming is different from the definition in the C
standard (C99 3.14):

    region of data storage in the execution environment, the contents
    of which can represent values

    NOTE When referenced, an object may be interpreted as having a
    particular type; see 6.3.2.1.

(The note is not part of the definition.)

The C90 definition is more verbose (C90 3.14), but it expresses the
same basic idea:

    A region of data storage in the execution environment, the
    contents of which can represent values. Except for
    bit-fields, objects are composed of contiguous sequences of one or
    more bytes, the number, order, and encoding of which are either
    explicitly specified or implementation-defined. When referenced,
    an object may be interpreted as having a particular type, see
    6.2.2

(That may not be an exact quote; my copy of the C90 standard makes
cut-and-paste difficult.)

> Are you saying that it is not possible
> to write object-oriented programs in C?

No, I'm not saying that, nor have I ever said anything resembling it.
Why do you ask?

> Why not say 'region of data storage' instead of object
> if that is all that is meant by object?
>
> What I am saying is that the English language is badly abused
> in the standards documents.
> It converts ordinary English words into meaningless jargon.
> These redefinitions narrow the meaning of these words
> to the point where it is impossible to make valid inferences
> and require the redefinition of other common terms.

No, it converts ordinary English words into meaningful jargon. Any
field of discourse has its own jargon, consisting of ordinary words
with specific definitions, phrases, and, in some cases, invented
words. (The word "object" in everyday English has a meaning that's
not particularly useful in the context of programming languages, for
example.)

If you're going to discuss C, as you insist on doing, you have to
understand the way the C standard defines certain terms. If you're
going to use terms defined in the C standard in ways inconsistent with
their definitions, you're going to have difficulties communicating in
this newsgroup (as you've already discovered).

> For example, your redefinition of object appears to require
> the redefinition of the term type
> to include *all* of the values that could be represented
> by the "region of storage" that you call a type.

It's not *my* redefinition, it's in the C standard. Apart from that,
I'm not sure what you mean.

> This, in turn, seems to imply that the type depends
> upon the representation that the programmer chooses
> and that data abstraction is impossible in C.

Nonsense.

> Take for example
>
> struct X {
> int* p;
> };
>
> struct X x;
>
> Does the object referenced through x include
> the region of data pointer to by p?

Given the C standard's definition of "object", the object named x
includes the storage for x.p, but it doesn't include the region of
data pointed to by x.p. If you want to refer to both x and the data
pointed to by x.p as a single entity, you should choose a name other
than "object"; I suggest "data structure".

-- 
Keith Thompson (The_Other_Keith) kst-u@mib.org  <http://www.ghoti.net/~kst>
San Diego Supercomputer Center             <*>  <http://users.sdsc.edu/~kst>
We must do something.  This is something.  Therefore, we must do this.


Relevant Pages

  • Re: The annotated annotated annotated C standard part 2
    ... A nice sounding statement, but totally meaningless. ... the body of a function is a compound ... Of course, the C Standard uses "block" to mean exactly the same thing as "compound statement", so Schildt's statement makes even less sense if I take your interpretation. ... Algol meaning, a profoundly important meaning which acknowledges the ...
    (comp.programming)
  • Re: function return pointer of int?
    ... The standard uses "value" to mean different things in ... the meaning is always as defined. ... It produces a value of pointer type. ... then it may be a trap representation, which is not a value of pointer ...
    (comp.lang.c)
  • Re: detabbing again
    ... The standard exists independent of any observer, ... (again in my opinion) ... meaning of some previous statements. ...
    (comp.lang.c)
  • Re: Malcolms new book
    ... Note that strlenis a "pure function". ... Different programming languages use different terms ... line may use the same word but with a different meaning. ... The Standard does not define it; ...
    (comp.lang.c)
  • Re: Judaism, evolution, and science in general
    ... >We can easily quibble over the meaning of 'race', ... (As measured by the standard IQ test, ... and white test-takers scores average a full standard ... Note that he doesn't claim it for every Jew, ...
    (soc.culture.jewish.moderated)

Loading