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 Path: border2.nntp.dca3.giganews.com!border4.nntp.dca.giganews.com!border2.nntp.dca.giganews.com!nntp.giganews.com!news.glorb.com!feeder.erje.net!us.feeder.erje.net!newsfeed.fsmpi.rwth-aachen.de!news-1.dfn.de!news.dfn.de!news.informatik.hu-berlin.de!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail From: Bill Findlay Newsgroups: comp.lang.ada Subject: Re: Dereferencing and style guides Date: 11 Oct 2013 13:19:06 GMT Message-ID: <556171307403189520.612579yaldnif.w-blueyonder.co.uk@news.individual.net> References: Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Trace: individual.net mSFqH5TGIVWiujzKAhik3wmb+VIXhOoeSDV7kEK0W9DDvufe5G Cancel-Lock: sha1:TBlVRHqtVBMF2XJPJ5ZbmtWy4L4= User-Agent: NewsTap/4.0.1 (iPad) Xref: number.nntp.dca.giganews.com comp.lang.ada:183612 Date: 2013-10-11T13:19:06+00:00 List-Id: Robert A Duff wrote: > Bill Findlay writes: > >> Can I make the contrary case? > > Certainly. > >> Given that we know that P is a pointer, P.f or P(i) can only reasonably be >> interpreted as dereferencing P and selecting a component from the result; so >> I do not see that P^.f or P^(i) improves comprehensibility to any >> significant degree. >> >> Given that we do not know that P is a pointer, P.f or P(i) is essentially >> the same cognitive burden as R.f or A(i); from the uniform referent point of >> view this is an advantage. It fails to be, only if the dereference fails, >> and we know that that should not happen in Ada 8-). Even if it does, the >> extra effort of perceiving the semantics correctly is trivial. > > By "dereference fails", I assume you're talking about null pointers. > I wasn't so worried about that -- I'm more worried about > aliasing. I'm thinking "X^.Y := ..." is a helpful reminder that > some other pointers might also point to X^. But even without prior knowledge that P is a pointer, there are several ways that must be borne in mind for how P.whatever could be aliased, the existence of another pointer with the same value as P being perhaps the most straightforward. {An anecdote. Many years ago I did once get major benefit from the ^ notation in Pascal. I had to convert a program from using data in an external file to using data in virtual memory. I merely had to write a "get" procedure for the latter and the rest of the code was essentially unchanged, with data^ reinterpreted as a pointer dereference instead of a file record access. The point being that there was some commonality of syntax in Pascal with ^, and there is even more in Ada without it.} > So I'm not convinced. But I guess your point of view is more > popular than mine. Consider languages like Java, for ex, > where (almost) everything is a pointer, greatly (IMHO) exacerbating > the aliasing problem. Yes. Yuck. -- Bill Findlay