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
Date: 30 Jun 93 08:49:25 GMT [thread overview]
Message-ID: <20rk2l$cfq@huon.itd.adelaide.edu.au> (raw)
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 # #
reply other threads:[~1993-06-30 8:49 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox