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.3 required=5.0 tests=BAYES_00,INVALID_MSGID, MSGID_RANDY autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,8276b2994037cd71 X-Google-Attributes: gid103376,public From: dmitry6243@my-deja.com Subject: Re: disjoint ranges ? Date: 2000/10/18 Message-ID: <8sjloe$ad2$1@nnrp1.deja.com>#1/1 X-Deja-AN: 682771192 References: <39E612C9.9BF98CD3@laas.fr> <8s59nu$ej4$1@news.huji.ac.il> <39E658A4.525AE881@acm.org> <39E6E890.3B13E7A9@laas.fr> <8s8iuk$q66$1@nnrp1.deja.com> <39EBB984.F2F8905F@ix.netcom.com> X-Http-Proxy: 1.0 x53.deja.com:80 (Squid/1.1.22) for client 212.79.192.251 Organization: Deja.com - Before you buy. X-Article-Creation-Date: Wed Oct 18 08:07:45 2000 GMT X-MyDeja-Info: XMYDJUIDdmitry6243 Newsgroups: comp.lang.ada X-Http-User-Agent: Mozilla/4.73 [en] (WinNT; U) Date: 2000-10-18T00:00:00+00:00 List-Id: In article , Robert A Duff wrote: > Lao Xiao Hai writes: > > > So, making a feature more powerful might be something such as being > > able to overload the "in" membership test. > > It might be in the abstract, but in the context of Ada, probably not. > > >... For some reason, this > > operator is not really a first class operator in Ada. I have often > > wondered about the rationale for that decision. > > What is the type of the right-hand side of "in" here: > > if X in Integer range 1..10 ... > > ? Ada has no way of describing that type. In order to make "in" a > normal operator, we would need to invent a way to pass types as > parameters, and talk about the type of a type (and subtypes). This is > not entirely unreasonable in the abstract, but it would be an enormous > change to Ada. > > Consider: > > type T is range 1..100; > function "in"(X: T; Y: type-of-T?) return Boolean; > > Or maybe it should be T'in? Anyway, it raises all kinds of questions. > What *is* the range of T (given that "in" changes it)? IMO, to make it consistent one should introduce built-in index types (or better to say, make them visible). Compare: type A is array (Integer range 1..100) of ...; and type B is index (Integer range 1..100); Array slice is a subarray. Index slice is a range. Array indexed by a value of its index type is a subarray. Then type T is range 1..100; type T_Index is index (T); function "in" (X: T; Y: T_Index) return Boolean; Surely indices can be multi-dimensional: type Square_Index is index (Integer range 1..100, Integer 1..100); Surely one needs an attribute to get an anonymous index type from array. Ada already has it! It is 'range. Unfortunately 'range = 'range(1) for multi-dimensional arrays. Static values of index types can used where ellipsis ".." appear. Actually "range N..M" is a literal of an anonymous index type (or maybe, of universal index type). -- Regards, Dmitry Kazakov Sent via Deja.com http://www.deja.com/ Before you buy.