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.7 required=5.0 tests=BAYES_00,PDS_OTHER_BAD_TLD, REPLYTO_WITHOUT_TO_CC autolearn=no autolearn_force=no version=3.4.4 X-Google-Thread: 103376,1aeedd6ed9898fbb X-Google-Attributes: gid103376,public,usenet X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news1.google.com!news2.google.com!border1.nntp.dca.giganews.com!nntp.giganews.com!newsfeed00.sul.t-online.de!t-online.de!inka.de!rz.uni-karlsruhe.de!news.belwue.de!newsfeed.ision.net!newsfeed2.easynews.net!ision!newsfeed.arcor.de!newsspool1.arcor-online.net!news.arcor.de.POSTED!not-for-mail From: "Dmitry A. Kazakov" Subject: Re: Dispatching problem. Newsgroups: comp.lang.ada User-Agent: 40tude_Dialog/2.0.15.1 MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Reply-To: mailbox@dmitry-kazakov.de Organization: cbb software GmbH References: <2d63ad45-4d52-4cb2-8dea-e1f92ecaacac@q77g2000hsh.googlegroups.com> Date: Tue, 15 Jan 2008 20:49:33 +0100 Message-ID: <9pcdfsa9h79f$.1naub13ik8tbd$.dlg@40tude.net> NNTP-Posting-Date: 15 Jan 2008 20:49:33 CET NNTP-Posting-Host: adec71e3.newsspool2.arcor-online.net X-Trace: DXC=XJIB9JLb;DLk:C4l9A;OcOA9EHlD;3YcB4Fo<]lROoRAnkgeX?EC@@@CboTG`\P]4I[6LHn;2LCVN[ On Tue, 15 Jan 2008 10:55:46 -0800 (PST), petter_fryklund@hotmail.com wrote: > I get compilation error when I try to dispatch a call using class > wide access variables stating that I cannot call abstract program. > > Perhaps oversimplified example is: > > package PBN is > type Item_T is abstract tagged null record; > type Item_Ptr is access all Item_T'Class; > function Create (From : in String) return access Item_T'Class is > abstract; > function Img (From : access Item_T'Class) return String is > abstract; This is a class-wide operation. As such it is not primitive (and does not dispatch). For non-primitive operations declaring abstract means disallowing in Ada. [ My guess, you wanted: function Img (From : access Item_T) return String is abstract; (better: function Img (From : Item_T) return String is abstract;) BTW, same applies to Create. It is a factory, so it should be function Create (From : in String) return access Item_T is abstract; (better: function Create (From : in String) return Item_T;) ] > end PBN; > > package PBN.Site is > type Site_T is new Item_T with > record > Name : ASU.Unbounded_String; > end record; > type Site_Ptr is access all Site_T; > > function Create (From : in String) return Site_Ptr; > function Img (From : access Site_T) return String; This is an "overloading" for the disallowed operation above. > end PBN.Site; > > with Ada.Text_IO; > with PBN; > with PBN.Site; > procedure Print is > Site : PBN.Item_Ptr; > begin > Site := PBN.Site.Create ("[Site qwerty]"); > Ada.Text_IO.Put_Line (Site.Img); <----------------- > cannot call abstract program This calls to the disallowed Img from PBN, the compiler tells you so. > end Print; > > Any suggestions (apart from taking extensive course in OOD ;-) ? Use new keywords of Ada 2005 indicating a desire to override, since you are using that (damned (:-)) prefix notation anyway... -- Regards, Dmitry A. Kazakov http://www.dmitry-kazakov.de