comp.lang.ada
 help / color / mirror / Atom feed
From: "Dmitry A. Kazakov" <mailbox@dmitry-kazakov.de>
Subject: Re: Generic procedures and their parameters
Date: Fri, 8 Sep 2006 09:21:44 +0200
Date: 2006-09-08T09:21:43+02:00	[thread overview]
Message-ID: <g3c05xzf7uad$.wucggq0h6wuy$.dlg@40tude.net> (raw)
In-Reply-To: dbGdnW_HQKomeZ3YnZ2dnUVZ_vydnZ2d@megapath.net

On Thu, 7 Sep 2006 22:35:44 -0500, Randy Brukardt wrote:

> "Dmitry A. Kazakov" <mailbox@dmitry-kazakov.de> wrote in message
> news:w0vh1ugsvkj1$.2fnx5mt0tplm$.dlg@40tude.net...
> ...
>> The reverse is a different story. It is a pity that Ada does not have
>> attributes to get the index and element types from the array type
>> (container type). The next step would be getting "<" from the element type,
>> which would eliminate a need to have Sort generic.
> 
> That doesn't really work. "<" is what controls how the items are sorted, and
> it is common to want to sort the same type in multiple ways. If you have
> employee records, you might want to sort them both on Social Security
> numbers and on date of employment, for example. Two generic instantiations
> work fine for that, but there isn't any way to have two "<" with different
> behaviors.
>
> We had this discussion when looking at the possibility of having a sorting
> interface. It just doesn't work well, because there can only be a single
> implementation. (That is a problem with any scheme based on inheritance.)
> That's why I view interfaces less as types and more as properties that are
> either present or absent on any individual specific type.

Yes, that's when somebody wanted to have different orders. But that in my
view is a different case, in which "<" should be better passed to Sort as a
plain parameter, rather than generic or primitive subprogram. I think the
difference between two scenarios is whether the order is arbitrary, ad-hoc
or else involved in some loose set of operations. In the first case "<"
should be a parameter in the latter case a part of the interface (be it
generic or primitive operation).

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



  reply	other threads:[~2006-09-08  7:21 UTC|newest]

Thread overview: 27+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-09-06  8:51 Generic procedures and their parameters Maciej Sobczak
2006-09-06  9:43 ` Dmitry A. Kazakov
2006-09-06 12:36   ` Maciej Sobczak
2006-09-06 13:11     ` Robert A Duff
2006-09-06 14:14       ` Maciej Sobczak
2006-09-06 15:09         ` Dmitry A. Kazakov
2006-09-06 16:35           ` Georg Bauhaus
2006-09-07  7:32             ` Dmitry A. Kazakov
2006-09-07  6:48               ` Georg Bauhaus
2006-09-07 10:19                 ` Dmitry A. Kazakov
2006-09-08  9:11           ` Maciej Sobczak
2006-09-08 10:19             ` Dmitry A. Kazakov
2006-09-09 14:49         ` Robert A Duff
2006-09-09 15:34           ` Dmitry A. Kazakov
2006-09-09 23:26           ` Jeffrey R. Carter
2006-09-10 11:49             ` Robert A Duff
2006-09-10 19:43               ` Jeffrey R. Carter
2006-09-06 13:02   ` Robert A Duff
2006-09-06 14:09     ` Dmitry A. Kazakov
2006-09-08  3:35   ` Randy Brukardt
2006-09-08  7:21     ` Dmitry A. Kazakov [this message]
2006-09-09  1:29       ` Randy Brukardt
2006-09-09  7:14         ` Dmitry A. Kazakov
2006-09-09 14:32         ` Robert A Duff
2006-09-06 12:56 ` Robert A Duff
2006-09-07  2:47 ` Steve
2006-09-07  7:47   ` Dmitry A. Kazakov
replies disabled

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