Do objects have type?

B

Beta What

I am seeing lots of posts (and websites like Chris Torek's) that claim
that objects have type. They are wrong.

Objects have no type, so everyone please stop spreading misinformation.
Only values have types (both lvalues and rvalues), not objects.

Thanks
 
B

Ben Pfaff

Beta What said:
Objects have no type, so everyone please stop spreading misinformation.

From the standard:
1 object
region of data storage in the execution environment, the
contents of which can represent values
2 NOTE When referenced, an object may be interpreted as
having a particular type; see 6.3.2.1.
Most of the time, when we're talking about an object, we're
interested in its value as a particular type. I don't think it's
too misleading to refer to this as the type of the object.
 
L

Lawrence Kirby

I am seeing lots of posts (and websites like Chris Torek's) that claim
that objects have type. They are wrong.

If you provided an evidence to back up your rather curious claim we might
take you seriously.
Objects have no type, so everyone please stop spreading misinformation.
Only values have types (both lvalues and rvalues), not objects.

In C90 you might argue that, but how does it help? What problems will
ascribing a type to an object cause? In C99 6.5p6 objects are given the
property called an "effective type". This is a type and is a persistent
property i.e. relates to more than just lvalues in isolation. "Effective
type" in C99 makes explicit something that was implicit in C90 and
corrects a problem in C90 relating to malloc'd objects.

C doesn't define precedence and associativity rules but they are a useful
way to describe how the language works. The same is probably true for
talking about object types, unless you can demonstrate that this
misrepresents how the language behaves (i.e. would mispredict program
output).

Lawrence
 

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

Forum statistics

Threads
474,159
Messages
2,570,881
Members
47,418
Latest member
NoellaXku

Latest Threads

Top