From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00 autolearn=unavailable autolearn_force=no version=3.4.4 Path: eternal-september.org!reader01.eternal-september.org!reader02.eternal-september.org!news.eternal-september.org!news.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail From: Simon Wright Newsgroups: comp.lang.ada Subject: Re: Problem with generic linked list package Date: Sun, 10 Aug 2014 09:22:53 +0100 Organization: A noiseless patient Spider Message-ID: References: <85a97spo1c.fsf@stephe-leake.org> <92dd7d22-a7da-44d7-9c40-b3aa62881683@googlegroups.com> <4f431041-5292-434d-988e-46d69f4800f8@googlegroups.com> <472a5732-3dc9-4c08-8bda-00720375a2a9@googlegroups.com> <8cc86d41-2c7e-42d7-b057-1f9f010d9002@googlegroups.com> <75864d79-609c-4e37-98d8-6b5f050ad59d@googlegroups.com> <42e0f58b-63c4-4a08-90ce-b5ddf7ebe95b@googlegroups.com> Mime-Version: 1.0 Content-Type: text/plain Injection-Info: mx05.eternal-september.org; posting-host="b814ca014269fd1fa21bc4c05b94dd9e"; logging-data="8448"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+fJI9dATkHVCO72DXOrnN8E21TSomugYc=" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3 (darwin) Cancel-Lock: sha1:OUvRr+cs4YknGEJLG9TI2gAQNn0= sha1:B1h6VYnDI1+PZITWbVVS/WfgSII= Xref: news.eternal-september.org comp.lang.ada:21638 Date: 2014-08-10T09:22:53+01:00 List-Id: Laurent 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.