From 6454803343625416063
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: f78e5,ede379f5dbbc1549
X-Google-Attributes: gidf78e5,public
From: sirwillard@my-deja.com
Subject: Re: Suggestion: "typeof" keyword
Date: 1999/08/12
Message-ID: <7oupeu$8te$1@nnrp1.deja.com>#1/1
X-Deja-AN: 511894761
X-NNTP-Posting-Host: 167.16.75.51
Approved: stephen.clamage@sun.com (comp.std.c++)
References: <7nt3vl$1oe$1@nnrp1.deja.com> <7oh7o8$t3f$1@nnrp1.deja.com> <37AE541B.A998F729@cs.utu.fi> <cTqioZABDwr3EwfO@robinton.demon.co.uk> <37AFAC37.6B7F4253@cs.utu.fi> <7opt86$pku$1@nnrp1.deja.com> <christian.bau-1108991021560001@christian-mac.isltd.insignia.com>
X-UID: 0000000001
X-Status: $$$T
X-Http-User-Agent: Mozilla/4.0 (compatible; MSIE 5.0; Windows NT)
X-Http-Proxy: 1.1 x29.deja.com:80 (Squid/1.1.22) for client 167.16.75.51
Organization: Deja.com - Share what you know. Learn what you don't.
X-Article-Creation-Date: Thu Aug 12 15:32:46 1999 GMT
X-MyDeja-Info: XMYDJUIDsirwillard
Newsgroups: comp.std.c++
Originator: clamage@taumet


In article <christian.bau-1108991021560001@christian-
mac.isltd.insignia.com>,
  christian.bau@isltd.insignia.com (Christian Bau) wrote:
> In article <7opt86$pku$1@nnrp1.deja.com>, sirwillard@my-deja.com
wrote:
>
> > > See my example:
> > > > typeof(a*b+c*d+e/f) x = a*b+c*d+e/f;
> > > vs.
> > > > declare x = a*b+c*d+e/f;
> > > I find the first line less clear in intent.
> >
> > I don't.  Even if I agreed, however, I think the idiom to be poor.
> > What you are doing is asking the compiler to determine the type of a
> > complex expression and at the same time declare an instance of that
> > type.  If I can't determine the type at the time I write such a line,
> > I'd hardly want the compiler to do so for me.  There may be rare cases
> > in which this is useful, but they are too rare to warrant yet another
> > keyword when the typeof keyword gives the same identical functionality.
>
> It is all about maintenance, and not forcing the programmer to specify
> things that he really doesnt care about. Say I want to exchange variables
> x and y. I need a temporary variable tmp. I dont want to specify the size
> of tmp, just "big enough".
>
> Anything that I have to specify is one thing that I can get right or
> wrong. Anything that I dont have to specify is one thing that I cannot get
> wrong. I prefer things that dont go wrong.

I see the "magic type" as being just as prone to error, but harder to
ascertain why.  You've basically lessened type safety here.


Sent via Deja.com http://www.deja.com/
Share what you know. Learn what you don't.


[ 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              ]




