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=AXB_XMAILER_MIMEOLE_OL_024C2, BAYES_00,MAILING_LIST_MULTI,REPLYTO_WITHOUT_TO_CC autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,af92cb4b0cc736af X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2002-10-31 05:33:03 PST Path: archiver1.google.com!news1.google.com!newsfeed.stanford.edu!news-spur1.maxwell.syr.edu!news.maxwell.syr.edu!newsfeed.icl.net!newsfeed.fjserv.net!proxad.net!teaser.fr!enst.fr!not-for-mail From: "David C. Hoos" Newsgroups: comp.lang.ada Subject: Re: problem with abstract types Date: Thu, 31 Oct 2002 07:32:31 -0600 Organization: ENST, France Sender: comp.lang.ada-admin@ada.eu.org Message-ID: References: Reply-To: comp.lang.ada@ada.eu.org NNTP-Posting-Host: marvin.enst.fr Mime-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit X-Trace: avanie.enst.fr 1036071183 48130 137.194.161.2 (31 Oct 2002 13:33:03 GMT) X-Complaints-To: usenet@enst.fr NNTP-Posting-Date: Thu, 31 Oct 2002 13:33:03 +0000 (UTC) Return-Path: X-Priority: 3 X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook Express 6.00.2600.0000 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2600.0000 Errors-To: comp.lang.ada-admin@ada.eu.org X-BeenThere: comp.lang.ada@ada.eu.org X-Mailman-Version: 2.0.13 Precedence: bulk List-Unsubscribe: , List-Id: comp.lang.ada mail<->news gateway List-Post: List-Help: List-Subscribe: , Errors-To: comp.lang.ada-admin@ada.eu.org X-BeenThere: comp.lang.ada@ada.eu.org Xref: archiver1.google.com comp.lang.ada:30253 Date: 2002-10-31T07:32:31-06:00 ----- Original Message ----- From: "Ulrich Eckhardt" Newsgroups: comp.lang.ada To: 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?