comp.lang.ada
 help / color / mirror / Atom feed
From: "Dmitry A. Kazakov" <mailbox@dmitry-kazakov.de>
Subject: Re: Building limited types through nested creator functions
Date: Tue, 7 Feb 2012 10:10:10 +0100
Date: 2012-02-07T10:10:10+01:00	[thread overview]
Message-ID: <12ltgmjr08pwh.10sal6ffvej77.dlg@40tude.net> (raw)
In-Reply-To: 326bcb0a-e37d-4d67-84c2-3d21e3ba3ffe@h6g2000yqk.googlegroups.com

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



  reply	other threads:[~2012-02-07  9:11 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-02-05 22:03 Building limited types through nested creator functions Simon Belmont
2012-02-06 12:44 ` Julian Leyh
2012-02-06 19:11 ` Shark8
2012-02-06 22:33   ` Simon Belmont
2012-02-07  0:03 ` Adam Beneschan
2012-02-07  0:27   ` Simon Belmont
2012-02-07  0:53     ` Adam Beneschan
2012-02-07  2:19       ` Simon Belmont
2012-02-07  9:10         ` Dmitry A. Kazakov [this message]
2012-02-07 10:58           ` Georg Bauhaus
2012-02-07 13:25             ` Dmitry A. Kazakov
2012-02-07 14:43               ` Yannick Duchêne (Hibou57)
2012-02-07 15:08                 ` Dmitry A. Kazakov
2012-02-07 17:04 ` Robert A Duff
replies disabled

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