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=-1.9 required=5.0 tests=BAYES_00 autolearn=ham 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 08:47:53 PST Path: archiver1.google.com!news1.google.com!newsfeed.stanford.edu!logbridge.uoregon.edu!uunet!sea.uu.net!sac.uu.net!ash.uu.net!lore.csc.com!baen1673807.greenlnk.net!baen1673807!not-for-mail From: Simon Wright Newsgroups: comp.lang.ada Subject: Re: problem with abstract types Date: 31 Oct 2002 15:31:23 +0000 Organization: Alenia Marconi Systems, ISD, Farlington Sender: sjw@galadriel.frlngtn.gecm.com Message-ID: References: NNTP-Posting-Host: 20.44.240.6 X-Trace: lore.csc.com 1036082153 29440 20.44.240.6 (31 Oct 2002 16:35:53 GMT) X-Complaints-To: abuse@news.csc.com NNTP-Posting-Date: Thu, 31 Oct 2002 16:35:53 +0000 (UTC) X-Newsreader: Gnus v5.5/Emacs 20.3 X-Original-NNTP-Posting-Host: galadriel.frlngtn.gecm.com X-Original-Trace: 31 Oct 2002 16:35:31 GMT, galadriel.frlngtn.gecm.com Xref: archiver1.google.com comp.lang.ada:30261 Date: 2002-10-31T15:31:23+00:00 List-Id: Ulrich Eckhardt 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.