comp.lang.ada
 help / color / mirror / Atom feed
From: "Dmitry A. Kazakov" <mailbox@dmitry-kazakov.de>
Subject: Re: Returning a limited object as a class-wide value
Date: Wed, 29 Nov 2017 10:00:18 +0100
Date: 2017-11-29T10:00:18+01:00	[thread overview]
Message-ID: <ovlsv4$1rjd$1@gioia.aioe.org> (raw)
In-Reply-To: ovl4m6$k5s$1@gioia.aioe.org

On 29/11/2017 03:05, Victor Porton wrote:
> Let T be a limited tagged type.
> 
> I want to define a function F which returns T'Class.
> 
> Please show me an example.
> 
> I try:
> 
> return X: T'Class := T'(others => <>) do
>     --- ...
> end return;
> 
> Right way?

Never return limited objects, never use limited aggregates. Both are 
bogus concepts.

Even if compiler perchance compiled your code, your design will not work 
in case you wanted private extensible limited type with kind of 
"constructor" called from the derived type's "constructor".

I tried that, it does not work. The worst thing is that you discover the 
dead end pretty much too late in some distant client packages and have 
to return all way back. Just don't.

-- 
Regards,
Dmitry A. Kazakov
http://www.dmitry-kazakov.de


  reply	other threads:[~2017-11-29  9:00 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-11-29  2:05 Returning a limited object as a class-wide value Victor Porton
2017-11-29  9:00 ` Dmitry A. Kazakov [this message]
2017-11-29 20:51 ` Randy Brukardt
replies disabled

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