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-Thread: a07f3367d7,3ef3e78eacf6f938 X-Google-Attributes: gida07f3367d7,public,usenet X-Google-NewGroupId: yes X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news2.google.com!news2.google.com!npeer02.iad.highwinds-media.com!news.highwinds-media.com!feed-me.highwinds-media.com!news.glorb.com!news2.glorb.com!feeder.eternal-september.org!eternal-september.org!aioe.org!not-for-mail From: Cesar Rabak Newsgroups: comp.lang.eiffel,comp.lang.ada Subject: Re: Alternatives to C: ObjectPascal, Eiffel, Ada or Modula-3? Date: Mon, 20 Jul 2009 16:55:19 -0300 Organization: Aioe.org NNTP Server Message-ID: References: <4a64c41c$0$32673$9b4e6d93@newsspool2.arcor-online.net> NNTP-Posting-Host: CypMocAmQgU7ZoH9HGMqRg.user.aioe.org Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Complaints-To: abuse@aioe.org X-Antivirus-Status: Clean X-Notice: Filtered by postfilter v. 0.7.9 X-Antivirus: avast! (VPS 090513-0, 13/05/2009), Outbound message Cancel-Lock: sha1:4NO5PqIRijL1jf3c+HgZTY5pOnk= User-Agent: Thunderbird 2.0.0.22 (Windows/20090605) Xref: g2news2.google.com comp.lang.eiffel:340 comp.lang.ada:7191 Date: 2009-07-20T16:55:19-03:00 List-Id: Georg Bauhaus escreveu: > Cesar Rabak schrieb: > >>> procedure >>> Syntactic_Overloading_Example_Based_On_An_Example_By_Bertrand_Meyer is >>> type Horizontal_Coordinate is new Float; >>> type Vertical_Coordinate is new Float; >>> procedure Point(X : Horizontal_Coordinate; Y : Vertical_Coordinate) is >>> begin >>> null; --Whatever. >>> end; >> Here you create two "subtypes" which are only nicknames for Float in >> order to help the Ada compiler to discriminate the signature. BTW, why >> the need of two subtypes for coordinates? > > Horizontal_Coordinate and Vertical_Coordinate are specifically > *not* nicknames, not even informally. > Two new types derived from the same ancestor are definitely > *not* only nicknames for Float. I see you are trying to > come up with an argument about the same literals providing > values for objects of entirely different types, and that's > certainly formally true and a nice try. Yes, formally it is my gripe. Remember this is not a thread is running in Ada NG only, so recursing to Ada _terminology_ does not add to discourse here. > But if you defer to > the programmers, I will, too, and suggest > > X := Vertical_Coordinate'(1.1); > > so as to say what they mean. Et voila, > > 21. X := Vertical_Coordinate'(1.1); > | > >>> expected type "Horizontal_Coordinate" defined at line 2 > >>> found type "Vertical_Coordinate" defined at line 3 Still, a pretense feeling of safety as the programmer had to work very hard to allow the compiler find the 'error'. > > > I'm sure Gloucester will speak for himself, but it's tempting > to step in. > > (Nitpick: he is introducing two new distinct types, > not subtypes as an Ada subtype is a type with a constraint > as in subset of values that are in the type). I comment this on other post. > > Every one of the tricks you play below in your example > assigns values of literals of anonymous predefined type > 'universal_real' to objects of distinct types. There > is certainly an issue with literals not being silver > bullets. Yes, some programmers do not define typed > constants of important values. Yes, they are not even > using C's untyped #define, they just sprinkle literals. I'm not playing tricks, just showing something may appear unnoticed if not debated. Although the example has been on literals, I've noticed the bulk of problems happen when data is read from the outside of the program (file reading, GUI fields, etc.). > > >> Careful reading of this line of code shows the 'protection' against >> mistakes occurs only after the 'subtype' has been initialized, but this: >> >> X := 3.3; -- for the sake of argument programmer >> Y := 0.5; -- wrote the GUI code backwards >> R := 1.1; >> Theta := 2.2; >> Point(X, Y); >> Point(R, Theta); >> >> Happy compiler and code runs, albeit with unexpected results... > > Well, there is no way to write full application programs in > type systems(*). But what's your point? If we add rigor to your > argument then we might just as well have but one type and make > the compilers even happier with that universal type... > > > (*) except Qi's, I should think. I avoided mentioning because this would open even more the discussion, but the OP could do its own research. Yes your assertion goes in the Lisp direction, which for numerics could even be more interesting as numbers are stored in a more accurate way (if you avoid 'premature optimization' syndrome ;-)