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,FREEMAIL_FROM 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-03 23:36:50 PST Path: archiver1.google.com!news1.google.com!newsfeed.stanford.edu!logbridge.uoregon.edu!arclight.uoregon.edu!enews.sgi.com!news.xtra.co.nz!53ab2750!not-for-mail From: "AG" Newsgroups: comp.lang.ada References: <1043855067.848326@master.nyc.kbcfp.com> <3OXZ9.85359$Ve4.6306@sccrnsc03> <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> Subject: Re: Anybody in US using ADA ? One silly idea.. X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2800.1106 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1106 Message-ID: Date: Tue, 4 Feb 2003 20:38:41 -0800 NNTP-Posting-Host: 219.88.62.12 X-Complaints-To: newsadmin@xtra.co.nz X-Trace: news.xtra.co.nz 1044344209 219.88.62.12 (Tue, 04 Feb 2003 20:36:49 NZDT) NNTP-Posting-Date: Tue, 04 Feb 2003 20:36:49 NZDT Organization: Xtra Xref: archiver1.google.com comp.lang.ada:33745 Date: 2003-02-04T20:38:41-08:00 List-Id: "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. > Sometimes raising Constraint_Error is OK. Sometimes rounding is > better. [For example, when coordinates of graphical objects have to be > mapped to pixels.] > > --- > Regards, > Dmitry Kazakov > www.dmitry-kazakov.de