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,b6e97963d32ee242 X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2003-05-21 11:21:24 PST Path: archiver1.google.com!news1.google.com!newsfeed.stanford.edu!logbridge.uoregon.edu!news.tele.dk!news.tele.dk!small.news.tele.dk!newsfeed1.e.nsc.no!nsc.no!nextra.com!uio.no!ntnu.no!not-for-mail From: Preben Randhol Newsgroups: comp.lang.ada Subject: Re: The old "Object.Method" syntax debate Date: Wed, 21 May 2003 18:21:23 +0000 (UTC) Organization: Norwegian university of science and technology Message-ID: References: <254c16a.0305210726.485125de@posting.google.com> <3ECBA778.4070909@crs4.it> NNTP-Posting-Host: kiuk0152.chembio.ntnu.no X-Trace: tyfon.itea.ntnu.no 1053541283 16422 129.241.83.78 (21 May 2003 18:21:23 GMT) X-Complaints-To: usenet@itea.ntnu.no NNTP-Posting-Date: Wed, 21 May 2003 18:21:23 +0000 (UTC) User-Agent: slrn/0.9.7.4 (Linux) Xref: archiver1.google.com comp.lang.ada:37607 Date: 2003-05-21T18:21:23+00:00 List-Id: David C. Hoos wrote: > > It would not make the language ambiguous. Since Him and Her > are objects of different types, each type would need its own > version of the Marry procedure, unless they were both derived > from a common ancestor type which had a class-wide Marry > procedure. No I mean when you read it. Look at the example from the AI: Here is an example of use of the "object.operation" syntax: package P is type T is tagged ... -- implicit declaration of T'Class procedure Prim(X : in out T); procedure Classwide(X : in out T'Class; Y : Integer); end P; with P; package P2 is type T2 is new P.T with ... -- implicit declaration of T2'Class -- implicit declaration of Prim(X : in out T2); procedure Prim2(X : in out T2; B : Boolean); function Prim3(X : T2) return Float; end P2; with P2; procedure Main is Obj : P2.T2; CObj : P2.T2'Class := ... begin Obj.Prim; -- call on inherited primitive Obj.Prim2(True); -- call on primitive CObj.Prim; -- dispatching call Here I get confused, because looking at package P the procedures available are: Prim(X : in out T); and Classwide(X : in out T'Class; Y : Integer); There is no Prim; procedure So the student will wonder why do I have to define : procedure Prim(X : in out T); and not only procedure Prim; ? (Yes I know why, but if the point is to mimic C++ and other OOP languages syntax this will confuse) >From the AI: Identifying both the package and the object is to some extent redundant, and makes object-oriented programming in Ada 95 wordier than necessary, and/or encourages heavy use of potentially confusing "use" clauses. Eliminating this redundancy would make object-oriented programming less-error prone, while also clarifying what object is the controlling object. The last part : "..., while also clarifying what object is the controlling object." I do not get. how come I cannot do: procedure Main is True_Or_Not : Boolean; Object : P2.T2; begin True_Or_Not.Prim2 (Object); (I see that B is not defined in out, but if it were) Besides if one can mix between using the old syntax and the new type-dot-procedure syntax in the source, wouldn't that lead to quite hard to read code? IMHO this is messy, confusing and I neither see the motivation nor need for it, but I guess I have gotten used to the Ada way :-) Perhaps somebody else can show my why this is a Good Idea[tm] Preben -- "... in Ada, you can never have a buffer overflow error. Unless of course you go very far out of your way to specifically program one [...] most Ada programmers would consider going out of your way to construct an Ada program that had a potential buffer overflow not as a challenge, but as a kind of pornography." - Robert I. Eachus