comp.lang.ada
 help / color / mirror / Atom feed
* AI-252
@ 2004-10-08 20:15 jn
  0 siblings, 0 replies; only message in thread
From: jn @ 2004-10-08 20:15 UTC (permalink / raw)


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



^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2004-10-08 20:15 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-10-08 20:15 AI-252 jn

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox