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!news.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail From: "Alejandro R. Mosteo" Newsgroups: comp.lang.ada Subject: Re: Constructing by classwide type Date: Tue, 18 Apr 2017 19:37:59 +0200 Organization: A noiseless patient Spider Message-ID: References: <93d2cfb3-1518-4d99-8075-e636e1f32b5d@googlegroups.com> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit Injection-Date: Tue, 18 Apr 2017 17:34:52 -0000 (UTC) Injection-Info: mx02.eternal-september.org; posting-host="f78f513a30c5dec0ee944648c4f2d762"; logging-data="14195"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+6Dbf5PTXwRNB4wcx+5XQk" User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.8.0 In-Reply-To: <93d2cfb3-1518-4d99-8075-e636e1f32b5d@googlegroups.com> Cancel-Lock: sha1:il3XaklmYCDeF+eWFk9QLzAN9RA= Xref: news.eternal-september.org comp.lang.ada:46590 Date: 2017-04-18T19:37:59+02:00 List-Id: On 03/04/17 03:04, sbelmont700@gmail.com wrote: > Can anyone offer advice on the pros and cons of having constructor functions of extended types return their classwide parent in lieu of the concrete type? Occasionally I find myself with an abstract parent type that is implemented by a broad number of children, none of which add any new primitive operations or are extended any further, and all of which are intended to be used in the context of their (classwide) parent; in these cases, there seems to be several marginal benefits to returning the parent type, including that nearly all declarations can be put into the body, it forces initialization, the constructor doesn't become a primitive operation, it acts as a kind poor mans 'final' keyword, et al... > > None of it is earth-shattering, but apart from not having access to the underlying type (not necessarily a bad thing depending on circumstance), are there other downsides I've yet to discover? > > Thanks for any advice I've been under the same circumstances recently and wondered the same. I hope you get some informed answers. Until date, I have noticed no drawbacks and all the advantages you mention. Alex. > > -sb >