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.3 required=5.0 tests=BAYES_00,INVALID_MSGID autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,9a7e0c43216f4def X-Google-Attributes: gid103376,public From: Robert A Duff Subject: Re: "out" or "access" Date: 1998/10/30 Message-ID: #1/1 X-Deja-AN: 406813306 Sender: bobduff@world.std.com (Robert A Duff) References: <908956499.754394@dedale.pandemonium.fr> <70mo3h$gll$1@cf01.edf.fr> <71cjab$ka8$1@nnrp1.dejanews.com> Organization: The World Public Access UNIX, Brookline, MA Newsgroups: comp.lang.ada Date: 1998-10-30T00:00:00+00:00 List-Id: Matthew Heaney writes: > The RM also recommends that implementations "deliver a useful result" > when you take the O'Address of a by-reference type (tagged types, > limited types) passed as a subprogram parameter. That's why > Sys.Addr_To_Acc_Conv can be used to work around this problem. I don't understand why you want to use 'Address at all. My earlier suggestion was to use 'Unchecked_Access. It has the same problem with possible dangling references, but at least it doesn't throw type checking completely out the window, as 'Address does. > type My_Iterator is > new Iterator with record > Stack : Conv.Object_Pointer; ^^^^^^^^^^^^^^^^^^^ Say My_Stack_Ptr, which is declared "access constant My_Stack", and then... > Index : ; > end record; > > function Initialize (S : My_Stack) return Iterator'Class is > begin > return My_Iterator'(To_Pointer (S'Address), S.Top); return My_Iterator'(S'Unchecked_Access, S.Top); > end; By the way, have you considered making the iterators limited, and initializing them with a discriminant that points to the Stack (or whatever is being iterated)? - Bob -- Change robert to bob to get my real email address. Sorry.