comp.lang.ada
 help / color / mirror / Atom feed
From: Tucker Taft <stt@averstar.com>
Subject: Re: use of attribute Pos
Date: 2000/10/12
Date: 2000-10-12T16:50:53+00:00	[thread overview]
Message-ID: <39E5EBED.170B7E46@averstar.com> (raw)
In-Reply-To: gNlF5.7$bz5.13225@nnrp3.sbc.net

Pat Rogers wrote:
> 
> "Philippe Torres" <ptorres@laas.fr> wrote in message
> news:39E5DE79.F61616EC@laas.fr...
> > Pat Rogers wrote:
> > >
> > > "Philippe Torres" <ptorres@laas.fr> wrote in message
> > > > 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 ?
> > >
> > > Now things get a little bit more involved.  :-)   The terminology
> > > invariably confuses people, so I won't be precise in that regard.
> > > Let's just say that what you really have here is a subtype of a
> type
> > > derived from Character.  Since it has a distinct name (Upper) it
> is a
> > > distinct type, but it is still a constraint on Character.
> > >
> > > Hope that helps, as opposed to making it worse!  :-)
> > >
> >
> > OK but to me it would have been more logical to have the attribute
> Pos
> > reflecting exactly the position of the element in the range of the
> type
> > which has been "ticked".
> > Anyway thanks for your help but it's a bit misleading for a newbie
> like
> > me to guess which are the attributes "overloaded" by a subtype or a
> > derived type and which are merely "inherited such as" from the base
> > type.
> 
> Instead of
> 
>     type Upper is new Character range 'A'..'Z' ;
> 
> imagine you wrote it this way:
> 
>     type Anonymous is new Character;
>     subtype Upper is Anonymous range 'A' .. 'Z';
> 
> That's effectively what you've got.   Anonymous'Pos('A') would be 65,
> and thus so is Upper'Pos('A')

You can actually get at this "underlying" unconstrained
(sub)type, by using the 'Base attribute.

Hence, Upper'Base'First equals nul.

Some attributes are type-related, and others are
subtype-specific.  'First and 'Last are subtype-specific,
whereas 'Pos, 'Image, (and all the attributes that are
functions) are type-related.

> 
> Better?
> 
> ---
> Patrick Rogers                      Consulting and Training in:
> http://www.classwide.com      Deadline Schedulability Analysis
> progers@classwide.com        Software Fault Tolerance
> (281)648-3165                       Real-Time/OO Languages

-- 
-Tucker Taft   stt@averstar.com   http://www.averstar.com/~stt/
Technical Director, Commercial Division, AverStar (formerly Intermetrics)
(http://www.averstar.com/services/IT_consulting.html)  Burlington, MA  USA




  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
     [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
2000-10-11  0:00 ` Pat Rogers
2000-10-12  0:00   ` Philippe Torres
2000-10-12  0:00     ` Pat Rogers
2000-10-12  0:00       ` Philippe Torres
2000-10-12  0:00         ` mark.biggar
2000-10-12  0:00         ` Pat Rogers
2000-10-12  0:00           ` Tucker Taft [this message]
2000-10-12  0:00             ` Philippe Torres
2000-10-12  0:00               ` Ehud Lamm
2000-10-12  0:00             ` Ehud Lamm
2000-10-12  0:00               ` Philippe Torres
2000-10-12  0:00               ` Pat Rogers
2000-10-12  0:00     ` Robert A Duff
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox