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.9 required=5.0 tests=BAYES_00 autolearn=ham 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!news3.google.com!out01b.usenetserver.com!news.usenetserver.com!in04.usenetserver.com!news.usenetserver.com!nx01.iad01.newshosting.com!newshosting.com!newsfeed.icl.net!newsfeed.fjserv.net!newsfeed.freenet.de!85.12.40.130.MISMATCH!xlned.com!feeder1.xlned.com!newshub2.home.nl!home.nl!amsnews11.chello.com!nuzba.szn.dk!news.jacob-sparre.dk!pnx.dk!not-for-mail From: "Randy Brukardt" Newsgroups: comp.lang.ada Subject: Re: Rational for not making cursor tagged in Containers Date: Thu, 19 Apr 2007 21:53:40 -0500 Organization: Jacob's private Usenet server Message-ID: References: <1176998738.656903.141250@q75g2000hsh.googlegroups.com> NNTP-Posting-Host: static-69-95-181-76.mad.choiceone.net X-Trace: jacob-sparre.dk 1177037512 20615 69.95.181.76 (20 Apr 2007 02:51:52 GMT) X-Complaints-To: news@jacob-sparre.dk NNTP-Posting-Date: Fri, 20 Apr 2007 02:51:52 +0000 (UTC) X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2800.1807 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1807 Xref: g2news1.google.com comp.lang.ada:15132 Date: 2007-04-19T21:53:40-05:00 List-Id: "Anh Vo" wrote in message news:1176998738.656903.141250@q75g2000hsh.googlegroups.com... > I enjoy using the prefixed (object) notation when and where ever I > can. However, when it comes to Containers, I can not use this notation > on cursor because it is not tagged. > > 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: 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). 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. 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. Randy.