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=-0.3 required=5.0 tests=BAYES_00, REPLYTO_WITHOUT_TO_CC autolearn=no 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-29 02:15:04 PST Path: archiver1.google.com!news1.google.com!newsfeed.stanford.edu!headwall.stanford.edu!fu-berlin.de!uni-berlin.de!dialin-145-254-039-049.arcor-ip.NET!not-for-mail From: "Dmitry A. Kazakov" Newsgroups: comp.lang.ada Subject: Re: Saturated Math Date: Thu, 29 May 2003 11:17:27 +0200 Organization: At home Message-ID: References: <3ECFF541.1010705@attbi.com> <3ED0B820.5050603@noplace.com> <3ED2096F.3020800@noplace.com> <3ED353BE.40605@noplace.com> <3ED4A323.3000909@noplace.com> Reply-To: mailbox@dmitry-kazakov.de NNTP-Posting-Host: dialin-145-254-039-049.arcor-ip.net (145.254.39.49) Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7Bit X-Trace: fu-berlin.de 1054199702 5897211 145.254.39.49 (16 [77047]) User-Agent: KNode/0.7.1 Xref: archiver1.google.com comp.lang.ada:37978 Date: 2003-05-29T11:17:27+02:00 List-Id: Robert A Duff wrote: > "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. Isn't it better to povide user defined conversions (and constructors), which then will deal with literals as well? -- Regards, Dmitry A. Kazakov www.dmitry-kazakov.de