From 8750776033764020214
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: f78e5,ede379f5dbbc1549
X-Google-Attributes: gidf78e5,public
From: Christopher Eltschka <celtschk@physik.tu-muenchen.de>
Subject: Re: Suggestion: "typeof" keyword
Date: 1999/08/25
Message-ID: <37C3DA57.25C88799@physik.tu-muenchen.de>#1/1
X-Deja-AN: 517138796
Content-Transfer-Encoding: 7bit
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> <t7hfm6ytow.fsf@calumny.jyacc.com> <120819991357412479%lisa_lippincott@advisories.com> <slrn7rbjp3.dom.sbnaran@localhost.localdomain> <37BBDDCA.90D590D4@physik.tu-muenchen.de> <slrn7rph9n.e43.sbnaran@localhost.localdomain>
X-Original-Date: Wed, 25 Aug 1999 13:58:15 +0200
X-Accept-Language: German/Germany, de-DE, German, de, en
Content-Type: text/plain; charset=us-ascii
X-Complaints-To: news@news.unimelb.edu.au
X-Trace: izvestia.its.unimelb.edu.au 935608601 1390 128.250.29.17 (25 Aug 1999 19:16:41 GMT)
Organization: [posted via] Leibniz-Rechenzentrum, Muenchen (Germany)
X-Auth: PGPMoose V1.1 PGP comp.std.c++ iQBFAgUAN8RA8+EDnX0m9pzZAQF5bwF+LU0rgDJ5RcXzbh0T4zVnDDnCmLiRqknz 0NXnPiDXibGcIsEMhQ83uKSU3ooj4Mpt =gImD
Mime-Version: 1.0
NNTP-Posting-Date: 25 Aug 1999 19:16:41 GMT
Newsgroups: comp.std.c++

"Siemel B. Naran" wrote:
> 
> On 19 Aug 1999 16:39:34 GMT, Christopher Eltschka
> >"Siemel B. Naran" wrote:
> 
> >> In one of my posts I used this
> >>    typeof(A*B+C) MultiplyAdd(...) { ... }
> 
> >That's problematic:
> >
> >class X {};
> >class Y { Y operator*(); };
> >X operator*(X, Y);
> >Y operator*(X*, Y);
> >
> >typeof(X**Y) a
> 
> The notation "X*" to mean pointer to an 'X' is wrong. 

According to the current rules of writing types, writing
"X*" to mean "pointer to X" is right.

> One should say
> "&X" to get a pointer to an 'X'.

This may not work if X has overloaded operator& to return
something different than X* (sic!)

>  To summarize, "&X" means operator&
> applied to an X object -- in short, X::operator&.  An "*Y" means
> operator* applied to a Y object -- in short, Y::operator*.  So the
> meaning is unamgiguous: typeof(X**Y) is simply X.

You added a new rule on the fly to make it unambiguous.
The new rule is "you may not use any type that is not
given by a single name". Now if you should need such a type,
you must either name if (with an earlier typedef), or find an
expression which resolves to that type (your &X). It's a rule
that doesn't fit nicely into C++, where you can use the full
type notation everywhere you need a type.

A better way would be to make a special syntax for
"arbitrary object of type X", like [X]. Then the
example above would either read

typeof([X]**[Y])

where both * are operators, or

typeof([X*]*[Y])

where the first * is part of the type X*.

However, if you replace the syntax [X] by obj<X>(), you can
do it even without an additional extension, by just declaring
template<class T> T obj();
---
[ 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              ]



