From 7841514947342911069
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: f78e5,18c6d861cef54158
X-Google-Attributes: gidf78e5,public
X-Google-ArrivalTime: 2003-01-01 22:39:28 PST
Path: archiver1.google.com!news1.google.com!newsfeed.stanford.edu!news-spur1.maxwell.syr.edu!news.maxwell.syr.edu!newsfeed.icl.net!newsfeed.fjserv.net!kibo.news.demon.net!mutlu.news.demon.net!demon!mail2news.demon.co.uk!devnull
From: Daniel.Miller@tellabs.com ("Dan'l Miller")
Newsgroups: comp.std.c++
Subject: Re: automatic downcast support through function parameters
Date: Thu, 2 Jan 2003 06:39:24 +0000 (UTC)
Lines: 54
Approved: fjh@cs.mu.oz.au (Fergus Henderson , moderator of comp.std.c++)
Message-ID: <3E120608.6060608@tellabs.com>
References: <23478c42.0212310830.23dbc580@posting.google.com>
Mime-Version: 1.0
Content-Type: text/plain; charset=us-ascii; format=flowed
Content-Transfer-Encoding: 7bit
X-Trace: mail2news.demon.co.uk 1041489564 10563 10.0.0.1 (2 Jan 2003 06:39:24 GMT)
X-Complaints-To: abuse@demon.net
NNTP-Posting-Date: Thu, 2 Jan 2003 06:39:24 +0000 (UTC)
X-Received: from mulga.cs.mu.oz.au ([128.250.1.22])
	by news.demon.co.uk with esmtp (Exim 4.05)
	id 18Tz0l-0002kE-00
	for mail2news@news.news.demon.net; Thu, 02 Jan 2003 06:39:23 +0000
X-Received: from localhost (localhost [[UNIX: localhost]]) by mulga.cs.mu.OZ.AU
	id RAA15461; Thu, 2 Jan 2003 17:39:19 +1100 (EST)
X-Authentication-Warning: mulga.cs.mu.OZ.AU: fjh set sender to devnull@stump.algebra.com using -f
X-Path: comp-std-cpp-robomod!not-for-mail
X-Robomod: STUMP, ichudov@algebra.com (Igor Chudov)
X-Delivered-To: std-c++@ncar.ucar.edu
X-User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.0.1) Gecko/20020823 Netscape/7.0 (nscd1)
X-Accept-Language: en,pdf
X-Newsgroups: comp.std.c++
X-NNTP-Posting-Date: Tue, 31 Dec 2002 15:03:38 CST
X-MailScanner: PASSED (v1.2.7 30032 gBVL3cMd043165 mailbox3.ucsd.edu)
X-Spam-Status: No, hits=-6.6 required=5.0
	tests=QUOTED_EMAIL_TEXT,REFERENCES,SPAM_PHRASE_01_02,USER_AGENT,
	      USER_AGENT_MOZILLA_UA,X_ACCEPT_LANG
	version=2.41
Xref: archiver1.google.com comp.std.c++:16604

danielgutson@hotmail.com wrote:
> People: I'd like to ask about the feasibility of this:
> automatic downcast during function calls.
> let's have:
>  struct Base{};
>  struct Der : Base{};
> 
>  void g(Base* b);
>  void g(Der* d);
> 
>  void f(upcasted Base* b)    // see below
>  {
>    g(b);
>  }
> 
>  void main(void)
>  {
>     Der d;
>     f(&d);
>  }
> 
>  - The idea here is that f ignores the function that will be finally
>  invoked, but knows that the pointer was upcasted ('upcasted'
> keyword).
>  Then, the function accepting the most derived class (closest to the
>  original type) will be invoked, in this case: g(Der*).
> 
> The 'spirit' of this is to recover specificity: in the process flow:
>   main -> f -> g
> specificity(main) = specificity(g) > specificity(f)
> and this would be an automatic way of recoviring specificity at g,
> without loosing generality at f.
> 
>  What you think?

   I think that this works well at compile-time only 1) if one has a single 
compilation unit or 2) if one has global analysis among separate compilation 
units.  In practice "compilation unit" normally corresponds to a .c/.cpp/.cxx/.C 
file which begets a .o/.obj file.

   Because C's (and thus C++'s) compilation model is predicated on separate 
compilation, this proposed feature is in turn predicated on the hypothetical 
removal of separate compilation from C++/C.  Such removal of the 
separate-compilation axiom appears quite unlikely to me in the foreseeable future.

   I think that human-authored code can be written to 
overtly/manually/nonautomatically accomplish this via RTTI at run-time.

---
[ 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.jamesd.demon.co.uk/csc/faq.html                       ]



