Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C++ > Re: The C++ type system

Reply
Thread Tools

Re: The C++ type system

 
 
James Kanze
Guest
Posts: n/a
 
      01-09-2011
On Jan 9, 10:43 pm, "Alf P. Steinbach /Usenet" <alf.p.steinbach
(E-Mail Removed)> wrote:

> Now, just checking the standard I didn't find the wording that
> I remember, but I found this little gem:


> 3.4.5/7 ... "the class pointed to by the pointer expression"


> Clearly some intelligence is needed in order to understand that.


I presume that the authors of the standard got tired of
inserting the word type everywhere where it was obvious.
Formally, that should doubtlessly be "the object of class type
pointed to by the expression of pointer type". Which is, IMHO,
a bit verbose. But if you think that the standard is too short
and too succinct, you can ask Pete to change it (and everywhere
else such shortcuts in wording occur).

--
James Kanze
 
Reply With Quote
 
 
 
 
James Kanze
Guest
Posts: n/a
 
      01-10-2011
On Jan 9, 9:16 pm, Keith Thompson <(E-Mail Removed)> wrote:
> Leigh Johnston <(E-Mail Removed)> writes:


> [...]
>
> There's some genuine confusion on this point, and it's fairly easy to
> avoid.


> The unqualified word "pointer" is ambiguous. It can refer, in
> different contexts, to a pointer object, to a pointer value, or to
> a pointer type. (The C standard, for example, says that malloc()
> returns a pointer, meaning a pointer value; I'm not sure whether
> the C++ standard does something similar.)


Well, not about malloc. (All it says about malloc is see the C
standard.) But in general, if the context is clear (and it
usually is to anyone who understands the difference between
objects, values, expressions and types), the C++ standard does
say things like "pointer expression", rather than "expression
with pointer type".

> Usually the meaning is sufficiently clear from the context,
> but sometimes it's best to avoid using the word "pointer",
> instead referring explicitly to a pointer object, a pointer
> value, or a pointer type.


The same thing holds for a lot of other things, and not just in
the standard. If the program contains "int a;", we'll often say
that a is an int, when what we really mean is that a is an
object of type int. At some point, it just gets tiresome
constantly repeating phrases like "object of type", and the
meaning is perfectly clear to anyone who isn't a complete idiot.

--
James Kanze
 
Reply With Quote
 
 
 
 
Keith Thompson
Guest
Posts: n/a
 
      01-10-2011
James Kanze <(E-Mail Removed)> writes:
> On Jan 9, 9:16 pm, Keith Thompson <(E-Mail Removed)> wrote:
>> Leigh Johnston <(E-Mail Removed)> writes:

>
>> [...]
>>
>> There's some genuine confusion on this point, and it's fairly easy to
>> avoid.

>
>> The unqualified word "pointer" is ambiguous. It can refer, in
>> different contexts, to a pointer object, to a pointer value, or to
>> a pointer type. (The C standard, for example, says that malloc()
>> returns a pointer, meaning a pointer value; I'm not sure whether
>> the C++ standard does something similar.)

>
> Well, not about malloc. (All it says about malloc is see the C
> standard.) But in general, if the context is clear (and it
> usually is to anyone who understands the difference between
> objects, values, expressions and types), the C++ standard does
> say things like "pointer expression", rather than "expression
> with pointer type".


That's not quite the same thing. In "pointer expression", the word
"pointer" qualifies the word "expression", and it's clear that a
pointer expression is an expression with pointer type (I should have
mentioned expressions in addition to objects, values, and types).
I was talking about the unadorned word "pointer".

For example (I just checked this), the C++ standard says a
new-expression "returns a pointer to the object created".

>> Usually the meaning is sufficiently clear from the context,
>> but sometimes it's best to avoid using the word "pointer",
>> instead referring explicitly to a pointer object, a pointer
>> value, or a pointer type.

>
> The same thing holds for a lot of other things, and not just in
> the standard. If the program contains "int a;", we'll often say
> that a is an int, when what we really mean is that a is an
> object of type int. At some point, it just gets tiresome
> constantly repeating phrases like "object of type", and the
> meaning is perfectly clear to anyone who isn't a complete idiot.


Agreed, mostly.

