From -1977844894215363527
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: f78e5,ede379f5dbbc1549
X-Google-Attributes: gidf78e5,public
From: fjh@cs.mu.OZ.AU (Fergus Henderson)
Subject: Re: Suggestion: "typeof" keyword
Date: 1999/08/13
Message-ID: <7p0lub$2i3$1@mulga.cs.mu.OZ.AU>#1/1
X-Deja-AN: 512289900
X-Nntp-Posting-Host: murlibobo.cs.mu.oz.au
Approved: stephen.clamage@sun.com (comp.std.c++)
References: <7nt3vl$1oe$1@nnrp1.deja.com> 		<7oh7o8$t3f$1@nnrp1.deja.com> 		<7ol6hi$ej9$2@news.BelWue.DE> 		<cTiioXAhAwr3Ew$X@robinton.demon.co.uk> 		<t7d7ww1vrz.fsf@calumny.jyacc.com> 		<e4DSyfA4ALs3Ew0Q@robinton.demon.co.uk> <t7hfm6ytow.fsf@calumny.jyacc.com> <37B2DA79.3A02@wanadoo.fr>
Organization: Computer Science, The University of Melbourne
X-UID: 0000000001
X-Status: $$$T
Newsgroups: comp.std.c++
Originator: clamage@taumet


Valentin Bonnard <Bonnard.V@wanadoo.fr> writes:

>Hyman Rosen wrote:
>
>> If you think about it, there is a fundamental asymmetry in function
>> template argument deduction, in that the deduced types are fully
>> available to be used within the function, 
>
>This ``asymmetry'' is called scoping, by the way.
>
>I am not sure that scoping has to be ``corrected''.

`declare' and even `typeof' would both preserve scoping.

I think it's more an issue of orthogonality rather than asymmetry.
Type deduction and function calls are separate things.  C++ compilers
know how to do type deduction, and knows how to do function calls.
But for various reasons, mostly historical IMHO, C++ doesn't provide
any way to do type deduction without doing a function call.
`typeof' could remedy that.

However, `typeof' is not quite as general as argument type deduction.
For example, you may know that a particular variable has type
`foo<const T *>', and you may want to find out what `T' is;
you can do that with argument type deduction, but you can't do it
with `typeof'.

Still, `typeof' is a simple extension in the following senses:
	- it's easy to implement (C++ compilers already have the necessary
	  infrastructure for doing type deduction, so I think it should
	  basically be just a matter of adding the front-end syntax)
	- it's easy to specify
	- it's easy for programmers to understand

I'm not sure how useful it is, but as far as extensions go,
the cost of adding this one is very low.

-- 
Fergus Henderson <fjh@cs.mu.oz.au>  |  "I have always known that the pursuit
WWW: <http://www.cs.mu.oz.au/~fjh>  |  of excellence is a lethal habit"
PGP: finger fjh@128.250.37.3        |     -- the last words of T. S. Garp.


[ comp.std.c++ is moderated.  To submit articles, try just posting with ]
[ your news-reader.  If that fails, use mailto:std-c++@ncar.ucar.edu    ]
[              --- Please see the FAQ before posting. ---               ]
[ FAQ: http://reality.sgi.com/austern_mti/std-c++/faq.html              ]




