From: "Matthew Heaney" <matthewjheaney@earthlink.net>
Subject: Re: XML DOM Binding for Ada 95 - matter of style
Date: Thu, 07 Aug 2003 12:52:44 GMT
Date: 2003-08-07T12:52:44+00:00 [thread overview]
Message-ID: <wYrYa.424$Nf3.323@newsread4.news.pas.earthlink.net> (raw)
In-Reply-To: egd1jvc6pe888e4ug683tis6a5q5ua12ml@4ax.com
"Dmitry A. Kazakov" <mailbox@dmitry-kazakov.de> wrote in message
news:egd1jvc6pe888e4ug683tis6a5q5ua12ml@4ax.com...
> On Tue, 5 Aug 2003 13:34:09 +0000 (UTC), Georg Bauhaus
> <sb463ba@d2-hrz.uni-duisburg.de> wrote:
>
> >Actually, you can pass operations of a tagged type as actuals.
>
> Yes, this is a great disadvantage of generics. You have to explicitly
> specify everything you need.
This is a feature, not a flaw. The Ada generics were deliberately designed
this way, because you get better error checking.
> Compare it with inheritance, you just
> specify a base type. This is because Ada's generics try to pretend to
> have some contract.
I don't know what you mean by "pretend" to have a contract: Ada generics do
have a contract. In fact it's called the "generic contract model."
> C++ does not, it openly says that what you become
> is your own business.
Well, yes and no. You don't just design ex nihilo, but with the expection
that the generic actual type will have a specific set of operations, even if
those operations are only loosely specified.
> template <class Element>void Sort ...;
> // Guess, what I have used here this week, "<=" or ">="?
No. Sort will only use operator<. It will never use operator<= or
operator>=, because those can be derived from the canonical operator<.
You should always define relational operators in terms of the less-than
operatior:
function "<" (L, R : T) return Boolean is ...;
function ">" (L, R : T) return Boolean is
begin
return R < L;
end;
function ">=" (L, R : T) return Boolean is
begin
return not (L < R);
end;
function ">=" (L, R : T) return Boolean is
begin
return R <= L;
end;
In the STL and in Charles, you even use the less-then operator for computing
"equivalence" of keys:
function Is_Equivalent (L, R : T) return Boolean is
begin
return not (L < R) and not (R < L);
end;
The equality operator "=" for elements is only used to compute the value of
container equality.
> >Can this be done with virtual member functions in C++?
>
> You mean to pass a dispatching operation to a template?
I showed how to do this in Ada in a previous post.
next prev parent reply other threads:[~2003-08-07 12:52 UTC|newest]
Thread overview: 47+ messages / expand[flat|nested] mbox.gz Atom feed top
2003-07-30 11:32 XML DOM Binding for Ada 95 - matter of style DENNY VRANDECIC
2003-07-30 12:33 ` Martin Dowie
2003-07-30 15:20 ` Denny Vrandecic
2003-07-30 16:33 ` Stephen Leake
2003-07-31 10:57 ` Marin David Condic
2003-07-31 11:27 ` Preben Randhol
2003-07-31 13:10 ` Matthew Heaney
2003-07-31 19:04 ` Simon Wright
2003-08-02 14:40 ` Matthew Heaney
2003-07-31 20:25 ` Randy Brukardt
2003-08-01 11:46 ` Marin David Condic
2003-08-02 3:40 ` Matthew Heaney
2003-08-02 12:08 ` Marin David Condic
2003-08-02 14:46 ` Matthew Heaney
2003-08-02 21:25 ` Ed Falis
2003-08-05 19:59 ` Marin David Condic
2003-08-03 16:42 ` Matthew Heaney
2003-08-04 8:04 ` Dmitry A. Kazakov
2003-08-05 8:00 ` Georg Bauhaus
2003-08-05 11:46 ` Dmitry A. Kazakov
2003-08-05 13:34 ` Georg Bauhaus
2003-08-06 9:03 ` Dmitry A. Kazakov
2003-08-06 18:15 ` signature like constructions (was: Re: XML DOM Binding for Ada 95 - matter of style) Georg Bauhaus
2003-08-07 10:12 ` Dmitry A. Kazakov
2003-08-07 16:22 ` signature like constructions Georg Bauhaus
2003-08-08 8:31 ` Dmitry A. Kazakov
2003-08-08 10:12 ` Robert I. Eachus
2003-08-08 13:29 ` Dmitry A. Kazakov
2003-08-08 19:37 ` Robert I. Eachus
2003-08-09 0:58 ` Alexander Kopilovitch
2003-08-09 7:39 ` Robert I. Eachus
2003-08-10 1:30 ` Alexander Kopilovitch
2003-08-10 4:11 ` Robert I. Eachus
2003-08-11 10:25 ` Dmitry A. Kazakov
2003-08-08 23:44 ` Alexander Kopilovitch
2003-08-11 9:54 ` Dmitry A. Kazakov
2003-08-11 14:59 ` Alexander Kopilovitch
2003-08-12 9:54 ` Dmitry A. Kazakov
2003-08-13 22:28 ` Alexander Kopilovitch
2003-08-09 8:32 ` Simon Wright
2003-08-09 15:32 ` Robert I. Eachus
2003-08-07 12:52 ` Matthew Heaney [this message]
2003-08-07 15:03 ` XML DOM Binding for Ada 95 - matter of style Dmitry A. Kazakov
2003-08-07 12:28 ` Matthew Heaney
2003-08-05 20:05 ` Marin David Condic
2003-07-30 16:34 ` Martin Dowie
2003-07-30 17:54 ` tmoran
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox