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=0.1 required=5.0 tests=BAYES_00,FREEMAIL_FROM, PDS_OTHER_BAD_TLD 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 Path: g2news1.google.com!postnews.google.com!i3g2000hsf.googlegroups.com!not-for-mail From: petter_fryklund@hotmail.com Newsgroups: comp.lang.ada Subject: Re: Dispatching problem. Date: Tue, 15 Jan 2008 12:01:41 -0800 (PST) Organization: http://groups.google.com Message-ID: <1499abbb-e553-4006-b37d-a12f1a8779a6@i3g2000hsf.googlegroups.com> References: <2d63ad45-4d52-4cb2-8dea-e1f92ecaacac@q77g2000hsh.googlegroups.com> <9pcdfsa9h79f$.1naub13ik8tbd$.dlg@40tude.net> NNTP-Posting-Host: 83.140.228.17 Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable X-Trace: posting.google.com 1200427302 32111 127.0.0.1 (15 Jan 2008 20:01:42 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: Tue, 15 Jan 2008 20:01:42 +0000 (UTC) Complaints-To: groups-abuse@google.com Injection-Info: i3g2000hsf.googlegroups.com; posting-host=83.140.228.17; posting-account=ACEctQoAAAD3d42JSpp6_fpg88BhdFDo User-Agent: G2/1.0 X-HTTP-UserAgent: Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.0; SLCC1; .NET CLR 2.0.50727; .NET CLR 3.0.04506),gzip(gfe),gzip(gfe) Xref: g2news1.google.com comp.lang.ada:19421 Date: 2008-01-15T12:01:41-08:00 List-Id: On 15 Jan, 20:49, "Dmitry A. Kazakov" wrote: > On Tue, 15 Jan 2008 10:55:46 -0800 (PST), petter_frykl...@hotmail.com > wrote: > > > I get compilation error when I =A0try to dispatch a call using class > > wide access variables stating that I cannot call abstract program. > > > Perhaps oversimplified example is: > > > package PBN is > > =A0 =A0type Item_T is abstract tagged null record; > > =A0 =A0type Item_Ptr is access all Item_T'Class; > > =A0 =A0function =A0Create (From : in String) return access Item_T'Class = is > > abstract; > > =A0 =A0function =A0Img (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: > > =A0 =A0 function =A0Img (From : access Item_T) return String is abstract; > (better: =A0function =A0Img (From : Item_T) return String is abstract;) > > BTW, same applies to Create. It is a factory, so it should be > > =A0 =A0function =A0Create (From : in String) > =A0 =A0 =A0 return access Item_T is abstract; > (better: =A0function =A0Create (From : in String) return Item_T;) ] > > > end PBN; > > > package PBN.Site is > > =A0 =A0type Site_T is new Item_T with > > =A0 =A0 =A0 record > > =A0 =A0 =A0 =A0 =A0Name : =A0ASU.Unbounded_String; > > =A0 =A0 =A0 end record; > > =A0 =A0type Site_Ptr is access all Site_T; > > > =A0 =A0function =A0Create (From : in String) return Site_Ptr; > > =A0 =A0function =A0Img (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 > > =A0 =A0 Site : =A0PBN.Item_Ptr; > > begin > > =A0 =A0 Site :=3D PBN.Site.Create ("[Site qwerty]"); > > =A0 =A0 Ada.Text_IO.Put_Line (Site.Img); =A0 =A0 =A0 =A0 =A0 =A0 <------= ----------- > > 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 ar= e > using that (damned (:-)) prefix notation anyway... > > -- > Regards, > Dmitry A. Kazakovhttp://www.dmitry-kazakov.de Thanks!