From: "Randy Brukardt" <randy@rrsoftware.com>
Subject: Re: Returning a limited object as a class-wide value
Date: Wed, 29 Nov 2017 14:51:29 -0600
Date: 2017-11-29T14:51:29-06:00 [thread overview]
Message-ID: <ovn6ki$r7l$1@franka.jacob-sparre.dk> (raw)
In-Reply-To: ovl4m6$k5s$1@gioia.aioe.org
"Victor Porton" <porton@narod.ru> wrote in message
news:ovl4m6$k5s$1@gioia.aioe.org...
> 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?
Ignoring Dmitry's typical rant, I believe this is correct. You are making a
new object this way (as copying of limited objects is banned -- that's the
point).
Remember that a limited function can only be used to initialize a limited
object or used for a very short lifetime. That's usually enough. You can
compose limited objects this way, as well, so long as it is used in a
limited aggregate or function return.
But remember that "limited" is, well, limited for a reason. So there are
definitely things that can't be done that way.
Randy.
prev parent reply other threads:[~2017-11-29 20:51 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
2017-11-29 20:51 ` Randy Brukardt [this message]
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox