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.9 required=5.0 tests=BAYES_00 autolearn=ham autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,583275b6950bf4e6 X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2003-05-28 02:15:00 PST Path: archiver1.google.com!news1.google.com!newsfeed.stanford.edu!cyclone.bc.net!skynet.be!skynet.be!fu-berlin.de!uni-berlin.de!213.200.246.247!not-for-mail From: Vinzent Hoefler Newsgroups: comp.lang.ada Subject: Re: Quality systems (Was: Using Ada for device drivers? (Was: the Ada mandate, and why it collapsed and died)) Date: Wed, 28 May 2003 11:13:46 +0200 Organization: JeLlyFish software Message-ID: References: <3ECFF541.1010705@attbi.com> <3ED0B820.5050603@noplace.com> <3ED2096F.3020800@noplace.com> <3ED353BE.40605@noplace.com> NNTP-Posting-Host: 213.200.246.247 Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: quoted-printable X-Trace: fu-berlin.de 1054113299 4834478 213.200.246.247 (16 [175126]) X-Newsreader: Forte Agent 1.8/32.548 Xref: archiver1.google.com comp.lang.ada:37883 Date: 2003-05-28T11:13:46+02:00 List-Id: Marin David Condic wrote: >Pretty simple stuff. Suppose you had a type like: > >type Saturated_Integer is range -10..10 ; Well, yes this could be a nice feature but personally I think, this would cause too many problems. >and an object of that type such as: > >X : Saturated_Integer :=3D 9 ; > >and then: > >X :=3D X + 4 ; > >would mean: > >(X =3D 10) Suppose you have an expression like: X :=3D X + 4 - 4; (Those fours might not be actual constants) What would be the result then? 6 if the expression is evaluated left-to-right or 9 if "4 - 4" is evaluated first and then applied to X? >I don't know of any hardware that would do this for either floating=20 >point or integer numbers, Well, at least Intels MMX has something similar, but of course it only saturates to 16#7FFF...# for signed and 16#FFFF...# for unsigned math. >so I'd suspect it would not be practical to do=20 >anything but implement it in software. Yes. IMO is has too many bad implications like effects on dependcy with expression evaluation order. >You'd probably want to do=20 >whatever it is you do to check for an overflow on a subtype, but instead= =20 >of raising an exception, you plug it with the max value and continue to = run. I think the easy(?) way would be a generic package supplying such sort of types like this: |generic | type Item is range <>; |package Saturated_Integer is | function "+" (I : Item; Amount : Item) return Item; | function "-" (I : Item; Amount : Item) return Item; |end Saturated_Integer; Well, I have a problem in successfully overloading the standard integer operations here... How do I do that? My understanding of generics is still quite vague. >Still, it seems like a useful feature for some kinds of jobs. Well, yes. But it's not an Ada-like feature, is it? Vinzent. --=20 Parents strongly cautioned -- this posting is intended for mature audiences over 18. It may contain some material that many parents would not find suitable for children and may include intense violence, sexual situations, coarse language and suggestive dialogue.