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-16 01:43:04 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: Fri, 16 Jan 2004 10:49:57 +0100 Message-ID: <2ucf009c1gl5rchk3avag0n9uecohff54d@4ax.com> References: <75ga001eokc2r1aijtvu9d70ck3i6j1p0m@4ax.com> <629d00tlqvu326hi1vsomlmnvkobvbc0bl@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 1074246182 15440659 212.79.194.116 ([77047]) X-Newsreader: Forte Agent 1.8/32.548 Xref: archiver1.google.com comp.lang.ada:4456 Date: 2004-01-16T10:49:57+01:00 List-Id: On Thu, 15 Jan 2004 17:22:33 +0100, Mats Weber wrote: >In article <629d00tlqvu326hi1vsomlmnvkobvbc0bl@4ax.com>, > Dmitry A. Kazakov wrote: > >>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 > >I think not, because with maps, you have to be able to extract an item >given its key, which you cannot do with Generic_Sets as there is no key >type. Following is the function that does that in my package: > > function Search (Key : Key_Type; Within : Bag) return Item_Type; > -- Returns the first item in FROM that has a key equal to KEY. > -- NONEXISTENT_KEY will be raised if no such item is > -- found in the bag. Mmm, one could use: function Is_In (Container : Map; Element : Object_Type) return Boolean; Actually here comes the motivation for maps from. I encountered that it is too expensive in some cases to create a new object to be used in Is_In. For example, when object is a handle to something large. So I decided to make maps with keys completely separated from objects. Your variant is somewhere in between, it is rather set than map. BTW, I didn't care that String could not be used as a key, because I had generic tables to deal with that [http://www.dmitry-kazakov.de/ada/tables.htm] and I saw no other interesting cases of unconstrained keys. ----------------- Some time ago I posted a proposal for proper constructors, assignments, limited types initialization: http://groups.google.com/groups?hl=en&lr=lang_en|lang_de|lang_ru&ie=UTF-8&selm=au9fm2%245kta0%241%40ID-77047.news.dfncis.de&rnum=1 That could help to solve the problem of creating unconstrained objects from unconstrained generic parameters (with some extensions of discriminants). Something like this: generic type Key_Type (<>) is private; ... package Foo is type Token (Constraints : Key_Type'Constraint) is record Key : Key_Type (Constraints); ... end record; Here Key_Type'Constraint denotes an anonymous null-record type having exactly same discriminants / bounds as Key_Type. Using this type as a discriminant for Token one could constrain the Key component. Interestingly, it seems that this would also allow to copy limited unconstrained objects without having assignment. But I see no harm in that. -- Regards, Dmitry A. Kazakov www.dmitry-kazakov.de