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=unavailable autolearn_force=no version=3.4.4 X-Received: by 2002:a5e:8a07:: with SMTP id d7mr16692150iok.7.1553068787361; Wed, 20 Mar 2019 00:59:47 -0700 (PDT) X-Received: by 2002:a9d:7246:: with SMTP id a6mr4527323otk.246.1553068787073; Wed, 20 Mar 2019 00:59:47 -0700 (PDT) Path: eternal-september.org!reader01.eternal-september.org!feeder.eternal-september.org!news.gegeweb.eu!gegeweb.org!usenet-fr.net!proxad.net!feeder1-2.proxad.net!209.85.166.216.MISMATCH!w126no62714ita.0!news-out.google.com!l81ni122itl.0!nntp.google.com!w126no62712ita.0!postnews.google.com!glegroupsg2000goo.googlegroups.com!not-for-mail Newsgroups: comp.lang.ada Date: Wed, 20 Mar 2019 00:59:46 -0700 (PDT) In-Reply-To: Complaints-To: groups-abuse@google.com Injection-Info: glegroupsg2000goo.googlegroups.com; posting-host=96.255.209.31; posting-account=zwxLlwoAAAChLBU7oraRzNDnqQYkYbpo NNTP-Posting-Host: 96.255.209.31 References: <6e1977a5-701e-4b4f-a937-a1b89d9127f0@googlegroups.com> <6f9ea847-2903-48c8-9afc-930201f2765a@googlegroups.com> User-Agent: G2/1.0 MIME-Version: 1.0 Message-ID: <74339f3f-9591-45a3-8632-8834b4b466ab@googlegroups.com> Subject: Re: Intervention needed? From: Optikos Injection-Date: Wed, 20 Mar 2019 07:59:47 +0000 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Xref: reader01.eternal-september.org comp.lang.ada:55912 Date: 2019-03-20T00:59:46-07:00 List-Id: On Tuesday, March 19, 2019 at 7:13:47 PM UTC-4, Randy Brukardt wrote: > "Optikos" wrote in message=20 > news:de2f5462-fa10-4fdf-97a6-99989e40c697@googlegroups.com... > On Tuesday, March 19, 2019 at 6:13:20 PM UTC-4, Randy Brukardt wrote: > >> Baloney. The cursor object still exists, and someone can still try to = use > >> it. Yes, you'll get an ...exception... rather than erroneous execution > > > >No, you have it all wrong ...there.... Not raise an exception, but rath= er > >gracefully take the end-of-walk branch of code, just as in normal=20 > >operations. >=20 > Walking is only a small portion of the usage of cursors, and IMHO it is t= he=20 > least important one (since everyone other than container developers ought= to=20 > be using iterators to walk their containers). >=20 > A cursor is a handle accessing an element of a larger container, nothing= =20 > more or less than that. The primary usage is to connect data structures m= ade=20 > up of multiple containers. For instance, consider a compiler symboltable.= =20 > There is a tree structure that represents each of the declarations and th= eir=20 > scopes, and a map structure that represents a mapping of names to nodes o= f=20 > the treee. The contents of that map is going to be tree cursors, each=20 > representing a declaration with a particular name. >=20 > In such a structure, it would be common to assume that the cursors are va= lid=20 > (just like you would assume that pointers are non-null in such a case -- = =20 > that's precisely what Janus/Ada code does, for instance). And dereferenci= ng=20 > a cursor that points at a deleted node has to raise some exception (just = as=20 > it would when using a pointer). >=20 > The value of cursors is that they can be implemented by a range of=20 > abstractions with a range of checking, from array indicies (as in the=20 > bounded containers and the vector) to pointers with a variety of schemes= =20 > from no dangling checking to the bulletproof controlled cursor scheme. Interesting (ab)use case for cursors: (ab)use cursors as an obfuscated lon= g-lived address/pointer/access instead of for transiently walking the cont= ents of containers. (The walk might be of only one or few results of a tra= nsient query, but still a walk of the transient results of the search.) Wh= at you describe as (a[n ab]use case for) cursors is in reality a pointer in= the end, despite any slight-of-hand to change what noun-phrase is utilized= to name what in the end is quite clearly still a pointer(-in-purpose-&-mis= sion). A rose by any other name is just as pungent. To put it SQL terms to reveal how jarring the (ab)use-case of cursors is, s= hould a cursor be able to be stored as a field or record in a table? The S= QL answer is: of course not, cursors are transient artifacts of dynamic qu= eries, not able to be ossified in static storage. My words are not a harsh critique or condemnation of Ada or of anyone's pro= gramming style; you are playing the cards that you are dealt. It is food f= or my contemplation of this interim era of programming that lacks BetterAda= or BetterRust as available programming languages. (I'd say BetterC++, but= that would be like saying BetterAbjectPoverty, where adding any richness m= akes poverty or C++ not poverty or C++ anymore.) Today's Ada is closer to = BetterAda than any other language is.