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: eternal-september.org!reader01.eternal-september.org!reader02.eternal-september.org!feeder.eternal-september.org!gandalf.srv.welterde.de!news.jacob-sparre.dk!franka.jacob-sparre.dk!pnx.dk!.POSTED.rrsoftware.com!not-for-mail From: "Randy Brukardt" Newsgroups: comp.lang.ada Subject: Re: Returning a limited object as a class-wide value Date: Wed, 29 Nov 2017 14:51:29 -0600 Organization: JSA Research & Innovation Message-ID: References: Injection-Date: Wed, 29 Nov 2017 20:51:30 -0000 (UTC) Injection-Info: franka.jacob-sparre.dk; posting-host="rrsoftware.com:24.196.82.226"; logging-data="27893"; mail-complaints-to="news@jacob-sparre.dk" X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2900.5931 X-RFC2646: Format=Flowed; Original X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.7246 Xref: reader02.eternal-september.org comp.lang.ada:49262 Date: 2017-11-29T14:51:29-06:00 List-Id: "Victor Porton" 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.