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-Thread: 103376,3a0f9dd5cb8ed3b6,start X-Google-Attributes: gid103376,public X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news1.google.com!postnews1.google.com!not-for-mail From: jonas.nygren@telia.com (jn) Newsgroups: comp.lang.ada Subject: AI-252 Date: 8 Oct 2004 13:15:05 -0700 Organization: http://groups.google.com Message-ID: <311c6b78.0410081215.2ad78a0@posting.google.com> NNTP-Posting-Host: 217.210.29.242 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 8bit X-Trace: posting.google.com 1097266506 4785 127.0.0.1 (8 Oct 2004 20:15:06 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: Fri, 8 Oct 2004 20:15:06 +0000 (UTC) Xref: g2news1.google.com comp.lang.ada:4935 Date: 2004-10-08T13:15:05-07:00 List-Id: I have finally managed to find where to read about all new additions to Ada slated for the next release - interesting but hard to read :) I found the AI-252 "object.operation" and I am concerned! Should this go into a new Ada standard? http://www.ada-auth.org/cgi-bin/cvsweb.cgi/AIs/AI-00252.TXT?rev=1.12 It is a hack. I searched for "hack" on this URL (all the comments are to much to read) but apparently no one has expressed themselves as strongly as I am doing. The following example is given for 'object.operation' in the URL: package P is type T is tagged ... -- implicit declaration of T'Class procedure Prim(X : in out T); procedure Class_Wide(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 Obj.Class_Wide(Y => 77); -- call on class-wide op if CObj.Prim3 > 33.5 then -- dispatching call on primitive function ... end if; end Main; So we can see that all 'methods' with a T/T2 argument type in them are inherited. It is so implicit and so hard to understand. Method declarations look to dissimlar to method invocations. Did not anybody propose something along task/protected type notation? E.g we could have written the example above in the following manner: package P is tagged type T is ... procedure Prim; procedure Class_Wide(Y : Integer)'Class; end T; -- implicit declaration of T'Class end P; with P; package P2 is tagged type T2 is new P.T with ... -- implicit declaration of Prim(X : in out T2); procedure Prim2(B : Boolean); function Prim3 return Float; end T2; -- implicit declaration of T2'Class 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 Obj.Class_Wide(Y => 77); -- call on class-wide op if CObj.Prim3 > 33.5 then -- dispatching call on primitive function ... end if; end Main; In my eyes the syntax for specification and invocation are in sync in this example. It is straightforward. Any Java, C++ or C# programmer would instinctively understand the syntax (perhaps not the 'Class_Wide' method :). I am not a language lawyer, I do not know anything about Ada internals but common sense says that the syntax I propose could be a pure add-on to existing Ada with very limited need to change existing definitions of the language, just an add on. An opportunistic mind would of course also make all objects of 'tagged type ..' to be of a reference nature requiring invocation of an allocator via 'new' and memory reclamation via garbage collection. Perhaps hard to accept in some Ada camps but provide a pragma 'No_Tagged_Types' or something, I guess this group of Ada users have little interest in and would never use this 'object oriented' notation anyway. They would willingly add such a pragma to all new code. Old code would of course not need it. I guess it might be to late to voice these concerns and I might not be sufficiently articulated in lingua Ada to convince the right people but - please reconsider. /jonas