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 13:06:19 PST Path: archiver1.google.com!news1.google.com!newsfeed.stanford.edu!lnsnews.lns.cornell.edu!news.litech.org!news-spur1.maxwell.syr.edu!news.maxwell.syr.edu!newsfeed.icl.net!newsfeed.fjserv.net!newshosting.com!news-xfer1.atl.newshosting.com!uunet!dca.uu.net!ash.uu.net!nntp.TheWorld.com!not-for-mail From: Robert A Duff Newsgroups: comp.lang.ada Subject: Re: Saturated Math Date: 28 May 2003 16:06:15 -0400 Organization: The World Public Access UNIX, Brookline, MA Message-ID: References: <3ECFF541.1010705@attbi.com> <3ED0B820.5050603@noplace.com> <3ED2096F.3020800@noplace.com> <3ED353BE.40605@noplace.com> <3ED4A323.3000909@noplace.com> NNTP-Posting-Host: shell01.theworld.com Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: pcls4.std.com 1054152375 6135 199.172.62.241 (28 May 2003 20:06:15 GMT) X-Complaints-To: abuse@TheWorld.com NNTP-Posting-Date: Wed, 28 May 2003 20:06:15 +0000 (UTC) User-Agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.2 Xref: archiver1.google.com comp.lang.ada:37942 Date: 2003-05-28T16:06:15-04:00 List-Id: "Randy Brukardt" writes: > Something like: > > package Saturation is > type Saturated_Integer is private; > for Saturated_Integer'Literal use Convert; > function Convert (Value : in Root_Integer) return > Saturated_Integer; > > function "+" (Left, Right : Saturated_Integer) return > Saturated_Integer; > -- etc. > end Saturation; > > The idea being that when a literal occurs, the compiler wraps it into a > call to Convert. You can sort of do this with unary "+", but it's > annoying to always have to write "+" (and you also don't have a named > "Root_Integer" type to use, so you have to use some other Integer type > to get the proper range). > > There hasn't been much interest in this idea (or the related > redefinition of array indexing), so don't hold your breath waiting for > it. I've always thought this sort of thing was a good idea. But I think the 'Literal attribute should take a String. That's what a literal is -- a string in the source code, which the compiler converts into a value. The goal is to give the user a hook to control that conversion. A good compiler could run Convert at compile time in most cases. - Bob