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,685d80ec307a0c X-Google-Attributes: gid103376,public From: mark.biggar@trustedsyslabs.com Subject: Re: use of attribute Pos Date: 2000/10/12 Message-ID: <8s4ouu$m5s$1@nnrp1.deja.com>#1/1 X-Deja-AN: 680625472 References: <39E4A08D.B454CB1C@laas.fr> <39E583F7.A971C8DB@laas.fr> <5DiF5.1987$tN5.213230@nnrp2.sbc.net> <39E5DE79.F61616EC@laas.fr> X-Http-Proxy: HTTP/1.1 sji-ca-cache[0A000001] (Traffic-Server/2.2 [uScMs f p eN:t cSMi p s ]), 1.0 x72.deja.com:80 (Squid/1.1.22) for client 165.236.189.200 Organization: Deja.com - Before you buy. X-Article-Creation-Date: Thu Oct 12 16:30:21 2000 GMT X-MyDeja-Info: XMYDJUIDmark_biggar Newsgroups: comp.lang.ada X-Http-User-Agent: Mozilla/4.75 [en] (Win98; U) Date: 2000-10-12T00:00:00+00:00 List-Id: In article <39E5DE79.F61616EC@laas.fr>, Philippe Torres wrote: > Pat Rogers wrote: > > > > "Philippe Torres" 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. Except thast it is reflecting the type being ticked. In Ada there are no named types; only subtypes have names. So the type declaration: type upper is new character range 'A'..'Z'; is really equavalent to: type is new character; subtype upper is range 'A'..'Z'; so the real underlying type looks just like the type character and thus upper'pos('A') is still 65. Note that the underlying type can be exposed using upper'base which look jsut like character. If you really wanted a type that worked the way you expected then you must declare a completely new character type like: type upper is ('A','B','C', ... ,'Z'); but now there is no relationship at all between character'('A') and upper'('A'), just like ther is no real realtion between two emumeration type values from different emumeration types that just happen to share the same identifer. -- mark.biggar@trustedsyslabs.com Sent via Deja.com http://www.deja.com/ Before you buy.