comp.lang.ada
 help / color / mirror / Atom feed
From: "Dmitry A. Kazakov" <mailbox@dmitry-kazakov.de>
Subject: Re: Limited use for limited with?
Date: Wed, 29 Sep 2010 23:18:28 +0200
Date: 2010-09-29T23:18:26+02:00	[thread overview]
Message-ID: <15ugvogl5r3li$.1u085y9xge6ft.dlg@40tude.net> (raw)
In-Reply-To: f059316d-9994-4ea4-b984-f9530768bfbc@d25g2000yqc.googlegroups.com

On Wed, 29 Sep 2010 13:51:53 -0700 (PDT), Maciej Sobczak wrote:

> On 29 Wrz, 15:41, "Dmitry A. Kazakov" <mail...@dmitry-kazakov.de>
> wrote:
> 
>>> This would create circular dependency between Object and Registry's
>>> internals.
>>
>> You add one derived type to either of the hierarchies and that breaks the
>> dependency. You have to with or without access types.
> 
> Not at all. In my design Object knows nothing about registry. There is
> no such dependency and therefore it does not have to be broken.
> You have introduced this dependency, but this is one of the many
> reasons why I don't like your solution.

I did not. You have to pass an object or its pointer to the registry, or a
registry to the object. It is no matter, the operation has two arguments.
The dependency is here.

>> Object would call a class-wide operation of Registry from its Finalize.
> 
> This assumes that Registry is object-oriented and that all registries
> have some common interface. I don't want this assumption, it does not
> reflect any system requirement.

It is not an assumption. All registries are capable to maintain objects.
The set of registry types shares this property, even if you don't introduce
this set as a class, which would be an unwise decision, the class is here.

>>> I don't control the concrete
>>> implementation - in particular I don't implement the factory
>>> (constructor function).
>>
>> You declare the factory function abstract to be implemented by derived
>> types.
> 
> And how can I enforce that user will properly use the registry from
> the constructor?

By hiding other ways to construct the parent type. If the object is
declared with (<>) discriminants and its full view is hidden you have to
use the construction function in the aggregate that creates the object.

>>> The solution that you propose is not only very complex,
>>
>> I don't see how removing a type could add complexity.
> 
> In order to "remove a type" you have introduced:
> - factory functions, perhaps abstract

I don't expose object components anyway. It is a good style to have
components private. If Initialize does not do the job, factory function is
the only choice, because, unfortunately, Ada does not have proper
constructors with parameters.

> - Controlled with Finalized

Same as above. Non-controlled tagged types make no sense, because, again,
Ada lacks constructors and destructors.

> - circular dependencies between Object and Registry (ironically, you
> have then proposed to introduce *another derived type* to break that
> dependency - does it still count as "removing a type"?)

The dependency exists anyway.

[ And it is not circular. The relation "there exists an operation with
arguments of both types" is symmetric. ]

> - common tagged root for all registries (this seems to be also an
> additional type)

A big advantage, because later I might wish to write some class-wide
operations dealing with any registry. It happened to me so many times, that
I practically always use controlled bases.

-- 
Regards,
Dmitry A. Kazakov
http://www.dmitry-kazakov.de



  reply	other threads:[~2010-09-29 21:18 UTC|newest]

Thread overview: 54+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-09-28  7:37 Limited use for limited with? Maciej Sobczak
2010-09-28  9:04 ` Alex R. Mosteo
2010-09-30  7:24   ` Stephen Leake
2010-09-30  9:21     ` Alex R. Mosteo
2010-09-28  9:18 ` Ludovic Brenta
2010-09-28 12:59   ` Maciej Sobczak
2010-09-28 13:45     ` Dmitry A. Kazakov
2010-09-28 21:57       ` Maciej Sobczak
2010-09-29  6:03         ` Ludovic Brenta
2010-09-29  8:25           ` Maciej Sobczak
2010-09-29  7:51         ` Dmitry A. Kazakov
2010-09-29  8:38           ` Maciej Sobczak
2010-09-29  9:16             ` Dmitry A. Kazakov
2010-09-29 12:22               ` Maciej Sobczak
2010-09-29 13:41                 ` Dmitry A. Kazakov
2010-09-29 15:07                   ` Georg Bauhaus
2010-09-29 19:22                     ` Dmitry A. Kazakov
2010-09-29 20:51                   ` Maciej Sobczak
2010-09-29 21:18                     ` Dmitry A. Kazakov [this message]
2010-10-05  7:35                     ` Randy Brukardt
2010-10-08  8:05                       ` Maciej Sobczak
2010-10-09  6:29                         ` Randy Brukardt
2010-10-05  7:25             ` Randy Brukardt
2010-10-08  8:23               ` Maciej Sobczak
2010-10-09  6:13                 ` Randy Brukardt
2010-10-10 14:13                   ` Maciej Sobczak
2010-10-11  6:23                     ` Randy Brukardt
2010-10-12 19:29                       ` Maciej Sobczak
2010-10-12 20:19                         ` Dmitry A. Kazakov
2010-10-13  2:09                         ` Randy Brukardt
2010-10-13  8:44                           ` Georg Bauhaus
2010-10-15  0:59                             ` Randy Brukardt
2010-10-13  9:43                           ` Maciej Sobczak
2010-09-28 15:15     ` Ludovic Brenta
2010-09-28 22:04       ` Maciej Sobczak
2010-09-28 15:54   ` Robert A Duff
2010-09-30  7:27   ` Stephen Leake
2010-09-30  7:33     ` Ludovic Brenta
2010-09-30 16:03     ` Adam Beneschan
2010-10-07 11:55       ` Stephen Leake
2010-10-07 18:27         ` Martin Krischik
2010-10-07 21:30           ` Adam Beneschan
2010-10-09  6:29             ` Martin Krischik
2010-10-09 18:35               ` Robert A Duff
2010-10-08  0:07           ` Randy Brukardt
2010-10-09  6:21             ` Martin Krischik
2010-09-28  9:32 ` Vadim Godunko
2010-09-28 11:34 ` stefan-lucks
2010-09-28 13:15   ` stefan-lucks
2010-09-28 16:55 ` Adam Beneschan
2010-09-28 17:31   ` Robert A Duff
2010-09-28 19:24     ` Adam Beneschan
2010-09-28 20:32       ` Vadim Godunko
2010-09-28 21:32         ` Adam Beneschan
replies disabled

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