From: Philippe Torres <ptorres@laas.fr>
Subject: Re: use of attribute Pos
Date: 2000/10/12
Date: 2000-10-12T09:27:18+00:00 [thread overview]
Message-ID: <39E583F7.A971C8DB@laas.fr> (raw)
In-Reply-To: kJ2F5.19$_H3.22643@nnrp1.sbc.net
Pat Rogers wrote:
>
> "Philippe Torres" <ptorres@laas.fr> wrote in message
> news:39E4A08D.B454CB1C@laas.fr...
> > Hi, do you think the following behaviour is normal ?
> > -----
> > subtype Upper is character range 'A'..'Z' ;
> > begin
> > Put(Upper'Pos('A')) ;
> > -----
> > Output : 65
> >
> > I was expecting 0 since 'A' is the first element of Upper but i got
> > the ranking of 'A' in the Character type.
> >
> > What's the point of defining constrained subtype if we can't use the
> > attributes on it ? Or am i missing something ?
>
> A subtype does not introduce a new type -- it names a constraint on an
> existing type. Understand that and all else follows.
>
> You can indeed use the attributes on the subtype, but you must
> recognize that only those attributes that represent *constraints* will
> be different than those of the actual type in question. Thus
> Upper'first will yield 'A', Upper'last will yield 'Z', and so on.
>
> Its all in the "names for constraints" concept...
>
OK. Thank you all for your answers.
I understand the behaviour on a subtype of "constraint" attributes are
the sole to change compared to the base class.
But now, i wonder why Alejandro's solution
----
type Upper is new Character range 'A'..'Z' ;
begin
Put(Upper'Pos('A')) ;
---
still manages to output 65 and not 0.
Since a different type is introduced, how does Pos still refer to
Character ?
Should not 'new' have broken all "links" between the types Character and
Upper ?
Philippe
next prev parent reply other threads:[~2000-10-12 0:00 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
2000-10-11 0:00 use of attribute Pos Philippe Torres
2000-10-11 0:00 ` Pat Rogers
2000-10-12 0:00 ` Philippe Torres [this message]
2000-10-12 0:00 ` Robert A Duff
2000-10-12 0:00 ` Pat Rogers
2000-10-12 0:00 ` Philippe Torres
2000-10-12 0:00 ` Pat Rogers
2000-10-12 0:00 ` Tucker Taft
2000-10-12 0:00 ` Ehud Lamm
2000-10-12 0:00 ` Pat Rogers
2000-10-12 0:00 ` Philippe Torres
2000-10-12 0:00 ` Philippe Torres
2000-10-12 0:00 ` Ehud Lamm
2000-10-12 0:00 ` mark.biggar
[not found] ` <39E4A637.AE6EE630@cepsz.unizar.es>
2000-10-11 0:00 ` Jerry Petrey
2000-10-14 3:32 ` Robert Dewar
2000-10-16 0:00 ` Alejandro Villanueva
2000-10-16 0:00 ` Ken Garlington
2000-10-18 0:00 ` Alejandro Villanueva
2000-10-16 0:00 ` Robert Dewar
2000-10-18 0:00 ` Alejandro Villanueva
2000-10-11 0:00 ` Jerry Petrey
2000-10-11 0:00 ` Ehud Lamm
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox