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=-0.3 required=5.0 tests=BAYES_00, REPLYTO_WITHOUT_TO_CC autolearn=no autolearn_force=no version=3.4.4 X-Google-Thread: 103376,e92d558e5b77fce2 X-Google-NewGroupId: yes X-Google-Attributes: gida07f3367d7,domainid0,public,usenet X-Google-Language: ENGLISH,ASCII-7-bit Received: by 10.68.227.40 with SMTP id rx8mr13449041pbc.5.1328605860797; Tue, 07 Feb 2012 01:11:00 -0800 (PST) Path: lh20ni269927pbb.0!nntp.google.com!news1.google.com!goblin1!goblin2!goblin.stu.neva.ru!aioe.org!.POSTED!not-for-mail From: "Dmitry A. Kazakov" Newsgroups: comp.lang.ada Subject: Re: Building limited types through nested creator functions Date: Tue, 7 Feb 2012 10:10:10 +0100 Organization: cbb software GmbH Message-ID: <12ltgmjr08pwh.10sal6ffvej77.dlg@40tude.net> References: <40048c5a-ecf5-43e6-8c76-a294d0c333d1@l14g2000vbe.googlegroups.com> <45c75d2a-02b4-40b2-b69b-04c6bf7a47a5@t2g2000yqk.googlegroups.com> <57a267ec-b901-401e-b415-ca6d9cf47616@d15g2000yqg.googlegroups.com> <326bcb0a-e37d-4d67-84c2-3d21e3ba3ffe@h6g2000yqk.googlegroups.com> Reply-To: mailbox@dmitry-kazakov.de NNTP-Posting-Host: FbOMkhMtVLVmu7IwBnt1tw.user.speranza.aioe.org Mime-Version: 1.0 X-Complaints-To: abuse@aioe.org User-Agent: 40tude_Dialog/2.0.15.1 X-Notice: Filtered by postfilter v. 0.8.2 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Date: 2012-02-07T10:10:10+01:00 List-Id: On Mon, 6 Feb 2012 18:19:44 -0800 (PST), Simon Belmont wrote: > I suppose the 'right' thing to do would be to create > factory-type objects so that all Make_Outer has to do is call some > hypothetical Create function of the argument, but I didn't want to > waste my time if there was a method involving less typing. I am afraid you should sacrifice both simplicity of use (if aggregates could ever be considered "simple"), as well as information hiding. The problem is that constructing functions of Ada are no replacement to constructors, especially not with limited types. Multiple language hacks were made (limited return, limited aggregates) in order to work this around, but the problem persists. The issue you have is not the only one. Another is when you have some parent types abstract. Since an abstract type cannot be returned, you would have to implement partial constructors as class-wide procedures and get a quite ugly and unsafe mess in the end. There is no good advise how to approach this in general. You should try this and that variant until you get a satisfactory solution. -- Regards, Dmitry A. Kazakov http://www.dmitry-kazakov.de