comp.lang.ada
 help / color / mirror / Atom feed
From: Robert A Duff <bobduff@shell01.TheWorld.com>
Subject: Re: Suggestion: Allow functions returning abstract types in certain situations
Date: Wed, 21 May 2014 18:04:05 -0400
Date: 2014-05-21T18:04:05-04:00	[thread overview]
Message-ID: <wccsio2zt4a.fsf@shell01.TheWorld.com> (raw)
In-Reply-To: a5c7aaeb-1871-4158-ba3f-189e088e7778@googlegroups.com

Adam Beneschan <adambeneschan@gmail.com> 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


  parent reply	other threads:[~2014-05-21 22:04 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-05-21 14:52 Suggestion: Allow functions returning abstract types in certain situations Victor Porton
2014-05-21 16:10 ` Adam Beneschan
2014-05-21 19:09   ` Dan'l Miller
2014-05-21 22:09     ` Robert A Duff
2014-05-21 22:29       ` Adam Beneschan
2014-05-21 22:04   ` Robert A Duff [this message]
2014-05-21 22:33     ` Adam Beneschan
2014-05-21 23:19       ` Robert A Duff
2014-05-22  7:22         ` Dmitry A. Kazakov
2014-05-24 18:39           ` Robert A Duff
2014-05-24 19:20             ` Dmitry A. Kazakov
2014-05-22 14:47         ` Adam Beneschan
2014-05-24 18:45           ` Robert A Duff
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox