C objects

J

junky_fellow

Keith Thompson said:
[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".

So, can we say a function pointer to be an object ?
 
J

Joe Wright

E. Robert Tisdale said:
A function is an object.
A pointer to that function is another object.

Pray tell where you find a function described as an object in C.
 
A

Arthur J. O'Dwyer

For the record: Functions are /not/ objects in C. However,
pointers are objects, be they pointers to functions or pointers
to data.

(It's been a while since the last blatant troll of Tisdale's,
so I expect we have a crop of newbies who might assume Tisdale
wasn't being maliciously wrong in his statements. FYI, he's a
well-known regular in c.l.c---please just ignore his ravings.)

-Arthur
 
E

E. Robert Tisdale

Something said:
Not according to the C standard according to what the more knowledgeable
people around here have said.

You are confused.
The C standards documents are *not*
part of the C computer programming language.
There is no 'object' keyword os standard identifier
in the C computer programming language.
The C standards documents have *nothing* to do with programming in C.
They exist *only* to specify the C computer programming language.
Terms, like object, given special meaning in the standards documents
to help with these specifications,
have *no* meaning outside of the scope of the standards documents
other that those meanings commonly used
in the context of a computer programming language.

Questions (remarks) about the C standards are off-topic in comp.lang.c
There is a more appropriate form for that -- comp.std.c

Please direct all your questions (remarks)
about the C standards documents to the appropriate newsgroup.
 
K

Keith Thompson

E. Robert Tisdale said:
I used Google

http://www.google.com/

to search for

+"functions are objects" +"C programming"

Did you actually look at the results, or did you just count the hits?
I just got 42 hits, and looked at most of the ones on the first page.
All the ones I checked are pages that state that functions are objects
in some language other than C, and also happen to have the phrase "C
programming".

There may well be some web page that claims that functions are objects
in C. If so, it proves nothing except that the author of the page is
mistaken.

Functions are not objects in C.
 
K

Keith Thompson

E. Robert Tisdale said:
You are confused.
The C standards documents are *not*
part of the C computer programming language.

The C standards documents define the C programming language.
There is no 'object' keyword os standard identifier
in the C computer programming language.

Nobody has claimed that there is. There is no "function", "array", or
"pointer" keyword or standard identifier in C; do you conclude from
that that C doesn't have functions, arrays, or pointers?
The C standards documents have *nothing* to do with programming in C.

Utter nonsense.
They exist *only* to specify the C computer programming language.

Yes, of course they specify the C programming language. That makes
them extremely relevant to programming in C (and, equally, to
implementing a C compiler and/or library).
Terms, like object, given special meaning in the standards documents
to help with these specifications,
have *no* meaning outside of the scope of the standards documents
other that those meanings commonly used
in the context of a computer programming language.

Utter nonsense.

Given a choice of using terms as defined by the C standard (as is the
nearly universal consensus of this newsgroup), or using terms as
defined by E. Robert Tisdale, it's not a difficult decision.
Questions (remarks) about the C standards are off-topic in comp.lang.c
There is a more appropriate form for that -- comp.std.c

comp.lang.c is for discussion of the C programming language, which is
defined by the C standards. comp.std.c is for discussion of the C
standards *as documents*. "What is an object?" would be an
appropriate question for comp.lang.c; the answer is found in the
standard. "The standard's definition of 'object' is ambiguous" would
be an appropriate topic for comp.std.c. (This is an example, and is
not meant to imply that I think the definition is actually ambiguous.)
Please direct all your questions (remarks)
about the C standards documents to the appropriate newsgroup.

Please stop lying to newbies. Those of us who have been here for a
while know enough not to take you seriously, but inexperienced
programmers might not.
 
C

CBFalconer

E. Robert Tisdale said:
Something that calls itself Flash Gordon wrote:>

You are confused.
The C standards documents are *not*
part of the C computer programming language.

You are getting objectionable again. The C language is defined by
the C standards documents, at least the only form of C discussed
here.
 
F

Flash Gordon

On Sun, 15 Aug 2004 04:15:33 GMT

Please stop lying to newbies. Those of us who have been here for a
while know enough not to take you seriously, but inexperienced
programmers might not.

I'm not actually a newbie, I just don't have a copy of the standard
myself and don't post very often so I left in that I was relying on what
I had read by those I respect :)

I slightly morphed the name a while back, but not enough to confuse
anyone who knows me (the domain name did not change). A few years
further back I changed domain but not the name I posted under.
 
C

CBFalconer

Flash said:
I'm not actually a newbie, I just don't have a copy of the standard
myself and don't post very often so I left in that I was relying on
what I had read by those I respect :)

He wasn't talking about you, but about ERT, whose foibles are well
known here.
 
F

Flash Gordon

He wasn't talking about you, but about ERT, whose foibles are well
known here.

I realised he was talking about ERT lying. My point was that in this
case ERTs drivel was not in response to a newbie but in response to
someone who ahs been around the block a couple of times.
 
K

Keith Thompson

Flash Gordon said:
On Sun, 15 Aug 2004 04:15:33 GMT



I'm not actually a newbie, I just don't have a copy of the standard
myself and don't post very often so I left in that I was relying on what
I had read by those I respect :)

I slightly morphed the name a while back, but not enough to confuse
anyone who knows me (the domain name did not change). A few years
further back I changed domain but not the name I posted under.

No offense intended. I wasn't referring specifically to you; I hadn't
even noticed that you wrote the article to which ERT was responding.
In effect, everything posted to a newsgroup is addressed to everyone
reading it.
 
D

Default User

CBFalconer said:
You are getting objectionable again. The C language is defined by
the C standards documents, at least the only form of C discussed
here.


What is it about Trollsdale? It seems he can go only so long before
exploding into a bullshit spew all over the newsgroup.




Brian Rodenborn
 
J

junky_fellow

Keith Thompson said:
Yes. (BTW, please trim any quoted text that's not relevant to your
question.)

Actually, i have some confusion related to null pointer and function
pointer
and C objects.
suppose, i have a function pointer "fptr" , which is pointing to some
funtion that lie at address 0x0.

i have one more pointer "nptr" which is a null pointer.
(NOTE: Assume that machine that i am using use all-bits-zero as null
pointer)
Also, 0x0 is a valid logical address in the address space of my
application.

+-------+
| fptr |------------------+-> +-------------+ 0x00 ( start address of
function)
+-------+ | | |
function pointer | | |
| | |
| . .
| . .
+-------+ | . .
| nptr |------------------+ . .
+-------+ | |
+-------------+
RAM

1) Now, can i say that my function pointer "fptr" is pointing to some
valid C object ?

2) if i compare my null pointer "nptr" with function pointer "fptr"
(for equality ) will they compare equal ?

3) If they compare equal, and fptr is pointing to some valid object,
that means a null pointer may compare equal to some valid object in C.
But, i had in my
mind that null pointer shouldn't compare equal to any valid C object.

i would be highly grateful, if you all expert don't use highly
technical
terms to explain the doubts. otherwise a newbie get entangled in those
terms
and gets more confused.
 

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

Members online

No members online now.

Forum statistics

Threads
474,146
Messages
2,570,832
Members
47,374
Latest member
anuragag27

Latest Threads

Top