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-03 04:34:37 PST Path: archiver1.google.com!news1.google.com!newsfeed.stanford.edu!news-spur1.maxwell.syr.edu!news.maxwell.syr.edu!newsfeed.icl.net!newsfeed.fjserv.net!skynet.be!skynet.be!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: Mon, 03 Feb 2003 13:34:33 +0100 Message-ID: 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> 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 1044275675 38326754 212.79.194.111 (16 [77047]) X-Newsreader: Forte Agent 1.8/32.548 Xref: archiver1.google.com comp.lang.ada:33718 Date: 2003-02-03T13:34:33+01:00 List-Id: On Mon, 3 Feb 2003 23:04:39 -0800, "AG" wrote: >"Dmitry A. Kazakov" wrote in message >news:h96l3vsrtf76akihqdu61r9edeav442eig@4ax.com... >> On Fri, 31 Jan 2003 10:02:15 -0500, Hyman Rosen >> wrote: > >> >Why? Since you're converting, what possible relevance is there >> >to requiring that the operation be present in both types? >> >> I do not want flawed implicit type conversions. I want sub- and >> supertyping. If an implementation of sub-/supertyping is based on some >> conversions, I do not care. >> >> >> Ada does this. >> > >> >Really? It does convert-in/convert-out of different types? >> >I've never seen that before. Can you show me sample code? >> >> procedure Query (X : in out Float); >> -- The initial value is used as a default >> ... >> I : Integer := 10; >> begin >> Query (Float (I)); > >A bit of an unfortunate example that. A quick twiddle of the code >produced this: > >with ada.text_io; > >procedure tes is > >procedure Query (X : in out Float) is > >begin > >x := x - 0.5; > >end; > >I : Integer := 10; > >begin > >Query (Float (I)); > >ada.text_io.put_line(integer'image(i)); > >end; > >The output is "10" of course which isn't surprising >but seems to sort of contradict the example's purpose. >Not much point in having a conversion like that ... The purpose of the example was only to show that Ada indeed have convert-copy-in-copy-out-convert. 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. 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