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=-0.9 required=5.0 tests=BAYES_00,FORGED_GMAIL_RCVD, FREEMAIL_FROM autolearn=no autolearn_force=no version=3.4.4 X-Google-Thread: 103376,1a52c822fc0dbb23 X-Google-Attributes: gid103376,public X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news1.google.com!postnews.google.com!o5g2000hsb.googlegroups.com!not-for-mail From: Anh Vo Newsgroups: comp.lang.ada Subject: Re: Rational for not making cursor tagged in Containers Date: 20 Apr 2007 09:08:37 -0700 Organization: http://groups.google.com Message-ID: <1177085317.148207.98340@o5g2000hsb.googlegroups.com> References: <1176998738.656903.141250@q75g2000hsh.googlegroups.com> NNTP-Posting-Host: 209.225.224.20 Mime-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" X-Trace: posting.google.com 1177085318 4183 127.0.0.1 (20 Apr 2007 16:08:38 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: Fri, 20 Apr 2007 16:08:38 +0000 (UTC) In-Reply-To: User-Agent: G2/1.0 X-HTTP-UserAgent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.0; .NET CLR 1.1.4322; InfoPath.1),gzip(gfe),gzip(gfe) Complaints-To: groups-abuse@google.com Injection-Info: o5g2000hsb.googlegroups.com; posting-host=209.225.224.20; posting-account=JVr7Xg0AAAAI3MbuARxMmvWLmA7qdJMx Xref: g2news1.google.com comp.lang.ada:15157 Date: 2007-04-20T09:08:37-07:00 List-Id: On Apr 19, 7:53 pm, "Randy Brukardt" wrote: > "Anh Vo" wrote in message > > > It seems that it is not balanced between Container types and its > > cursors. I just want to know what rationale behind it for not making > > cursor a tagged type. > > I think there are two reasons: > > (1) The original designer of the containers library intended for cursors to > be implemented as a bare access value; adding a tag makes that messier and > doubles the size of the cursors. I personally don't find this too important. > > (2) Ada does not allow an operation to be primitive for two tagged types. > (I'm sure we'll hear at length from Dmitry on this. ;-) That would mean that > operations like: > procedure Delete (Container : in out Vector; Index : in Cursor); > would be illegal. That could be worked around by making the cursor > classwide: Thanks for your explanation. Reason in (2) is more legitimate. > procedure Delete (Container : in out Vector; Index : in Cursor'Class); > but now you don't have much taggedness left. On most operations, you're not > even losing prefix notation (as the cursor is the second parameter). agreed. > Indeed, the real reason for your problem is that container is implicit in > Cursor operations that read from the container: > function Element (Position : Cursor) return Element_Type; > > A prefix call like > My_Cursor.Element > doesn't make much sense, because a cursor is just an accessor, you're not > extracting the element from it! You really ought to be able to say: > My_Container.Element (Position => My_Cursor) > which makes it clear where the element is coming from. The latter is already given. I am not quite agreed with the former because I do not see any thing wrong to extract an element pointed by an accessor if and only if Cursor is tagged. > I admit we didn't think much about these issues. When it was suggested that > perhaps the container type should be visibly tagged, I recall someone noted > that would allow the prefix notation. And that seemed good; but I don't > think anyone noted that it doesn't work sometimes. It is a good lesson learned. AV