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=0.4 required=5.0 tests=BAYES_00,FORGED_MUA_MOZILLA autolearn=no 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.19.161 with SMTP id g1mr15679708pbe.7.1320139814705; Tue, 01 Nov 2011 02:30:14 -0700 (PDT) Path: p6ni53474pbn.0!nntp.google.com!news2.google.com!news3.google.com!feeder.news-service.com!feed.xsnews.nl!border-2.ams.xsnews.nl!npeer.de.kpn-eurorings.net!npeer-ng0.de.kpn-eurorings.net!newsfeed.arcor.de!newsspool2.arcor-online.net!news.arcor.de.POSTED!not-for-mail Date: Tue, 01 Nov 2011 10:30:12 +0100 From: Georg Bauhaus User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.6; rv:7.0.1) Gecko/20110929 Thunderbird/7.0.1 MIME-Version: 1.0 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> In-Reply-To: <82mxciogt0.fsf@stephe-leake.org> Message-ID: <4eafbc25$0$6575$9b4e6d93@newsspool3.arcor-online.net> Organization: Arcor NNTP-Posting-Date: 01 Nov 2011 10:30:13 CET NNTP-Posting-Host: edd9bea9.newsspool3.arcor-online.net X-Trace: DXC=chZ4bUnX9LCAa;:RKVJ>LEMcF=Q^Z^V3H4Fo<]lROoRA8kFejVH3;GGVR0\5_NXTV]`e@7D7G X-Complaints-To: usenet-abuse@arcor.de Xref: news2.google.com comp.lang.ada:14260 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Date: 2011-11-01T10:30:13+01:00 List-Id: On 30.10.11 12:32, Stephen Leake wrote: > 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", but there are a few places where you cannot make "this" explicit (e.g. when declaring a method). This is part of how Java, the language, is defined. > Making those > features explicit is definitely the Ada way. But Ada does not use "access" for O-O; one or more parameters of a tagged type indicate O-O (or 'Class if you want dispatching.) Can't have O-O with just access: procedure Plain (This: access Integer; That : ...); has no trace of O-O even though "access" is present with the first parameter. 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; Why is Super_Ref called Super_Ref, BTW? Isn't this name another hint at writing Java in Ada? It's not like I won't get used to writing access routinely, or think in terms of the Java like Android model when writing Ada. It's just that I'll then have to think in terms of two models of an O-O system: one model uses pointers, the other doesn't, since it doesn't need them. > 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. (Typical grammars have recursion in them. This suggests recursion of some form in the subprograms. The subprograms in my scanners use explicit access to local procedures as necessary, guided by the grammar. The sequence of tokens is stored in an instance of Indefinite_Vectors. (Class-wide parameters are one way to invoke users' even handlers. Users will pass objects that have overridden prim ops. (Another option for event handlers is to ask for them to be passed as actuals matching formal generic parameters/packages. (The program construction techniques are different, but I think the solution that follows from these alternative premises solve the same problem, without needing O-O pointers.) > 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.