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,c7ea1cb7a2beb2ee X-Google-Attributes: gid103376,public From: "Robert I. Eachus" Subject: Re: Disallowing Pre-Defined Operations Date: 2000/04/09 Message-ID: <38F01A51.679F8E0E@earthlink.net>#1/1 X-Deja-AN: 608610391 Content-Transfer-Encoding: 7bit References: <8a9eeg$qtv$1@newpoisson.nosc.mil> <38D2E598.262D1CD5@erols.com> <8b0pbg$aph$1@nnrp1.deja.com> <38D9A2E8.F720768@erols.com> <8bcalg$pmb$1@nnrp1.deja.com> <38EBDD10.65444727@earthlink.net> <38EC160F.E2A13F44@quadruscorp.com> <8cic1h$195$1@nnrp1.deja.com> X-Accept-Language: en,pdf Content-Type: text/plain; charset=us-ascii X-Complaints-To: abuse@earthlink.net X-Trace: newsread2.prod.itd.earthlink.net 955259382 63.24.56.171 (Sat, 08 Apr 2000 22:49:42 PDT) Organization: The MITRE Corporation MIME-Version: 1.0 NNTP-Posting-Date: Sat, 08 Apr 2000 22:49:42 PDT Newsgroups: comp.lang.ada Date: 2000-04-09T00:00:00+00:00 List-Id: Robert Dewar wrote: > > Why does this need a language feature? This is the sort of thing > that is perfectly easy to program in Ada now. Sure you might > get a little bit more efficient implementation if it was built > in, but compilers could already do that by use of Intrinsic > conventions, I see no reason for a new language feature here. > > Does anyone have any experience with saturating numeric types > in existing Ada programs? Yes, and the non-standard integer type I suggested would neatly solve the problem. The two workarounds available are to overload the predefined "+" and "-", but now you have to have lots of rules to avoid paasing saturated values to generic operations, 'Pred and 'Succ, etc. The preferred alternative is to make the visible type private, and to overload monadic "+" and "-" as conversions for literals. This has its own disadvantages--including making numeric constants non-static.