From 6919804348061811913 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: f78e5,bb2cedb5166b3859 X-Google-Attributes: gidf78e5,public X-Google-ArrivalTime: 2001-11-13 11:22:03 PST Path: archiver1.google.com!news1.google.com!newsfeed.stanford.edu!news-spur1.maxwell.syr.edu!news.maxwell.syr.edu!dispose.news.demon.net!news.demon.co.uk!demon!mail2news.demon.co.uk!not-for-mail From: "Brian Parker" Newsgroups: comp.std.c++ Subject: Re: Typeof considered harmful (long) Date: Tue, 13 Nov 2001 19:21:49 GMT Organization: OzEmail Ltd, Australia Approved: Fergus Henderson , moderator of comp.std.c++ Message-ID: References: <58LH7.21413$xS6.32670@www.newsranger.com> X-Trace: mail2news.demon.co.uk 1005679316 mail2news:19716 mail2news mail2news.demon.co.uk X-Complaints-To: abuse@demon.net X-Mail2News-Path: news.demon.net!mulga.cs.mu.oz.au X-Authentication-Warning: mulga.cs.mu.OZ.AU: fjh set sender to devnull@stump.algebra.com using -f X-Robomod: STUMP, ichudov@algebra.com (Igor Chudov) X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 5.50.4807.1700 X-MimeOLE: Produced By Microsoft MimeOLE V5.50.4807.1700 NNTP-Posting-Date: Tue, 13 Nov 2001 21:59:39 EST Lines: 77 Xref: archiver1.google.com comp.std.c++:8158 "Michiel Salters" wrote in message news:58LH7.21413$xS6.32670@www.newsranger.com... >... > You are wrong. A template can be exported, in which case the source code need > not be available where the template is declared. I was aware of export. An environment supporting export must have some mechanism to find the exported pre-compiled templates when it needs to instantiate them. I presumed that an environment supporting export could use this mechanism to also lookup the deduced function return type. However, as was pointed out in a previous response, the standard says: [Note: an implementation may require that a translation unit containing the definition of an exported template be compiled before any translation unit containing an instantiation of that template.] So if an implementation required this then I don't think there would be a problem. But I agree that an implementation that didn't require this may make implementing this proposal for exported functions difficult (or impossible?). One simple possibility would be to limit this proposal to non-exported functions, but this would severely reduce the utility of it. I don't know enough about what extra-linguistic support export requires to be able to say definitively whether it is an insurmountable problem for this proposal; hopefully implementations supporting export will be available in the not-too-distant future. > > In addition, it is a major disadvantage that this solution does not work > in class templates. Many of the uses of typeof are not associated with > an initializing expression in such context, but are used to define > class members. Hmmm... this could be a major limitation of this proposal (or at least might suggest that typeof( ) would still be useful in addition to this proposal). Do you have a specific example where a class member type would need type typeof()? > > Let's see if (3) holds > > template > void f( Arg a ) > { > Local i=a, j=a+1; > //... > } > > Oops. Is typeof(a)==typeof(a+1) ? If not ? Yes, this edge case would need to be specified, probably by specifying that i is used for type deduction in the above example. > I think this proposal needs some work to handle class templates, exported > templates and a cleaner formulation of "THE type of initializing expression" Agreed, though the class template issue and possible the export issue may be show-stoppers. I would be very interested in specific class examples where typeof() would still be needed. Thanks, Brian Parker. --- [ 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://www.research.att.com/~austern/csc/faq.html ]