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!news3.google.com!proxad.net!feeder1-2.proxad.net!news.cs.univ-paris8.fr!gegeweb.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 15:33:33 -0300 Organization: Aioe.org NNTP Server Message-ID: References: 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:tjuDdWIgwYNZ0M/VJ48BHH/mVhA= User-Agent: Thunderbird 2.0.0.22 (Windows/20090605) Xref: g2news2.google.com comp.lang.eiffel:334 comp.lang.ada:7183 Date: 2009-07-20T15:33:33-03:00 List-Id: Nicholas Paul Collin Gloucester escreveu: [snipped] > > I give an example showing that Ada is better than Eiffel (and Modula-3 > and many versions of Pascal) in this regard, based on an example by > Bertrand Meyer in the second edition of the book "Object-oriented > software construction". In that book, Dr. Meyer claimed that Ada's > overloading is inferior to Eiffel's overloading. He called Ada's > overloading syntactic overloading. He called Eiffel's overloading > semantic overloading. I believe that he was being sincere, but he was > definitely mistaken. He claimed that it would not be possible to > sensibly discriminate between overloaded subprograms for a point if > the real-number parameters could be in any of Cartesian notation and > polar notation. > > This is refuted by the following Ada code... > Not it's not, your code only changed the problem appearance but not substance: > 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? > > type Magnitude is new Float; > type Radians is new Float range -3.14*2.0 .. 3.14*2.0; > procedure Point(R : Magnitude; Theta : Radians) is Ditto with two more "subtypes", and for no reason creating a new mess as you made a design decision that Radians can only go from -6.28 to +6.28, so you leave to the poor programmers that shall use this code the task of normalizing the angles before creating points else runtime exceptions? > begin > null; --Whatever. > end; > > X : Horizontal_Coordinate; > Y : Vertical_Coordinate; > R : Magnitude; > Theta : Radians; > begin > X := 1.1; > Y := 2.2; > R := 3.3; > Theta := 0.5; > Point(X, Y); > Point(R, Theta); > > --The above is all legal Ada. However, the following mistakes would > --be legal in Eiffel but would be rejected by an Ada compiler... > > R := X; 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... -- Cesar Rabak PS.: for some reason could not set the Followup-To so I trimmed to the pertaining language NGs.