473,387 Members | 1,495 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

difference

what is the difference between objects and pointers?
Nov 14 '05
59 3495
Joe Wright wrote:
Is a + b an object?


Another way of looking at it, is that a + b isn't an identifier.
If you don't have an identifier and you don't have an address,
then what object would you be talking about?

I only know three ways to create objects in a program.
1 Declared variables are objects.
2 String literals refer to anonymous objects,
when the string literals aren't array initializers.
3 A non NULL return value from malloc or friends, is
a pointer to an anonymous object.

--
pete
Nov 14 '05 #51
E. Robert Tisdale wrote:
For the definition of the term object,
you should consult an English language dictionary:


Only if you're not discussing C.
Using a Standard English dictionary to get the defintition of words,
which are technical terms, defined in the C standard, is ...

WHAT THE HELL IS WRONG WITH YOU ?!!!

--
pete
Nov 14 '05 #52
Hallvard B Furuseth wrote:

Joe Wright wrote:
Hallvard B Furuseth wrote:
I think integer constants are objects, and that what this text refers
to is lvalues like *p where p points to freed memory. That freed
memory is no longer an object.

From K&R2 A4 p195
"An object, sometimes called a variable, is a location in storage, and
its interpretation depends on two main attributes: its 'storage class'
and its 'type'."..

That doesn't sound like a constant to me. I must have missed something
important earlier.


What you missed is that C is defined by the C standard, not by K&R2.
The sentence you quoted illustrates why: It is wrong. It says that all
objects are variables. So malloced memory, which is not a variable, is
not an object.
Give me an example of an integer constant that you
think is an object. Please.


1

Not the way I read it. That the constant 1 has object type (int) does
not make it an object. Its object type describes the object which might
hold the value if you wanted to store it somewhere or the
promotion/conversion rules to apply if you want to do arithmetic with
it. It is not a object.
--
Joe Wright http://www.jw-wright.com
"Everything should be made as simple as possible, but not simpler."
--- Albert Einstein ---
Nov 14 '05 #53
pete wrote:

Joe Wright wrote:
Is a + b an object?


Another way of looking at it, is that a + b isn't an identifier.
If you don't have an identifier and you don't have an address,
then what object would you be talking about?

I only know three ways to create objects in a program.
1 Declared variables are objects.
2 String literals refer to anonymous objects,
when the string literals aren't array initializers.
3 A non NULL return value from malloc or friends, is
a pointer to an anonymous object.

Thanks pete. It seems you are on the side of reason (my side). There is
some wording in the standard about constants having object type. They
do. I fear this is being construed to mean that constants are objects.
They are not!
--
Joe Wright http://www.jw-wright.com
"Everything should be made as simple as possible, but not simpler."
--- Albert Einstein ---
Nov 14 '05 #54
"E. Robert Tisdale" <E.**************@jpl.nasa.gov> wrote:
pete wrote:
Joe Wright wrote:
> c = a + b;

Is a + b an object?


Yes.


No. RTBS.

Richard
Nov 14 '05 #55
"E. Robert Tisdale" <E.**************@jpl.nasa.gov> wrote:
Joe Wright wrote:
That doesn't sound like a constant to me.
I must have missed something important earlier.
Give me an example of an integer constant that you think is an object.


For the definition of the term object,
you should consult an English language dictionary:

http://www.bartleby.com/61/


Of course. And integers must be able to split in the middle to produce
smaller integers, and two long doubles should have sex together,
resulting in a cute little float nine nano-months later. Because, after
all, that is the dictionary meaning of "multiplication".

Richard
Nov 14 '05 #56
Joe Wright wrote:

pete wrote:

Joe Wright wrote:
Is a + b an object?
Another way of looking at it, is that a + b isn't an identifier.
If you don't have an identifier and you don't have an address,
then what object would you be talking about?

I only know three ways to create objects in a program.
1 Declared variables are objects.
2 String literals refer to anonymous objects,
when the string literals aren't array initializers.
3 A non NULL return value from malloc or friends, is
a pointer to an anonymous object.

Thanks pete. It seems you are on the side of reason (my side).
There is some wording in the standard about
constants having object type. They do.


They do.
I fear this is being construed to mean that constants are objects.
They are not!


They are not.

Here's that in a nutshell:
N869 6.3.2 Other operands
6.3.2.1 Lvalues and function designators
[#1] An lvalue is an expression with an object type or an
incomplete type other than void; if an lvalue does not
designate an object when it is evaluated, the behavior is
undefined.

(5) is is an expression with an object type
or an incomplete type other than void.

x = (5);

If (5) does not designate an object when it is evaluated,
the behavior is undefined.

From previous discussion on comp.std.c,
I've been informed that what they meant by
"if an lvalue does not designate an object when it is evaluated"
was, an invalidly dereferenced pointer.

char object;
char* pointer;

pointer = &object;
*(pointer + 17) = 0;

The left operand of the last above assignment,
is an example of what they meant by
"an lvalue does not designate an object when it is evaluated".

--
pete
Nov 14 '05 #57
Joe Wright wrote:
pete wrote:
Joe Wright wrote:
Is a + b an object?
Another way of looking at it, is that a + b isn't an identifier.
What of it?
If you don't have an identifier and you don't have an address,
then what object would you be talking about?


An unnamed object, of course. Or what is sometimes called a temporary
variable, depending on who you are speaking to.
There is
some wording in the standard about constants having object type. They
do. I fear this is being construed to mean that constants are objects.


Not by me. I've simply assuming that the text from the standard which
Pete claimed is in error in message <40***********@mindspring.com>, is
in fact not on error. The rest follows.

It fits how I think of program execution, anyway. A (sub)expression is
evaluated. The result is a (temporary) object. That object may be
stuffed into a variable by an assignment operator, or whatever. And
the compiler may optimize away the temporary object.

Though I think I should have said that constants, when evaluated,
_become_ objects. I do agree that this does become murky one way or
another. Now that I think of it, it doesn't fit static initializers.
Then only the initialized element is an object.

--
Hallvard
Nov 14 '05 #58
pete wrote:
N869 6.3.2 Other operands
6.3.2.1 Lvalues and function designators
[#1] An lvalue is an expression with an object type or an
incomplete type other than void; if an lvalue does not
designate an object when it is evaluated, the behavior is
undefined.

(5) is is an expression with an object type
or an incomplete type other than void.

x = (5);

If (5) does not designate an object when it is evaluated,
the behavior is undefined.

From previous discussion on comp.std.c,
I've been informed that what they meant by
"if an lvalue does not designate an object when it is evaluated"
was, an invalidly dereferenced pointer.


Yes, that's what I thought.

--
Hallvard
Nov 14 '05 #59
Hallvard B Furuseth wrote:

Joe Wright wrote:
pete wrote:
Joe Wright wrote:

Is a + b an object?

Another way of looking at it, is that a + b isn't an identifier.
What of it?
If you don't have an identifier and you don't have an address,
then what object would you be talking about?

An unnamed object, of course.


That's not what an unnamed object is.
An unnamed object has an address.
All objects have either an address or an identifier or both.
a + b has neither.
Or what is sometimes called a temporary
variable, depending on who you are speaking to.


Unnamed objects have specified duration and representation
described by the standard.
Temporary variables are not described by the standard
and have nothing to do with C.

For
c = a + b;
the standard doesn't say that the value of a + b will be stored
anywhere else, except in c.

--
pete
Nov 14 '05 #60

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

Similar topics

34
by: yensao | last post by:
Hi, I have a hard time to understand difference and similarities between Relational database model and the Object-Oriented model. Can somebody help me with this? Thank you in advance. ...
21
by: b83503104 | last post by:
Hi, Can someone tell me the difference between single quote and double quote? Thanks
26
by: Frank | last post by:
For my website i would like to display the age of my son in years, months, days and hours. For now i manage to get a result for totals. Like the total number of days. This is the beginning: ...
21
by: Rich | last post by:
I was considering C# for developing a scientific application, but I have noticed a ~30% difference between VC++ .NET and C# on the same machine, under identical conditions: double a = 0,b = 0, c...
4
by: jamesyreid | last post by:
Hi, I'm really sorry to post this as I know it must have been asked countless times before, but I can't find an answer anywhere. Does anyone have a snippet of JavaScript code I could borrow...
3
by: bbawa1 | last post by:
Hi, I have a table which has a field ItemsReceived of type datetime. I have a grid view which has two columns. In first column i have to show the data from field ItemsReceived and in second...
12
by: Petronius | last post by:
Hallo, does anyone have an idea how to implement difference lists in Javascript? Thanks allot in advance
5
by: Julius | last post by:
Hej dudes, I need to calc the difference between two timestamps / dates ... For example what i need to calculate: Date 1: 2007.11.06 - 20:13:04 Date 2: 2007.11.07 - 21:13:04 Difference:...
9
by: viki1967 | last post by:
Hi all! This new forum its great! :) Congratulations !!! My answer: why this my code not working? Nothing error but not work the difference.... : <html>
11
by: cmb3587 | last post by:
I have two arrays and I'm trying to create a 3rd array that is the difference between the two arrays Ex: arrayA: 3 5 8 9 arrayB: 3 4 6 9 difference of A-B: 5 8 however, my...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
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...

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.