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: Matthew Heaney Subject: Re: "out" or "access" Date: 1998/10/31 Message-ID: #1/1 X-Deja-AN: 406898541 Sender: matt@mheaney.ni.net References: <908956499.754394@dedale.pandemonium.fr> <70mo3h$gll$1@cf01.edf.fr> <71cjab$ka8$1@nnrp1.dejanews.com> NNTP-Posting-Date: Fri, 30 Oct 1998 20:06:08 PDT Newsgroups: comp.lang.ada Date: 1998-10-31T00:00:00+00:00 List-Id: Robert A Duff writes: > 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... You are correct. However, the library I'm building has one iterator type, that can be used to both query and modify objects in the collection. The representation of the iterator must therefore include an access-to-variable access type. (Actually, I could do it the other way around: implement the iterator type using an access-to-constant access type, and use addr-to-acc-conv inside the one operation that modifies state. Hmmm...) So perhaps I'm going beyond what even access constant params buy you. Maybe my real problem is how to "cast away const." It would be hip if the language provided a way to do that explicitly, analogous to something like Unchecked_Conversion. BTW: does the language define --or give implementation advice-- on what the effect of unchecked conversion from access-to-constant to access-to-variable is? Or is it the intention of the designers that you never try to do that? Real programmers --like me-- are occasionally going to need to cast away const. The language designers should state explictly 1) that you shouldn't do that, or 2) that it's OK to do it, and here's how. If you don't say, then I'm going to do it _some_ way, perhaps using a technique you didn't intend. Just tell me what your specific intent is. > 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)? Oh yes, but this doesn't meet my needs, because you need to call a dispatching operation ("factory method") that returns an iterator of a class-wide type. Class-wide types are indefinate, and therefore require initialization during object declaration, which isn't possible if the type is limited.