From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.5-pre1 (2020-06-20) on ip-172-31-74-118.ec2.internal X-Spam-Level: X-Spam-Status: No, score=-1.9 required=3.0 tests=BAYES_00 autolearn=ham autolearn_force=no version=3.4.5-pre1 Date: 30 Jun 93 08:49:25 GMT From: munnari.oz.au!metro!basser.cs.su.oz.au!news.adelaide.edu.au!achilles!andr ewd@uunet.uu.net (Andrew Dunstan) Subject: Re: Access Discriminants Message-ID: <20rk2l$cfq@huon.itd.adelaide.edu.au> List-Id: My previous question on this apparently didn't make it onto the net (or at least I can't see it in the old articles!). So, at the risk of annoying people, I am reposting it. In comp.lang.ada, stt@spock.camb.inmet.com (Tucker Taft) writes: > > type Set is limited private; > -- Abstract "Set" of Item_Type type > procedure Add_Item(To : in out Set; Item : Item_Type); > . . . > > type Set_Iterator(Over : access Set) is limited private; > -- Iterator over a given set, designated by the access discrim > procedure Start(Iterator : in out Set_Iterator); > -- (Re)Start iteration at "beginning" of set identified > -- by Iterator.Over > function More(Iterator : Set_Iterator) return Boolean; > -- return True if more items left in iteration. > procedure Get_Next(Iterator : in out Set_Iterator; > Item : out Item_Type); > -- Get next item in the iteration. > Let's say type Set is private instead of limited private. As I understand it, this is OK - it is the type Iterator that must be limited private in order to have an access discriminant. Now, say we have function some_func(The_Set : in set) return something is ... Can I create an iterator over The_Set? It is not aliased, so it appears that I can't, directly. I could make an aliased copy, but this seems a bit round-about. cheers andrew # Andrew Dunstan # There's nothing good or bad # # net: # # # adunstan@steptoe.adl.csa.oz.au # but thinking makes it so. # # or: andrewd@cs.adelaide.edu.au # #