Topic: Compound types as functions in latest C++ standard


Author: Edward Diener <eldiener@tropicsoft.invalid>
Date: Sun, 1 May 2011 12:52:47 CST
Raw View
In the latest C++ standard document (n3290) in section 3.9.2 part 1,
where it mentions the ways in which compound types can be constructed
I read:

"    functions, which have parameters of given types and return void or
references or objects of a given type, 8.3.5;"

Should not this say "... return void or references or pointers or
objects of a given type, 8.3.5;", or better yet just say "... return
void or given types, 8.3.5;".


--
[ comp.std.c++ is moderated.  To submit articles, try posting with your ]
[ newsreader.  If that fails, use mailto:std-cpp-submit@vandevoorde.com ]
[              --- Please see the FAQ before posting. ---               ]
[ FAQ: http://www.comeaucomputing.com/csc/faq.html                      ]





Author: Francis Glassborow<francis.glassborow@btinternet.com>
Date: Mon, 2 May 2011 13:10:19 CST
Raw View
On 01/05/2011 19:52, Edward Diener wrote:
>
>  In the latest C++ standard document (n3290) in section 3.9.2 part 1,
>  where it mentions the ways in which compound types can be constructed
>  I read:
>
>  "    functions, which have parameters of given types and return void or
>  references or objects of a given type, 8.3.5;"
>
>  Should not this say "... return void or references or pointers or
>  objects of a given type, 8.3.5;", or better yet just say "... return
>  void or given types, 8.3.5;".
>
>
Strictly speaking a pointer is an object. References are not objects. A
function does not and cannot return a type. So the wording is correct as
it stands.


--
[ comp.std.c++ is moderated.  To submit articles, try posting with your ]
[ newsreader.  If that fails, use mailto:std-cpp-submit@vandevoorde.com ]
[              --- Please see the FAQ before posting. ---               ]
[ FAQ: http://www.comeaucomputing.com/csc/faq.html                      ]





Author: =?windows-1252?Q?Daniel_Kr=FCgler?=<daniel.kruegler@googlemail.com>
Date: Mon, 2 May 2011 13:10:48 CST
Raw View
On 2011-05-01 20:52, Edward Diener wrote:
>
>  In the latest C++ standard document (n3290) in section 3.9.2 part 1,
>  where it mentions the ways in which compound types can be constructed
>  I read:
>
>  "    functions, which have parameters of given types and return void or
>  references or objects of a given type, 8.3.5;"
>
>  Should not this say "... return void or references or pointers or
>  objects of a given type, 8.3.5;", or better yet just say "... return
>  void or given types, 8.3.5;".

To me the current wording looks more correct than your first suggestion,
because pointers are also objects (but references are not). I don't see
much of a win to make this shorter my your second (and your preferred)
rewording. What do you consider as defective with the current state?

HTH&  Greetings from Bremen,

Daniel Kr   gler


--
[ comp.std.c++ is moderated.  To submit articles, try posting with your ]
[ newsreader.  If that fails, use mailto:std-cpp-submit@vandevoorde.com ]
[              --- Please see the FAQ before posting. ---               ]
[ FAQ: http://www.comeaucomputing.com/csc/faq.html                      ]





Author: Johannes Schaub<schaub.johannes@googlemail.com>
Date: Mon, 2 May 2011 13:11:29 CST
Raw View
Edward Diener wrote:

>
>  In the latest C++ standard document (n3290) in section 3.9.2 part 1,
>  where it mentions the ways in which compound types can be constructed
>  I read:
>
>  "    functions, which have parameters of given types and return void or
>  references or objects of a given type, 8.3.5;"
>
>  Should not this say "... return void or references or pointers or
>  objects of a given type, 8.3.5;", or better yet just say "... return
>  void or given types, 8.3.5;".
>

It's worded so that it sounds natural, but it's really about types, not
about values. Pointer types are object types, so the bullet as it stands is
fine: Functions can return void types, reference types and object types.

Of course, a function like "int f() { return 0; }" doesn't return an object.
But it returns a value of object type.


--
[ comp.std.c++ is moderated.  To submit articles, try posting with your ]
[ newsreader.  If that fails, use mailto:std-cpp-submit@vandevoorde.com ]
[              --- Please see the FAQ before posting. ---               ]
[ FAQ: http://www.comeaucomputing.com/csc/faq.html                      ]





Author: Francis Glassborow <francis.glassborow@btinternet.com>
Date: Mon, 2 May 2011 16:59:07 CST
Raw View
On 02/05/2011 20:11, Johannes Schaub wrote:

>
> Edward Diener wrote:
>
>
>>  In the latest C++ standard document (n3290) in section 3.9.2 part 1,
>>  where it mentions the ways in which compound types can be constructed
>>  I read:
>>
>>  "=97 functions, which have parameters of given types and return void or
>>  references or objects of a given type, 8.3.5;"
>>
>>  Should not this say "... return void or references or pointers or
>>  objects of a given type, 8.3.5;", or better yet just say "... return
>>  void or given types, 8.3.5;".
>>
>>
> It's worded so that it sounds natural, but it's really about types, not
> about values. Pointer types are object types, so the bullet as it stands =
is
> fine: Functions can return void types, reference types and object types.
>
> Of course, a function like "int f() { return 0; }" doesn't return an
> object.
> But it returns a value of object type.
>
>
> No, a function cannot return a type. Do not confuse the thing returned wi=
th
the type of the thing returned.


--
[ comp.std.c++ is moderated.  To submit articles, try posting with your ]
[ newsreader.  If that fails, use mailto:std-cpp-submit@vandevoorde.com ]
[              --- Please see the FAQ before posting. ---               ]
[ FAQ: http://www.comeaucomputing.com/csc/faq.html                      ]





Author: Edward Diener <eldiener@tropicsoft.invalid>
Date: Tue, 3 May 2011 19:32:00 CST
Raw View
On 5/2/2011 3:10 PM, Francis Glassborow wrote:

>
> On 01/05/2011 19:52, Edward Diener wrote:
>
>>
>> In the latest C++ standard document (n3290) in section 3.9.2 part 1,
>> where it mentions the ways in which compound types can be constructed
>> I read:
>>
>> "=97 functions, which have parameters of given types and return void or
>> references or objects of a given type, 8.3.5;"
>>
>> Should not this say "... return void or references or pointers or
>> objects of a given type, 8.3.5;", or better yet just say "... return
>> void or given types, 8.3.5;".
>>
>>
>> Strictly speaking a pointer is an object. References are not objects. A
> function does not and cannot return a type. So the wording is correct as
> it stands.
>

I did not realize that "a pointer is an object" in C++ standards
terminology. In that case the original wording is perfectly correct.

I do think it is natural to have assumed that "an object" meant something
different. One often refers to "pointers to objects" or "references to
objects" to distinguish objects themselves from the pointer or reference wa=
y
of specifying an object.


--
[ comp.std.c++ is moderated.  To submit articles, try posting with your ]
[ newsreader.  If that fails, use mailto:std-cpp-submit@vandevoorde.com ]
[              --- Please see the FAQ before posting. ---               ]
[ FAQ: http://www.comeaucomputing.com/csc/faq.html                      ]





Author: Pete Becker <pete@versatilecoding.com>
Date: Wed, 4 May 2011 12:46:13 CST
Raw View
On 2011-05-03 15:32:00 -0400, Edward Diener said:

On 5/2/2011 3:10 PM, Francis Glassborow wrote:
>
>
>> On 01/05/2011 19:52, Edward Diener wrote:
>>
>>
>>> In the latest C++ standard document (n3290) in section 3.9.2 part 1,
>>> where it mentions the ways in which compound types can be constructed
>>> I read:
>>>
>>> "=97 functions, which have parameters of given types and return void or
>>> references or objects of a given type, 8.3.5;"
>>>
>>> Should not this say "... return void or references or pointers or
>>> objects of a given type, 8.3.5;", or better yet just say "... return
>>> void or given types, 8.3.5;".
>>>
>>>
>>> Strictly speaking a pointer is an object. References are not objects. A
>>>
>> function does not and cannot return a type. So the wording is correct as
>> it stands.
>>
>>
> I did not realize that "a pointer is an object" in C++ standards
> terminology. In that case the original wording is perfectly correct.
>
> I do think it is natural to have assumed that "an object" meant something
> different. One often refers to "pointers to objects" or "references to
> objects" to distinguish objects themselves from the pointer or reference
> wa=
> y
> of specifying an object.
>

"object" as it's used in the standard is a compiler writer's term, not an
object-oriented programming term. An object is a region of storage and the
operations that are associated with it. So a pointer to an object is an
object, and, recursively, a pointer to a pointer to an object is also an
object. Since a reference doesn't have memory associated with it (although
it may be a pointer under the hood), it isn't an object; further, there are
no operations on references, only operations on the thing that's referred
to, so it isn't an object.

--
 Pete
Roundhouse Consulting, Ltd. (www.versatilecoding.com) Author of "The
Standard C++ Library Extensions: a Tutorial and Reference (
www.petebecker.com/tr1book)


[ comp.std.c++ is moderated.  To submit articles, try posting with your ]
[ newsreader.  If that fails, use mailto:std-cpp-submit@vandevoorde.com ]
[              --- Please see the FAQ before posting. ---               ]
[ FAQ: http://www.comeaucomputing.com/csc/faq.html                      ]