On the other hand, it's been argued by some that "a pointer" can
only be a pointer object, not a pointer value. Both the C and
C++ standards at least sometimes refer to a pointer value just as
"a pointer". (They do so in a context where there's little risk
of ambiguity.)

--
Keith Thompson (The_Other_Keith) http://www.velocityreviews.com/forums/(E-Mail Removed) <http://www.ghoti.net/~kst>
Nokia
"We must do something. This is something. Therefore, we must do this."
-- Antony Jay and Jonathan Lynn, "Yes Minister"
 
Reply With Quote
 
Keith Thompson
Guest
Posts: n/a
 
      01-10-2011
James Kanze <(E-Mail Removed)> writes:
> On Jan 9, 10:43 pm, "Alf P. Steinbach /Usenet" <alf.p.steinbach
> (E-Mail Removed)> wrote:
>
>> Now, just checking the standard I didn't find the wording that
>> I remember, but I found this little gem:

>
>> 3.4.5/7 ... "the class pointed to by the pointer expression"

>
>> Clearly some intelligence is needed in order to understand that.

>
> I presume that the authors of the standard got tired of
> inserting the word type everywhere where it was obvious.
> Formally, that should doubtlessly be "the object of class type
> pointed to by the expression of pointer type". Which is, IMHO,
> a bit verbose. But if you think that the standard is too short
> and too succinct, you can ask Pete to change it (and everywhere
> else such shortcuts in wording occur).


No, if you look at the context I think it means "the type of the
object of class type pointed to by the expression of pointer type".

I'd say it's a reasonable verbal shorthand, and I wouldn't
necessarily recommend changing it.

--
Keith Thompson (The_Other_Keith) (E-Mail Removed) <http://www.ghoti.net/~kst>
Nokia
"We must do something. This is something. Therefore, we must do this."
-- Antony Jay and Jonathan Lynn, "Yes Minister"
 
Reply With Quote
 
James Kanze
Guest
Posts: n/a
 
      01-11-2011
On Jan 10, 6:19 pm, Keith Thompson <(E-Mail Removed)> wrote:
> James Kanze <(E-Mail Removed)> writes:
> > On Jan 9, 10:43 pm, "Alf P. Steinbach /Usenet" <alf.p.steinbach
> > (E-Mail Removed)> wrote:


> >> Now, just checking the standard I didn't find the wording that
> >> I remember, but I found this little gem:


> >> 3.4.5/7 ... "the class pointed to by the pointer expression"


> >> Clearly some intelligence is needed in order to understand that.


> > I presume that the authors of the standard got tired of
> > inserting the word type everywhere where it was obvious.
> > Formally, that should doubtlessly be "the object of class type
> > pointed to by the expression of pointer type". Which is, IMHO,
> > a bit verbose. But if you think that the standard is too short
> > and too succinct, you can ask Pete to change it (and everywhere
> > else such shortcuts in wording occur).


> No, if you look at the context I think it means "the type of the
> object of class type pointed to by the expression of pointer type".


Maybe. I didn't look it up in context. All I was concerned
with was giving some idea as to how verbose the results could
end up.

> I'd say it's a reasonable verbal shorthand, and I wouldn't
> necessarily recommend changing it.


My last sentence was meant to be ironic. I can't imagine anyone
really thinking that the standard is too short and to succinct,
and I definitely don't want this sort of change to take place.

--
James Kanze
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Unable to cast object of type 'System.Byte[]' to type 'System.String'. Imran Aziz ASP .Net 4 01-19-2011 03:39 AM
Unable to cast object of type 'System.Security.Principal.GenericIdentity' to type 'System.Web.Security.FormsIdentity'. adupuis@dublin.ie ASP .Net 2 08-31-2007 12:51 PM
Unable to cast object of type 'System.Web.UI.WebControls.SqlDataSource' to type 'System.Collections.IEnumerable'. Chris ASP .Net 1 02-12-2007 04:42 PM
Unable to cast object of type 'System.Web.Compilation.BuildResultCompiledAssembly' to type 'System.Web.Util.ITypedWebObjectFactory'. jlecain@free.fr ASP .Net 0 08-03-2006 06:00 PM
Help: Unable to cast object of type 'System.Int32' to type 'System.String'. keithb ASP .Net 3 05-07-2006 08:06 AM



Advertisments