From -3679420371324170775
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: f78e5,ede379f5dbbc1549
X-Google-Attributes: gidf78e5,public
From: postmast.root.admi.gov@iname.com (blargg)
Subject: Re: Suggestion: "typeof" keyword
Date: 1999/08/28
Message-ID: <user-2708990154450001@as1-dialup-77.io.com>#1/1
X-Deja-AN: 518171137
Approved: Fergus Henderson <fjh@cs.mu.oz.au>
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> <t7r9laz5hj.fsf@calumny.jyacc.com> <7oup0a$8g2$1@nnrp1.deja.com> <37B3C2AD.5AB722AE@lucent.com> <37B5A571.449B@wanadoo.fr> <37B908A8.717CAC2C@lucent.com> <CVJFZFAbaWu3Ew15@robinton.demon.co.uk> <7pcvjs$tk4$1@nnrp1.deja.com> <user-1808991258230001@aus-as3-121.io.com> <37BBE6CC.FE2475E5@physik.tu-muenchen.de> <user-1908991352370001@aus-as5-169.io.com> <slrn7rph2r.e43.sbnaran@localhost.localdomain> <wk4shp3qij.fsf@newsguy.com> <user-2508990222060001@aus-as3-137.io.com> <37C45EDB.55BF9E6D@cds.duke.edu>
X-Original-Date: Fri, 27 Aug 1999 01:54:45 -0500
X-Complaints-To: news@news.unimelb.edu.au
X-Trace: izvestia.its.unimelb.edu.au 935843177 9043 128.250.29.17 (28 Aug 1999 12:26:17 GMT)
Organization: e-mail address IS valid - but fools the spammers
X-Auth: PGPMoose V1.1 PGP comp.std.c++ iQBFAgUAN8fVSeEDnX0m9pzZAQH7DAF/fg5a4oadXVFCdrazXN5vdkLvIL260JXB W/Bic9qukp7fysTZgZ23j8vOpMgRGVWd =5qXG
NNTP-Posting-Date: 28 Aug 1999 12:26:17 GMT
Newsgroups: comp.std.c++

In article <37C45EDB.55BF9E6D@cds.duke.edu>, Max TenEyck Woodbury
<mtew@cds.duke.edu> wrote:

> blargg wrote:
> > 
> > <tkkost@newsguy.com> wrote:
> > 
> > > ...
> > > If, as Siemel suggested,
> > > :: could be applied to the return type of a function, typeof could be
> > > written in terms of the language, but it would have to have a slightly
> > > different syntax if you wanted the typeof an expression
> > 
> > OK, type of an expression make sense.
> > 
> > > vs. the typeof a type:
> > 
> > Uhhh, I don't follow. Common-sense on. What the hell is "typeof a type"
> > for? Typeof a type is the type. It's useless. I'll repeat what I posted a
> > few days ago:
> > 
> >     typeof (typeof (typeof (typeof (typeof (typeof (typeof (int))))))))
> 
> While you don't need 'typeof <<type>>', it would make a bit more sense
> in some cases to specify the types needed for a function signature
> directly rather than having to supply an instance. Something like:
> 
>     typeof func( class xyz)

I simply do not like these added syntactic elements, becuase I don't think
they're necessary. I believe that templates provide all we need to make
temporaries to get their types in expressions.

    template<typename F>
    struct func_ret_type_;

    template<typename R>
    struct func_ret_type_<T (*f)()> {
        typedef R type;
    };

    template<typename R,typename A1>
    struct func_ret_type_<T (*f)( A1 )> {
        typedef R type;
    };

    // etc.

    template<typename F>
    typename func_ret_type_<F>::type func_ret_type( F );

    void f( Func f ) { // we don't know the exact typedef
        typeof (func_ret_type( f )) ret = f();
    }


The reason I don't like these extra syntactic elements is that there are
so many one could think to add. If the language allows it in a
relatively-concise way, then do it that way.

> which provides exactly the excuse needed to bring it closer to the
> sizeof syntax. 'typeof (<<expr>>)' or typeof <<function signature>>.

Uck. And I suppose you also want to add little syntactic elements to allow
finding out the type of argument n?

Please, let's look for solutions that involve minimal new elements that
work in many ways with *current* elements. C++ doesn't need more feature
creep.
---
[ 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              ]



