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: a07f3367d7,9506bdc34331969a X-Google-Attributes: gida07f3367d7,public,usenet X-Google-NewGroupId: yes X-Google-Language: ENGLISH,ASCII Path: g2news2.google.com!postnews.google.com!j9g2000prh.googlegroups.com!not-for-mail From: Adam Beneschan Newsgroups: comp.lang.ada Subject: Re: put of access type Date: Thu, 20 Aug 2009 08:42:46 -0700 (PDT) Organization: http://groups.google.com Message-ID: References: NNTP-Posting-Host: 66.126.103.122 Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable X-Trace: posting.google.com 1250782966 6586 127.0.0.1 (20 Aug 2009 15:42:46 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: Thu, 20 Aug 2009 15:42:46 +0000 (UTC) Complaints-To: groups-abuse@google.com Injection-Info: j9g2000prh.googlegroups.com; posting-host=66.126.103.122; posting-account=duW0ogkAAABjRdnxgLGXDfna0Gc6XqmQ User-Agent: G2/1.0 X-HTTP-UserAgent: Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.0; WOW64; SLCC1; .NET CLR 2.0.50727; Media Center PC 5.0; .NET CLR 3.5.21022; .NET CLR 3.5.30729; .NET CLR 3.0.30618),gzip(gfe),gzip(gfe) Xref: g2news2.google.com comp.lang.ada:7908 Date: 2009-08-20T08:42:46-07:00 List-Id: On Aug 20, 1:05=A0am, Stephen Leake wrote: > Dennis Lee Bieber writes: > > > On Tue, 18 Aug 2009 23:36:15 -0400, Rob Solomon > > declaimed the following in comp.lang.ada: > > >> The only way I know to see the results of my playing is to output > >> them. > > > =A0 =A0And what meaning would some address from either the stack or a h= eap > > have? You can't modify them -- Ada's access types are so heavily > > controlled they are basically black boxes with no inherent meaning. > > Yes, but seeing the actual values helps the learning process. I don't see how. If the goal is to learn to use Ada to write more-or- less "normal" programs, then there's no particular value in seeing the actual "value" of an access object, as opposing to simply "knowing" that a non-null access object designates some other object. In fact, I'd argue the opposite: It helps the learning process to force oneself to think of access values as "black boxes" that designate some other object, because it helps one get in the mind-set of thinking in terms of abstractions that you can use without knowing how they're implemented. And Ada is definitely a language that allows and encourages a programmer to think that way---it's not perfect, but it's pretty good. I think that C programmers in particular who are trying to learn Ada probably need this sort of mental discipline to change the way they think about programming. I've seen too much Ada code written by C programmers who didn't make this change. The code is terrible---very difficult to read and maintain. I don't know Modula-2 at all, and I thought it was better than C at allowing an "abstraction" approach to programming; but from Rob's comment that a pointer is assignment-compatible with System.Address, apparently it isn't better, at least in that one aspect. However, if the goal is to learn Ada to do systems programming, or write other programs where it's *necessary* to do low-level meddling like Unchecked_Conversion and that sort of thing, then I'd say you're right. > A : aliased Interfaces.Unsigned_32; > B : aliased Interfaces.Unsigned_32; > > begin > =A0 =A0 Put (To_Integer (A'access)); > =A0 =A0 Put (To_Integer (B'access)); > > The results should be 4 bytes apart. Ummm... why? What rule in Ada says that the compiler has to put A and B next to each other? -- Adam