comp.lang.ada
 help / color / mirror / Atom feed
From: "David C. Hoos" <david.c.hoos.sr@ada95.com>
Subject: Re: problem with abstract types
Date: Thu, 31 Oct 2002 07:32:31 -0600
Date: 2002-10-31T07:32:31-06:00	[thread overview]
Message-ID: <mailman.1036071182.3072.comp.lang.ada@ada.eu.org> (raw)
In-Reply-To: uc6rpa-8u1.ln@uli.uli-eckhardt.de


----- Original Message ----- 
From: "Ulrich Eckhardt" <uli.e@gmx.de>
Newsgroups: comp.lang.ada
To: <comp.lang.ada@ada.eu.org>
Sent: Thursday, October 31, 2002 6:06 AM
Subject: problem with abstract types


> Hi,
> 
> i am starting my first project in ada (A complete rewrite
> of WHFC, see my Homepage). For this i want to
> write an OS independend way to store configuration
> informations (on windows in the registry and on unix in
> human readable config files).
> 
> Therefore my idea was to created a package registry wich defines
> an abstract type registry and several abstract functions
> and (at this time) one real function .
> 
> 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
>    [..]
> 
> Also i have created a child package registry.unix,
> which implements the abstract functions for using on
> unix:
> 
>   package registry.unix is
>      type file_registry is new registry with private;
>      procedure openRegistry(reg : in out file_registry; ..);  
>      [..]
> 
> Also i will create a package registry.win which does the
> same for windows.
> package registry.win is
>      type win_registry is new registry with private;
>      procedure openRegistry(reg : in out win_registry; ..);
> 
> The function getRegistry of the main package should return
> and initialize now depending on the os a package registry.win
> or registry.unix, since for the use of this package it
> should not be visible on which platform it was compiled.
> 
> function getRegistry (a : in sys_access; p_name : in Unbounded_String)
>    return registry_Access is
>    r : registry_Access;
>    begin
>      if compiled = SYS_UNIX then
>         r := new file_registry(s_access => a);
>      else
>         r := new win_registry();
>      end if;
>      return r;
> end getRegistry;
> 
> So in a testprogramm i use :
> 
> 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
> 
> Any hints what i am missing, or comments how such things are better
> done in ada?
This problem has nothing to do with abstract types. The error message means
exactly what it says.  So, what is the prefix of the "access" attribute?
It's "reg" so, "reg" must be aliased.

This the declaration of "reg" should be
reg : aliased registry_Access;
This will fix the compiler's complaint.

All of that being said, the bigger question is "why do you want to take the
"access" attribute of an access value?






  parent reply	other threads:[~2002-10-31 13:32 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 [this message]
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
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