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.3 required=5.0 tests=BAYES_00,INVALID_MSGID,XPRIO autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,2aed634b0d2edf21,start X-Google-Attributes: gid103376,public From: "Michael Garrett" Subject: Run Time Dispatch Question Date: 2000/02/25 Message-ID: <895q4e$5up$1@ssauraaa-i-1.production.compuserve.com>#1/1 X-Deja-AN: 589822164 X-Priority: 3 X-MimeOLE: Produced By Microsoft MimeOLE V5.00.2314.1300 X-Complaints-To: newsmaster@compuserve.com X-Trace: ssauraaa-i-1.production.compuserve.com 951479246 6105 216.192.165.8 (25 Feb 2000 11:47:26 GMT) Organization: CompuServe Interactive Services X-MSMail-Priority: Normal NNTP-Posting-Date: 25 Feb 2000 11:47:26 GMT Newsgroups: comp.lang.ada Date: 2000-02-25T11:47:26+00:00 List-Id: I am back to my study of Ada... I am having a problem understanding run time dispatching. ( Basic question I know, but I'm having a brain cramp. ) I have declared a basic type using a class wide access variable link to the next object. When I create a simple linked list and a class wide access variable to point into the list, I get a compile time error when calling procedure p( .... ), a dispatching procedure. ( which works for compile time dispatching ). What is my problem??? with ada.text_io; use ada.text_io; procedure main7 is ------------------------------------------------------- type t; type pt is access all t'class; type t is tagged record next : pt := null; end record; ------------------------------------------------------- type t1 is new t with record x : integer; end record; procedure p( this : t1 ) is begin put_line(" in p(t1)"); end p; ------------------------------------------------------- type t2 is new t1 with record y : integer; end record; procedure p( this : t2 ) is begin put_line("in p(t2)"); end p; ------------------------------------------------------- begin -- static dispatching, compile time put_line("Compile Time Dispatching"); declare tt1 : t1; tt2 : t2; begin tt1.x := 10; tt2.x := 5; tt2.y := 40; p(tt1); p(tt2); end; -- end compile time dispatching put_line("Run Time Dispatching"); declare ptrt : pt; it : pt; -- classwide access type begin ptrt := new t1; ptrt.next := new t2; it := ptrt.next; -- it references a t2 object, second in list. p(it.all); -- PROBLEM end; end main7; -- Thank You!! Michael C. Garrett