From: Georg Bauhaus <rm.dash-bauhaus@futureapps.de>
Subject: Re: Interface specification in Ada
Date: Wed, 11 Jun 2008 17:02:48 +0200
Date: 2008-06-11T17:02:48+02:00 [thread overview]
Message-ID: <484fe918$0$6558$9b4e6d93@newsspool3.arcor-online.net> (raw)
In-Reply-To: <8bf0fc5b-3eac-4898-835c-93d40aca25e2@z66g2000hsc.googlegroups.com>
christoph.grein@eurocopter.com schrieb:
> You missed the "this" parameter, which is implicit in Java, but
> explicit in Ada:
>
> package Bicycle is
> type Object is interface;
>
> procedure changeCadence (Ob: in out Object; newValue : in Integer)
> is abstract;
And in Ada 2005 the "this" parameter can be suitably
named, and when used, it can be written just like in
Java,
Peugeot: Bicyle.Object;
Peugeot.changeCadence(27);
Incidentally, I'd suggest you consider defining distict integer
types that reflect gears etc. By doing so you can have the
compiler check that a cadence number is not inadvertently
used as a gear number. E.g.,
type Gear is range 1 .. 21;
...
procedure changeGear
(The_Bike: in out Object; newValue : in Gear) is abstract;
or
type Gear
(Front_Wheel: Wheel_Number;
Rear_Wheel: Wheel_Number)
is private;
and so on.
next prev parent reply other threads:[~2008-06-11 15:02 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-06-11 12:46 Interface specification in Ada Dennis Hoppe
2008-06-11 13:04 ` christoph.grein
2008-06-11 15:02 ` Georg Bauhaus [this message]
2008-06-11 16:34 ` Robert A Duff
2008-06-11 21:23 ` Dennis Hoppe
2008-06-12 8:37 ` 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