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,4cb1f8d1c17d39a8 X-Google-NewGroupId: yes X-Google-Attributes: gida07f3367d7,domainid0,public,usenet X-Google-Language: ENGLISH,ASCII-7-bit Received: by 10.68.25.194 with SMTP id e2mr3908000pbg.7.1320249345047; Wed, 02 Nov 2011 08:55:45 -0700 (PDT) Path: p6ni63136pbn.0!nntp.google.com!news2.google.com!news1.google.com!npeer03.iad.highwinds-media.com!news.highwinds-media.com!feed-me.highwinds-media.com!post02.iad.highwinds-media.com!news.flashnewsgroups.com-b7.4zTQh5tI3A!not-for-mail From: Stephen Leake Newsgroups: comp.lang.ada Subject: Re: Ada 'hello world' for Android; success! References: <8239efcjuw.fsf@stephe-leake.org> <98ca5430-aa52-4e39-b789-70d0dd6adb46@d33g2000prb.googlegroups.com> <824nyrq5p6.fsf@stephe-leake.org> <4eac1ca1$0$7625$9b4e6d93@newsspool1.arcor-online.net> <82mxciogt0.fsf@stephe-leake.org> <4eafbc25$0$6575$9b4e6d93@newsspool3.arcor-online.net> Date: Wed, 02 Nov 2011 11:55:43 -0400 Message-ID: <82mxcemscg.fsf@stephe-leake.org> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.2 (windows-nt) Cancel-Lock: sha1:Zw/A7GlAK9FGbBNNvoOAbm6voyU= MIME-Version: 1.0 X-Complaints-To: abuse@flashnewsgroups.com Organization: FlashNewsgroups.com X-Trace: ca5444eb16800e26b0fa621582 Xref: news2.google.com comp.lang.ada:14275 Content-Type: text/plain; charset=us-ascii Date: 2011-11-02T11:55:43-04:00 List-Id: Georg Bauhaus writes: >> And here is the Ada version (just the package body): >> >> package body Hello is >> >> overriding procedure OnCreate >> (This : access Typ; >> savedInstanceState : access Standard.Android.Os.Bundle.Typ'class) >> is >> type Super_Ref is access all Android.App.Activity.Typ; >> begin >> Android.App.Activity.Oncreate (Super_Ref (This), savedInstanceState); >> >> Android.App.Activity.SetContentView (Android.App.Activity.Ref (This), 16#7f030000#); >> end OnCreate; >> >> end Hello; >> >> By defintion, every non-scalar type in Java _is_ a pointer; Bundle and >> 'this' are pointers. The fact that the code doesn't say 'access' just >> hides that fact. Java also hides the existence of 'this'. > > Java does not really hide the existence of "this", All I mean is it is not present in the parameter list; that's hidden. > .. Hence, with Android, I'd find this to be just as good: > > package body Hello is > > overriding procedure OnCreate > (This : in out Hello.Typ; > savedInstanceState : Android.Os.Bundle.Typ'Class) > is > begin > Android.App.Activity.OnCreate ( > Android.App.Activity.Typ(This), > savedInstanceState); > > Android.App.Activity.SetContentView ( > Android.App.Activity.Typ(This), > 16#7f030000#); > end OnCreate; > > end Hello; Yes, that is one possible design. But it certainly does not match the Android Java API. And in my real Ada program at work, I started with that style, but ended up needing to store pointers to objects, so lots of 'access' crept in. > Why is Super_Ref called Super_Ref, BTW? Isn't this name another hint at > writing Java in Ada? Yes. In this case, because I'm explicitly following the Android example. But in general, the 'super' keyword in Java is a nice feature. There has been discussion of adding that feature to Ada; I forget what the problem was that ended up killing it. >> http://www.stephe-leake.org/ada/access_vs_object.html). > > (When the problem domain is grammars, my goal of an application is to allow > the user to build a structure of subprograms that represent a grammar, > so the application can then call the subprogram matching the start symbol > (or other symbols) to parse input strings. I'd love to see your solution to this problem. It's easy to talk about general principles and design goals; only complete actual solutions flesh out all the problems and details. >> In brief, _any_ framework that uses dispatching on class-wide >> objects needs reference semantics. In Ada, that is indicated by the >> explicit word 'access'. > > +1 to Randy's remarks; tagged types being by-reference types for > a reason, in Ada, is the first thing I thought when I saw > "access Typ['Class]". > > And 'Class makes dispatching explicit enough IMHO. Then you really did not understand the point of my access_vs_object example. I tried as hard as I could to eliminate 'access'; I succeeded, but at too great a cost. Do you agree with my conclusion in that example? If not, why not? -- -- Stephe