comp.lang.ada
 help / color / mirror / Atom feed
From: "Dan'l Miller" <optikos@verizon.net>
Subject: Re: Suggestion: Allow functions returning abstract types in certain situations
Date: Wed, 21 May 2014 12:09:30 -0700 (PDT)
Date: 2014-05-21T12:09:30-07:00	[thread overview]
Message-ID: <a8c0fb07-bb62-4db8-a622-058422145bcb@googlegroups.com> (raw)
In-Reply-To: <a5c7aaeb-1871-4158-ba3f-189e088e7778@googlegroups.com>

On Wednesday, May 21, 2014 11:10:44 AM UTC-5, Adam Beneschan wrote:
> On Wednesday, May 21, 2014 7:52:27 AM UTC-7, Victor Porton wrote:
> 
> > I think the standard should allow functions returning abstract types,

The size of an abstract type is not known in this situation.  Perhaps you should reconsider your design (and your critique of Ada) to focus on functions returning some variety of *access* to abstract type  or abstract type 'Class (rather than returning an instance of an abstract type's eventual concrete type).

> > but we 
> > can restrict to call such functions ONLY in parent parts of record 
> > extensions or private extensions.

In C++ this is called slicing, which is undefined behavior and which is considered one of the ways to drive off the cliff in C++.  Ada should absolutely not permit any form of slicing.

> Unless you mean "extension aggregates", I'm not sure what you're referring to.  An extension aggregate is an aggregate where the parent part is specified as an expression and the extension fields follow the "with" keyword.  So are you referring to something like this?
> 
> 
> 
>     package Pack1 is
>         type T1 is abstract tagged record ... end record;
>         function Func (X : Integer) return T1;  -- not currently legal

This whole topic seems to be going nowhere fast.  The size of T1's eventual concrete type (i.e., some member of T1'Class) cannot be known by Func (nor in general by callers of Func).  There could be many such eventual concrete types of T1; hence the insurmountable question will always be:  which member of T1'Class was instantiated concretely?

  reply	other threads:[~2014-05-21 19:09 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 [this message]
2014-05-21 22:09     ` Robert A Duff
2014-05-21 22:29       ` Adam Beneschan
2014-05-21 22:04   ` Robert A Duff
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