From: Simon Wright <simon@pushface.org>
Subject: Re: Problem with generic linked list package
Date: Sun, 10 Aug 2014 09:22:53 +0100
Date: 2014-08-10T09:22:53+01:00 [thread overview]
Message-ID: <ly4mxkn482.fsf@pushface.org> (raw)
In-Reply-To: 42e0f58b-63c4-4a08-90ce-b5ddf7ebe95b@googlegroups.com
Laurent <daemon2@internet.lu> writes:
> Yes indeed if Element would be a record then insert_in_order wouldn't
> work as it is. Because "<" and "=" don't exist for this type. Perhaps
> if I compared the components of the record I would but for now I don't
> see how I would do that. Problem for later when I have to use my
> package for a real program.
type Rec is record
B : Boolean;
I : Integer;
end record;
function "<" (L, R : Rec) return Boolean is
begin
return L.I < R.I;
end "<";
and similarly for "=".
I've found it's less confusing for me if I don't actually call these
functions "<", "=" but rather Less_Than, Equals. You lose the (minor)
inconvenience of being able to use the default comparison when
instantiating your generic, but gain clarity. This is presumably why we
have Ada.Strings.Less_Case_Insensitive and Equal_Case_Insensitive;
if they were called "<", "=" there could easily be ambiguity with the
default String subprograms.
next prev parent reply other threads:[~2014-08-10 8:22 UTC|newest]
Thread overview: 28+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-07-28 13:26 Problem with generic linked list package Laurent
2014-07-29 7:51 ` Jacob Sparre Andersen
2014-07-29 8:12 ` Laurent
2014-07-29 8:27 ` Stephen Leake
2014-07-29 15:38 ` Laurent
2014-08-07 19:07 ` Laurent
2014-08-07 19:21 ` Adam Beneschan
2014-08-07 19:25 ` Adam Beneschan
2014-08-07 22:20 ` Laurent
2014-08-07 23:35 ` Adam Beneschan
2014-08-08 4:42 ` Laurent
2014-08-09 14:32 ` Laurent
2014-08-09 14:58 ` AdaMagica
2014-08-09 15:22 ` Jeffrey Carter
2014-08-09 18:51 ` Shark8
2014-08-09 21:53 ` Laurent
2014-08-09 22:25 ` Jeffrey Carter
2014-08-10 8:22 ` Simon Wright [this message]
2014-08-10 10:45 ` Simon Wright
2014-08-10 20:20 ` Laurent
2014-08-10 21:57 ` Simon Wright
2014-08-10 23:42 ` Jeffrey Carter
2014-08-11 4:51 ` Laurent
2014-08-11 5:13 ` Jeffrey Carter
2014-08-11 7:56 ` Laurent
2014-08-07 20:37 ` Shark8
2014-08-07 22:30 ` Laurent
2014-08-07 23:22 ` Shark8
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox