From: dmitry6243@my-deja.com
Subject: Re: disjoint ranges ?
Date: 2000/10/18
Date: 2000-10-18T00:00:00+00:00 [thread overview]
Message-ID: <8sjloe$ad2$1@nnrp1.deja.com> (raw)
In-Reply-To: wccr95fobf6.fsf@world.std.com
In article <wccr95fobf6.fsf@world.std.com>,
Robert A Duff <bobduff@world.std.com> wrote:
> Lao Xiao Hai <laoxhai@ix.netcom.com> 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.
next prev parent reply other threads:[~2000-10-18 0:00 UTC|newest]
Thread overview: 32+ messages / expand[flat|nested] mbox.gz Atom feed top
2000-10-12 0:00 disjoint ranges ? Philippe Torres
2000-10-12 0:00 ` Pat Rogers
2000-10-12 0:00 ` Ehud Lamm
2000-10-12 0:00 ` Pat Rogers
2000-10-13 0:00 ` Ehud Lamm
2000-10-13 0:34 ` Jeff Carter
2000-10-13 0:00 ` Philippe Torres
2000-10-14 3:12 ` Robert Dewar
2000-10-16 0:00 ` Robert A Duff
2000-10-16 0:00 ` Lao Xiao Hai
2000-10-17 0:00 ` Robert A Duff
2000-10-17 0:00 ` Lao Xiao Hai
2000-10-18 0:00 ` dmitry6243 [this message]
2000-10-18 0:00 ` Robert Dewar
2000-10-18 0:00 ` Robert A Duff
2000-10-19 3:08 ` Overloading "in" (was: disjoint ranges ?) Jeff Carter
2000-10-19 0:00 ` Ehud Lamm
2000-10-21 0:00 ` Robert Dewar
2000-10-21 0:00 ` Jeff Carter
2000-10-16 0:00 ` disjoint ranges ? Robert Dewar
2000-10-13 0:00 ` Marin David Condic
2000-10-14 3:14 ` Robert Dewar
2000-10-13 0:00 ` Philippe Torres
2000-10-13 0:00 ` wayne lydecker
2000-10-13 0:00 ` wayne lydecker
2000-10-13 0:00 ` Lao Xiao Hai
2000-10-23 0:00 ` Charles Hixson
2000-10-24 0:00 ` dmitry6243
2000-10-13 0:00 ` Lao Xiao Hai
2000-10-14 3:17 ` Robert Dewar
2000-10-16 0:00 ` Robert A Duff
2000-10-24 0:00 ` Andrew Cooke
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox