From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00 autolearn=unavailable autolearn_force=no version=3.4.4 Path: border1.nntp.dca.giganews.com!nntp.giganews.com!news.bbs-scene.org!xmission!news.snarked.org!newsfeed.news.ucla.edu!usenet.stanford.edu!bloom-beacon.mit.edu!bloom-beacon.mit.edu!newsswitch.lcs.mit.edu!nntp.TheWorld.com!.POSTED!not-for-mail From: Robert A Duff Newsgroups: comp.lang.ada Subject: Re: Suggestion: Allow functions returning abstract types in certain situations Date: Wed, 21 May 2014 18:04:05 -0400 Organization: The World Public Access UNIX, Brookline, MA Message-ID: References: NNTP-Posting-Host: shell01.theworld.com Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: pcls7.std.com 1400709845 6066 192.74.137.71 (21 May 2014 22:04:05 GMT) X-Complaints-To: abuse@TheWorld.com NNTP-Posting-Date: Wed, 21 May 2014 22:04:05 +0000 (UTC) User-Agent: Gnus/5.1008 (Gnus v5.10.8) Emacs/21.3 (irix) Cancel-Lock: sha1:FvMH5Oj2HE0Xhuv/0ZDOvBsLyaY= Xref: number.nntp.dca.giganews.com comp.lang.ada:186551 Date: 2014-05-21T18:04:05-04:00 List-Id: Adam Beneschan writes: > Although at first glance this appeared reasonable to me, I think > there's a huge problem: how would you write the *body* of the > function? The function would have to return something. The language > doesn't allow you to declare objects of an abstract type, so Func > could not declare a local variable "Result" of type T1 that it could > return. Nor could it return an aggregate, which involves creating a > temporary object. Those things would have to be allowed, too. >...In my view, the language model depends heavily on > the assumption that an object can never be created whose tag refers to > an abstract type; allowing the rule to *ever* be relaxed could be > disastrous. I don't think so. As I posted a while back, the only trouble comes from converting an object of an abstract type to a class-wide type -- that is what needs to be forbidden. Note to the OP: You can also use the form of extension aggregate where you give the ancestory type name. In that case, you get default initialization, which is unfortunate, but it does work. - Bob