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,103b407e8b68350b X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2003-02-04 02:08:43 PST Path: archiver1.google.com!news1.google.com!newsfeed.stanford.edu!nntp.cs.ubc.ca!fu-berlin.de!uni-berlin.de!tar-alcarin.cbb-automation.DE!not-for-mail From: Dmitry A. Kazakov Newsgroups: comp.lang.ada Subject: Re: Anybody in US using ADA ? One silly idea.. Date: Tue, 04 Feb 2003 11:08:41 +0100 Message-ID: <2h3v3v4ioi4vu3a9d17c6manuedbnehoq1@4ax.com> References: <1043880843.44251@master.nyc.kbcfp.com> <1043938782.244443@master.nyc.kbcfp.com> <25ji3v8n915cnnnaqpjvm4f7i01a66r9pf@4ax.com> <1043949507.331484@master.nyc.kbcfp.com> <1044025336.3067@master.nyc.kbcfp.com> NNTP-Posting-Host: tar-alcarin.cbb-automation.de (212.79.194.111) Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Trace: fu-berlin.de 1044353322 36782410 212.79.194.111 (16 [77047]) X-Newsreader: Forte Agent 1.8/32.548 Xref: archiver1.google.com comp.lang.ada:33751 Date: 2003-02-04T11:08:41+01:00 List-Id: On Tue, 4 Feb 2003 20:38:41 -0800, "AG" wrote: >"Dmitry A. Kazakov" wrote in message >news:r4ns3vsbjo61opm62v8ugcogk4s96tiogs@4ax.com... > >> What your example shows is that in case of specialization (integers is >> a subset), one will always have potential problems with >> out-parameters. But technicaly there is no much difference between: >> >> subtype Positive is Float 0.0...Float'Last; >> >> and >> >> subtype Integer is Float with only whole values; -- Not Ada! >> >> In both cases there is no ideal way to define the backward conversion. > >Well, the difference between the two is that, in the first case, >you only introduce a scalar range restriction. That is, any valid >value of float in this range is also a valid value for positive if >derived in this way. This is not the case for the second definition >(and I suspect that's exactly the reason it's not Ada). > >The backward conversion in the first case only needs to check >the range and raise an exception or whatever handling is >appropiate if the final result is out of range (you can even ignore >intermediates - maybe). No other properties of the type are >involved so everything withing that range should be ok. > > In the second case, the backward conversion is pretty much >doomed unless you are using it in a very specialized case and >implementation that knows how to handle that. In which case >it becomes quite a bit more than a simple subtype since it >would have to have lots of additional logic about rounding, >redefining operations that no longer make sense etc etc. I did not mean here that Integer is Standard.Integer. I meant just a Float subtype called Integer (having Float representation as Ada requires), with the constraint imposed not by a range, but by requirement to be whole. In this case the backward conversion is as straightforward as range check, i.e. check if whole, if not, raise Constraint_Error. A similar example: type Day is (Su, Mo, Tu, We, Th, Fr, Sa); subtype Weekend is Day (Su, Sa); -- This also not Ada --- Regards, Dmitry Kazakov www.dmitry-kazakov.de