comp.lang.ada
 help / color / mirror / Atom feed
From: "Dmitry A. Kazakov" <mailbox@dmitry-kazakov.de>
Subject: Re: Discriminants of tagged types
Date: Thu, 28 Oct 2010 12:28:56 +0200
Date: 2010-10-28T12:28:56+02:00	[thread overview]
Message-ID: <1golp1kh7fc3j$.aeqd3d3zlf60$.dlg@40tude.net> (raw)
In-Reply-To: 14f33f04-40f5-4a72-a18b-d511dd2eb3b3@w21g2000vby.googlegroups.com

On Thu, 28 Oct 2010 01:50:51 -0700 (PDT), Maciej Sobczak wrote:

> On 28 Paďż˝, 09:53, "Dmitry A. Kazakov" <mail...@dmitry-kazakov.de>
> wrote:
> 
>>> Because tagged types usually represent entities that are bound to some
>>> resources
>>
>> This has nothing to do with copying. Consider a handle of a resource, e.g.
>> HWND as an example. It is bound to the resource, nevertheless it is
>> copyable.
> 
> Just like a file descriptor. Yet, there is no reason for these things
> to be polymorphic.

Nonsense. The handles must be typed. The relationships between their types
must reflect ones of the types of the target objects. Example, the handle
to an edit control must have a type derived from the type of a handle to a
window.

> Now consider a window or a file (as opposed to handle or descriptor).
> They are different from handles and descriptors in that they represent
> the target resources together with their lifetime management. That is,
> I expect that finalizing the window object leads to the window being
> closed or that finalizing the file object leads to the file being
> flushed and closed, etc. Copy operations for such types are
> meaningless.

That depends on the concrete case. There is much sense to be able to copy a
file or a graphical context.

> What would it mean to copy a file object? Should the file on disk be
> copied as well?

Yes, the file is on the disk, isn't it?

> Should the data that is still in the buffer be copied?

Yes. The data in the buffer is an implementation detail of which the file
user does not care. That is, the observable behavior shall not depend on
the implementation. If you copy a file it is copied independently on
whatever buffers be in whatever state.

> And so on. Instead of answering these questions in an unsatisfactory
> way, it is better to outlaw the dubious operation up front.

Programming is all about answering questions in unsatisfactory ways. The
goal is to minimize unsatisfaction. (:-))

>> Rather the opposite, most of container types are not copyiable [*]
> 
> Is Vector limited?

In which library? It could be or could be not. I designed unbounded arrays
not copyable.

>> most of them are very useful to derive from [**].
> 
> I don't see any justification for this.

Maybe you don't, but as a matter of fact, I derive from 3/4 of container
types I use. The container implementation provides an implementation to
adjust. It is a design tool, not an end product.

The way types (tools) are applied constitutes the types algebra. Derivation
is one of the most important operations of the algebra. That is why ideally
any type shall be inheritable.

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



  reply	other threads:[~2010-10-28 10:28 UTC|newest]

Thread overview: 41+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-10-27 12:16 Discriminants of tagged types Maciej Sobczak
2010-10-27 12:34 ` Ludovic Brenta
2010-10-27 13:19   ` Dmitry A. Kazakov
2010-10-27 13:52     ` Robert A Duff
2010-10-27 14:12       ` Dmitry A. Kazakov
2010-10-27 13:44 ` Robert A Duff
2010-10-27 15:06   ` Adam Beneschan
2010-10-27 15:58     ` Yannick Duchêne (Hibou57)
2010-10-27 16:35       ` Vinzent Hoefler
2010-10-27 17:58       ` J-P. Rosen
2010-10-27 20:18         ` Yannick Duchêne (Hibou57)
2010-10-27 20:26       ` Adam Beneschan
2010-10-27 22:07         ` Yannick Duchêne (Hibou57)
2010-10-27 22:42           ` Adam Beneschan
2010-10-27 15:13   ` Maciej Sobczak
2010-10-27 16:02     ` Yannick Duchêne (Hibou57)
2010-10-27 21:13       ` Maciej Sobczak
2010-10-27 21:23         ` Ludovic Brenta
2010-10-28  8:38           ` Maciej Sobczak
2010-10-27 21:25         ` Vinzent Hoefler
2010-10-28  7:53         ` Dmitry A. Kazakov
2010-10-28  8:50           ` Maciej Sobczak
2010-10-28 10:28             ` Dmitry A. Kazakov [this message]
2010-10-28 17:48             ` Yannick Duchêne (Hibou57)
2010-10-29 18:59             ` Vinzent Hoefler
2010-10-30 21:05               ` Maciej Sobczak
2010-10-30 21:21                 ` Vinzent Hoefler
2010-10-30 22:01                   ` Yannick Duchêne (Hibou57)
2010-10-31 16:20                   ` Maciej Sobczak
2010-10-31 17:04                     ` Yannick Duchêne (Hibou57)
2010-10-31 18:36                     ` Shark8
2010-10-31 21:06                       ` Maciej Sobczak
2010-11-01  0:44                         ` Shark8
2010-11-01  9:41                           ` Maciej Sobczak
2010-10-27 16:06     ` Robert A Duff
2010-10-27 16:34       ` Yannick Duchêne (Hibou57)
2010-10-27 21:05       ` Maciej Sobczak
2010-10-28  0:35         ` Robert A Duff
2010-10-28  8:55           ` Maciej Sobczak
2010-10-27 21:28       ` Simon Wright
2010-10-27 13:54 ` J-P. Rosen
replies disabled

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