473,734 Members | 2,647 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

C objects

What is a C object ?

If i have some function "func()" in my C program, then
can i say that "func()" is a C object ?
or if i have some function pointer (ptr) which contains the address
of function "func()", can i say that ptr is pointing to some C object ?

Is a C object always associated with some "data" ?

thanx in advance for any help .....
Nov 14 '05
115 4904
E. Robert Tisdale wrote:
struct X {
int* p;
};

struct X x;

Does the object referenced through x include
the region of data pointer to by p?


No.
x is an object of type struct X.
(sizeof x) is not affected by what x.p points to.
Objects are blocks of contiguous memory.
It's explicitly stated in the C89 object definition.

C89 Last public draft
1.6 DEFINITIONS OF TERMS
* Object --- 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.

A list is not an object.

--
pete
Nov 14 '05 #51
Keith Thompson <ks***@mib.or g> wrote in message news:<ln******* *****@nuthaus.m ib.org>...
"E. Robert Tisdale" <E.************ **@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".


So, can we say a function pointer to be an object ?
Nov 14 '05 #52
"junky_fell ow" <ju**********@y ahoo.co.in> wrote in message
news:8c******** *************** ***@posting.goo gle.com...
So, can we say a function pointer to be an object ?


Not in English.
Nov 14 '05 #53
ju**********@ya hoo.co.in (junky_fellow) writes:
[...]
So, can we say a function pointer to be an object ?


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

--
Keith Thompson (The_Other_Keit h) ks***@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.
Nov 14 '05 #54
junky_fellow wrote:
So, can we say a function pointer to be an object?


A function is an object.
A pointer to that function is another object.
Nov 14 '05 #55
E. Robert Tisdale wrote:
junky_fellow wrote:
So, can we say a function pointer to be an object?

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.
--
Joe Wright mailto:jo****** **@comcast.net
"Everything should be made as simple as possible, but not simpler."
--- Albert Einstein ---
Nov 14 '05 #56
Joe Wright wrote:
E. Robert Tisdale wrote:
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.


I used Google

http://www.google.com/

to search for

+"functions are objects" +"C programming"
Nov 14 '05 #57

On Sat, 14 Aug 2004, E. Robert Tisdale wrote:
E. Robert Tisdale wrote:
A function is an object.
A pointer to that function is another object.


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
Nov 14 '05 #58
On Sat, 14 Aug 2004 13:48:19 -0700
"E. Robert Tisdale" <E.************ **@jpl.nasa.gov > wrote:
junky_fellow wrote:
So, can we say a function pointer to be an object?
A function is an object.


Not according to the C standard according to what the more knowledgeable
people around here have said.
A pointer to that function is another object.


Yes, a pointer to a function is an object.
--
Flash Gordon
Sometimes I think shooting would be far too good for some people.
Although my email address says spam, it is real and I read it.
Nov 14 '05 #59
Something that calls itself Flash Gordon wrote:
E. Robert Tisdale wrote:
A function is an object.


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.
Nov 14 '05 #60

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
8252
by: dasod | last post by:
I would like to know if my method to remove list objects is correct in this small test program. It seems to me that there might be a simplier way, but I'm afraid I don't know enough about list iterators and how they are behaving in situations like this. #include <iostream> #include <list> class Test; typedef std::list< Test* > Tlist;
9
1888
by: Aguilar, James | last post by:
Hey guys. A new question: I want to use an STL libarary to hold a bunch of objects I create. Actually, it will hold references to the objects, but that's beside the point, for the most part. Here's the question: I want to be able to change the references (including deleting them). Is there any way to do that besides using pointers rather than references for the STL library? I'd also prefer to avoid using const_cast, if it is indeed...
6
2576
by: Alfonso Morra | last post by:
I have written the following code, to test the concept of storing objects in a vector. I encounter two run time errors: 1). myClass gets destructed when pushed onto the vector 2). Prog throws a "SEGV" when run (presumably - attempt to delete deleted memory. Please take a look and see if you can notice any mistakes I'm making. Basically, I want to store classes of my objects in a vector. I also have three further questions:
3
3029
by: ytrewq | last post by:
Should dynamic ("expando") properties be restricted to native and user-defined objects? Or should host objects - such as references to the browser or a plug-in or to the document and its elements - also allow them? Adding (and removing) object properties dynamically is an acceptable and common practice in JavaScript, and greatly adds to the power and character of the language. Essentially, an object in JavaScript can be considered to...
8
1862
by: Lüpher Cypher | last post by:
Hi, Suppose we have a hierarchical class structure that looks something like this: Object | +-- Main | +-- Object1
161
7851
by: KraftDiner | last post by:
I was under the assumption that everything in python was a refrence... so if I code this: lst = for i in lst: if i==2: i = 4 print lst I though the contents of lst would be modified.. (After reading that
7
8222
by: Jo | last post by:
Hi, How can i differentiate between static and dynamic allocated objects? For example: void SomeFunction1() { CObject *objectp = new CObject; CObject object;
21
2210
by: George Exarchakos | last post by:
Hi everyone, I'd like your help... Can we have a std::list<BASEwhere BASE be the base class of a class hierarchy? I want to add to this list objects that are inherited from BASE class but not necessarily the same... class base { int x;
27
2561
by: SasQ | last post by:
Hello. I wonder if literal constants are objects, or they're only "naked" values not contained in any object? I have read that literal constants may not to be allocated by the compiler. If the Standard is saying that "object is a region of storage", I deduce from that that literal constants aren't objects because they may not be alocated as regions of storage in the memory.
14
6022
by: Jess | last post by:
Hello, I learned that there are five kinds of static objects, namely 1. global objects 2. object defined in namespace scope 3. object declared static instead classes 4. objects declared static inside functions (i.e. local static objects) 5. objects declared at file scope.
0
8946
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9310
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9236
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9182
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
6735
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4809
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3261
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2724
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2180
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.