comp.lang.ada
 help / color / mirror / Atom feed
From: Simon Wright <simon.j.wright@amsjv.com>
Subject: Re: problem with abstract types
Date: 31 Oct 2002 15:31:23 +0000
Date: 2002-10-31T15:31:23+00:00	[thread overview]
Message-ID: <x7vadkuocac.fsf@galadriel.frlngtn.gecm.com> (raw)
In-Reply-To: uc6rpa-8u1.ln@uli.uli-eckhardt.de

Ulrich Eckhardt <uli.e@gmx.de> writes:

> package registry is
>    type registry is abstract tagged limited private;
>    type registry_Access is access all registry'Class;
> 
>    procedure openRegistry(reg : in out registry; ..) is abstract;
>    function getRegistry( .. ) return registry_Access
>    [..]

[...]

> with registry; use registry;
> with Ada.Strings.Unbounded; use Ada.Strings.Unbounded;
> 
> procedure main is
>     reg : registry_Access;
>     err : r_error;
> begin
>     reg := getRegistry(CLASS_USER,To_Unbounded_String("registrytest"));
>     openRegistry(reg'access,err);
> end main;
> 
> But when compiling this code i get a
> main.adb:10:20: prefix of "access" attribute must be aliased

reg'access is an access-to-registryAccess, while openRegistry requires
a registry, not an access-to-registryAccess or even a registryAccess,
so your call should have read

   openRegistry (reg.all, err);

Some people would declare your openRegistry as (pardon my Ada-isation
of your naming conventions):

   procedure Open (Reg : access Registry; ...);

in which case you could have said

   Registry.Open (Reg);

Passing a parameter called err to openRegistry implies you aren't
thinking of using exceptions, this is one place where you definitely
should.

It seems needlessly painful for users to make them use unbounded
strings in the getRegistry call, a plain string would be much easier.



  parent reply	other threads:[~2002-10-31 15:31 UTC|newest]

Thread overview: 30+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2002-10-31 12:06 problem with abstract types Ulrich Eckhardt
2002-10-31 13:15 ` John English
2002-10-31 14:43   ` Ulrich Eckhardt
2002-10-31 17:18     ` Robert I. Eachus
2002-10-31 18:20       ` Jeffrey Carter
2002-10-31 20:58         ` Robert I. Eachus
2002-11-01 10:57       ` Ulrich Eckhardt
2002-11-01 12:05         ` Simon Wright
2002-11-01 17:03           ` Robert A Duff
2002-11-04 15:18             ` Robert I. Eachus
2002-11-04 16:14               ` Robert A Duff
2002-10-31 13:32 ` David C. Hoos
2002-10-31 13:47   ` problem with posters Peter Hermann
2002-10-31 14:15     ` Preben Randhol
2002-10-31 14:35   ` problem with abstract types Ulrich Eckhardt
2002-11-01  8:31     ` Dmitry A.Kazakov
2002-11-01 11:32       ` Ulrich Eckhardt
2002-10-31 15:31 ` Simon Wright [this message]
2002-10-31 17:22 ` Stephen Leake
2002-11-01 10:25   ` Ulrich Eckhardt
2002-11-04 14:30     ` Ted Dennison
2002-11-04 15:08     ` Ulrich Eckhardt
2002-11-04 15:32       ` Stephen Leake
2002-11-04 17:12         ` Ulrich Eckhardt
2002-11-04 17:43           ` David C. Hoos
2002-11-04 19:34             ` Ulrich Eckhardt
2002-11-04 19:54             ` Stephen Leake
2002-11-04 20:08             ` Robert A Duff
2002-11-01 11:15   ` Preben Randhol
2002-11-01 17:21     ` Stephen Leake
replies disabled

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