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 04:53:09 PST Path: archiver1.google.com!news1.google.com!sn-xit-02!sn-xit-06!sn-xit-08!supernews.com!newsfeed1.earthlink.net!newsfeed.earthlink.net!stamper.news.pas.earthlink.net!stamper.news.atl.earthlink.net!harp.news.atl.earthlink.net!not-for-mail From: Marin David Condic Newsgroups: comp.lang.ada Subject: Saturated Math (was: Re: Quality systems (Was: Using Ada for device drivers? (Was: the Ada mandate, and why it collapsed and died)) Date: Wed, 28 May 2003 07:53:07 -0400 Organization: MindSpring Enterprises Message-ID: <3ED4A323.3000909@noplace.com> References: <3ECFF541.1010705@attbi.com> <3ED0B820.5050603@noplace.com> <3ED2096F.3020800@noplace.com> <3ED353BE.40605@noplace.com> NNTP-Posting-Host: d1.56.b4.6e Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit X-Server-Date: 28 May 2003 11:53:09 GMT User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.0.1) Gecko/20020823 Netscape/7.0 (OEM-HPQ-PRS1C03) X-Accept-Language: en-us, en Xref: archiver1.google.com comp.lang.ada:37898 Date: 2003-05-28T11:53:09+00:00 List-Id: Vinzent Hoefler wrote: > > Suppose you have an expression like: > > X := X + 4 - 4; > > (Those fours might not be actual constants) > > What would be the result then? > Imagine it was a garden variety integer with the same range. What does the ARM say it would do? What if it were a modular type with wraparound semantics? What does the ARM say it would do? My suggestion would be that we look for the pages that define behavior on numeric types, copy them, change the type names to something indicating "Saturated" and wherever the ARM says "raise an exception" insert "saturate in the direction of the limit exceedence." > > > Yes. IMO is has too many bad implications like effects on dependcy > with expression evaluation order. > No more so than you already have for the type Integer or Float or any other type. You're merely expressing a different accommodation for bounds exceedence. > > 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. > We've cobbled together solutions like this in the past. It isn't impossible to go invent your own home-grown type and come up with operations that do what you want. The real issue is that it would just work so much better and easier if it was a directly supported feature of the language and well integrated with all the rest of Ada. > >>Still, it seems like a useful feature for some kinds of jobs. > > > Well, yes. But it's not an Ada-like feature, is it? > How is it any less Ada-like than any other numeric type? I think one of the big advantages to Ada is that it provides a *wealth* of type capabilities so you can pick whatever type best fits the needs of the problem space. This would be adding a set of types that provide different behavior that is desirable in some situations. (Compare it to C where they say "here's your int and float and if you can't do it with that, go pound sand..." This would be very Ada-esque) MDC -- ====================================================================== Marin David Condic I work for: http://www.belcan.com/ My project is: http://www.jast.mil/ Send Replies To: m c o n d i c @ a c m . o r g "In general the art of government consists in taking as much money as possible from one class of citizens to give to the other." -- Voltaire ======================================================================