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=ham autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,94f331aa4ac6827f X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2004-01-15 06:57:28 PST Path: archiver1.google.com!news2.google.com!fu-berlin.de!uni-berlin.de!tar-atanamir.cbb-automation.DE!not-for-mail From: Dmitry A. Kazakov Newsgroups: comp.lang.ada Subject: Re: ANN: Simple components v 1.3 Date: Thu, 15 Jan 2004 16:04:18 +0100 Message-ID: <629d00tlqvu326hi1vsomlmnvkobvbc0bl@4ax.com> References: <75ga001eokc2r1aijtvu9d70ck3i6j1p0m@4ax.com> NNTP-Posting-Host: tar-atanamir.cbb-automation.de (212.79.194.116) Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Trace: news.uni-berlin.de 1074178647 15228805 212.79.194.116 ([77047]) X-Newsreader: Forte Agent 1.8/32.548 Xref: archiver1.google.com comp.lang.ada:4437 Date: 2004-01-15T16:04:18+01:00 List-Id: On Thu, 15 Jan 2004 15:01:05 +0100, Mats Weber wrote: >In article <75ga001eokc2r1aijtvu9d70ck3i6j1p0m@4ax.com>, > Dmitry A. Kazakov wrote: > >>>> This release includes generic maps (associative arrays) > >>http://www.dmitry-kazakov.de/ada/components.htm > >I have been working on this (generic maps) for quite a while (and a long >time ago). What I came up with is that the generic formal key type must >be limited private and unconstrained (<>) for the component to be >useable in most situations. > >Here is the generic formal part of my version of maps: > >generic > type Key_Type (<>) is limited private; > type Item_Type is private; > with function Key_Of (Item : in Item_Type) return Key_Type; > with function "=" (X, Y : Key_Type) return Boolean is <>; > with function "<" (X, Y : Key_Type) return Boolean is <>; > type Count is range <>; -- must include 0 >package Bags is > ... > >The big differences is that there is no constraint on Key_Type and that >the key is part of each item and is extracted from it with the generic >formal function Key_Of. > >For instance, you can have Key_Type => String, with the above, which you >cannot do with your version. Isn't it same as to have just set rather than map? I have Generic_Set: generic type Object_Type is private; Null_Element : Object_Type; ... with function "<" (Left, Right : Object_Type) return Boolean is <>; with function "=" (Left, Right : Object_Type) return Boolean is <>; package Generic_Set is Here elements are comparable without mentioning any key type. I have added Generic_Map only after realizing that sometimes it is necessary to have different ordering strategies for the same object type and that the key is not always deducible from the object it points to. -- Regards, Dmitry A. Kazakov www.dmitry-kazakov.de