comp.lang.ada
 help / color / mirror / Atom feed
From: Stephen Leake <stephen_leake@acm.org>
Subject: Re: class wide object in generic package
Date: Mon, 10 Jun 2002 13:00:37 GMT
Date: 2002-06-10T13:00:37+00:00	[thread overview]
Message-ID: <wkelffffuy.fsf@acm.org> (raw)
In-Reply-To: 3D045767.8020102@rcs.ei.tum.de

Thomas Maier-Komor <maierkom@rcs.ei.tum.de> writes:

> Hi everybody,
> 
> I am getting this error message when compiling the
> code at the end of the message:
> 
> generic_pac.adb:7:26: class-wide argument not allowed here
> generic_pac.adb:7:26: "eval" is not a primitive operation of "Object"
> 
> 
> my question is:
> first: is it possible to declare a procedure in the
> generic part so that it will be a primitive operation of
> Object?

No. All primitive operations are declared in the same declarative
region as the type.

> second: why isn't a class-wide argument not allowed in this place?

Because "eval" isn't a primitive operation of Object :). Using a
class-wide argument means you _want_ dispatching. Only primitive
operations can be dispatching.

You have a couple choices to make this work. If you don't actually
need dispatching, you can make eval take a class-wide argument:

with procedure eval(o : in out Object'class);

If you want dispatching, you'll have to use a generic formal package
parameter:

generic
   package Object_Package is new Generic_Obj_Package (...);
package generic_pac ...

Then in Generic_Obj_Package, declare Object and Eval. Note that it has
to be generic!

Good luck,

-- 
-- Stephe



  parent reply	other threads:[~2002-06-10 13:00 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2002-06-10  7:38 class wide object in generic package Thomas Maier-Komor
2002-06-10 12:28 ` Craig Carey
2002-06-10 13:14   ` Thomas Maier-Komor
2002-06-10 13:00 ` Stephen Leake [this message]
2002-06-10 13:25   ` Thomas Maier-Komor
2002-06-11 20:57   ` Ehud Lamm
2002-06-12 17:33     ` Stephen Leake
2002-06-13  1:58       ` Robert A Duff
2002-06-13 14:07         ` Stephen Leake
  -- strict thread matches above, loose matches on Subject: below --
2002-06-10 11:07 Grein, Christoph
replies disabled

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