comp.lang.ada
 help / color / mirror / Atom feed
From: "Randy Brukardt" <randy@rrsoftware.com>
Subject: Re: Generic procedures and their parameters
Date: Fri, 8 Sep 2006 20:29:20 -0500
Date: 2006-09-08T20:29:20-05:00	[thread overview]
Message-ID: <3aqdnWxXdPQDhZ_YnZ2dnUVZ_vmdnZ2d@megapath.net> (raw)
In-Reply-To: g3c05xzf7uad$.wucggq0h6wuy$.dlg@40tude.net

"Dmitry A. Kazakov" <mailbox@dmitry-kazakov.de> wrote in message
news:g3c05xzf7uad$.wucggq0h6wuy$.dlg@40tude.net...
...
> 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.

We considered that, too, and decided not to do it because it because it
doesn't work well in Ada. "<" is usually Intrinsic, and Intrinsic things
cannot be passed as access-to-subprogram parameters. So you'd have to
explicitly build a wrapper function, with all of the possibilities for error
that that exposes. Generic instantiations don't have that limitation (as
they are are considered more heavyweight than a simple 'Access).

> 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).

We really wanted to avoid having a lot of different sorting routines,
because that then forces users to decide which one that they need to use.
Most of the time, the choice is not particularly important (if it is not a
critical operation), and excess choices just take mental energy away from
solving the problem at hand. (That's why I'd be opposed to having multiple
kinds of lists [like doubly and singly linked] in the Ada Containers
library; the space and performance differences would be slight, but they'd
add an additional complexity to deciding what container to use.)

But you are correct that there usually is a "natural" comparison operation
and then secondary orderings -- one could consider these as different cases,
simply as one would be named "<" and the other would have some other name..

                       Randy.





  reply	other threads:[~2006-09-09  1:29 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
2006-09-09  1:29       ` Randy Brukardt [this message]
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