From: Stephen Leake <stephen_leake@stephe-leake.org>
Subject: Re: Ada 'hello world' for Android; success!
Date: Wed, 02 Nov 2011 11:55:43 -0400
Date: 2011-11-02T11:55:43-04:00 [thread overview]
Message-ID: <82mxcemscg.fsf@stephe-leake.org> (raw)
In-Reply-To: 4eafbc25$0$6575$9b4e6d93@newsspool3.arcor-online.net
Georg Bauhaus <rm.dash-bauhaus@futureapps.de> 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
next prev parent reply other threads:[~2011-11-02 15:55 UTC|newest]
Thread overview: 47+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-10-27 1:18 Ada 'hello world' for Android; success! Stephen Leake
2011-10-27 7:12 ` Alex R. Mosteo
2011-10-28 12:51 ` Stephen Leake
2011-10-27 10:50 ` Jeffrey Creem
2011-10-28 13:01 ` Stephen Leake
2011-10-27 10:58 ` Brian Drummond
2011-10-28 1:37 ` Shark8
2011-10-28 12:22 ` Anatoly Chernyshev
2011-10-29 13:37 ` Stephen Leake
2011-10-29 14:46 ` Anatoly Chernyshev
2011-10-29 20:47 ` Brad Moore
2011-10-29 21:59 ` Anatoly Chernyshev
2011-10-30 3:51 ` Brad Moore
2011-10-30 7:20 ` Anatoly Chernyshev
2011-10-30 10:56 ` Stephen Leake
2011-10-30 17:32 ` Brad Moore
2011-10-29 15:32 ` Georg Bauhaus
2011-10-29 16:09 ` Simon Wright
2011-10-29 17:32 ` tmoran
2011-10-30 11:38 ` Stephen Leake
2011-10-29 20:51 ` Brad Moore
2011-10-30 11:32 ` Stephen Leake
2011-10-31 22:34 ` Randy Brukardt
2011-11-01 8:41 ` Stephen Leake
2011-11-01 9:30 ` Georg Bauhaus
2011-11-02 15:55 ` Stephen Leake [this message]
2011-11-02 17:37 ` Robert A Duff
2011-11-08 3:56 ` Randy Brukardt
2011-11-03 0:37 ` Georg Bauhaus
2011-11-03 11:36 ` Stephen Leake
2011-11-03 15:24 ` Robert A Duff
2011-11-03 18:43 ` Pascal Obry
2011-11-03 22:14 ` Georg Bauhaus
2011-11-04 8:48 ` Dmitry A. Kazakov
2011-11-04 12:18 ` Stephen Leake
2011-11-04 15:03 ` Georg Bauhaus
2011-11-05 16:56 ` Stephen Leake
2011-11-01 9:52 ` Dmitry A. Kazakov
2011-11-02 15:59 ` Stephen Leake
2011-11-02 16:27 ` Dmitry A. Kazakov
2011-11-02 17:38 ` Simon Wright
2011-11-10 17:25 ` Stephen Leake
2011-11-27 15:18 ` mockturtle
2011-11-28 22:35 ` Ada 'hello world' for Android; success! (but music player failure) Stephen Leake
2011-11-29 11:23 ` Georg Bauhaus
2011-11-30 3:33 ` Stephen Leake
2011-11-30 18:57 ` Georg Bauhaus
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox