comp.lang.ada
 help / color / mirror / Atom feed
From: petter_fryklund@hotmail.com
Subject: Re: Dispatching problem.
Date: Tue, 15 Jan 2008 12:01:41 -0800 (PST)
Date: 2008-01-15T12:01:41-08:00	[thread overview]
Message-ID: <1499abbb-e553-4006-b37d-a12f1a8779a6@i3g2000hsf.googlegroups.com> (raw)
In-Reply-To: 9pcdfsa9h79f$.1naub13ik8tbd$.dlg@40tude.net

On 15 Jan, 20:49, "Dmitry A. Kazakov" <mail...@dmitry-kazakov.de>
wrote:
> On Tue, 15 Jan 2008 10:55:46 -0800 (PST), petter_frykl...@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. Kazakovhttp://www.dmitry-kazakov.de

Thanks!



  reply	other threads:[~2008-01-15 20:01 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-01-15 18:55 Dispatching problem petter_fryklund
2008-01-15 19:49 ` Dmitry A. Kazakov
2008-01-15 20:01   ` petter_fryklund [this message]
  -- strict thread matches above, loose matches on Subject: below --
2003-02-06 14:04 Petter Fryklund
2003-02-06 15:33 ` James S. Rogers
2003-02-07  7:35   ` Petter Fryklund
2003-02-07  9:01 ` Dmitry A. Kazakov
2003-02-07 14:55   ` Petter Fryklund
2003-02-10  9:12     ` Dmitry A. Kazakov
2003-02-11  8:31       ` Petter Fryklund
replies disabled

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