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 autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,2afac1a4161c7f35 X-Google-Attributes: gid103376,public From: nobody@REPLAY.COM (Anonymous) Subject: Re: Distinguishing type names from other identifiers Date: 1998/01/15 Message-ID: <199801151530.QAA21301@basement.replay.com>#1/1 X-Deja-AN: 316217389 Content-Transfer-Encoding: 7bit References: Content-Type: text/plain; charset=us-ascii Organization: Replay Associates, L.L.P. Mail-To-News-Contact: postmaster@nym.alias.net X-001: Replay may or may not approve of the content of this posting X-002: Report misuse of this automated service to X-URL: http://www.replay.com/remailer/ Newsgroups: comp.lang.ada Date: 1998-01-15T00:00:00+00:00 List-Id: <199801121523.QAA06527@basement.replay.com> <01bd2078$a449b460$41fd82c1@xhv46.dial.pipex.com> On Tue, 13 Jan 1998 18:34:46 -0800, mheaney@ni.net (Matthew Heaney) wrote: > In article <01bd2078$a449b460$41fd82c1@xhv46.dial.pipex.com>, "Nick > Roberts" wrote: > > > > >For example: > > > > type Hour_Of_Day is range 0..23; > > type Minute_Of_Hour is range 0..59; > > type Seconds_Past_Minute is delta 0.001 range 0.000 .. 59.999; > > >Finally, I think the declaration of the fixed-point type > >Seconds_Past_Minute in the example raises another interesting question. > >Should I have used 59.999 for the upper bound, or 60.000? Is it a bad > >omission that Ada does not provide for both open and closed bounds? > > Do this if you really don't want 60.0 in the range: > > type Seconds_Past_Midnight_Base is > delta 0.001 range 0.0 .. 60.0; > > subtype Seconds_Past_Midnight is > Seconds_Past_Midnight range 0.0 .. Seconds_past_Midnight_Base'Succ (60.0); > > The idea is let the compiler figure out what the largest value is, by using > T'Succ. Declaring a subtype of a first named subtype is a technique few > programmers take advantage of. > > This is similar to the issue shops have declaring a heading type that > doesn't have the value 360.0 in the range. Do this for a floating point > type, if you really insist on not having 360.0 as a value: > > type Ownship_Heading_Base is digits 5; -- whatever the precision req'd > > subtype Ownship_Heading is > Ownship_Heading_Base range 0.0 .. Ownship_Heading_Base'Succ (360.0); > Surely you mean 'Pred, not 'Succ? OK, I'll stop calling you Shirley :) Jeff Carter PGP:1024/440FBE21 My real e-mail address: ( carter @ innocon . com ) "Perfidious English mouse-dropping hoarders." Monty Python & the Holy Grail Posted with Spam Hater - see http://www.compulink.co.uk/~net-services/spam/