From: "Dmitry A. Kazakov" <mailbox@dmitry-kazakov.de>
Subject: Re: Real syntax problems in Ada
Date: Wed, 29 Aug 2012 13:58:32 +0200
Date: 2012-08-29T13:58:32+02:00 [thread overview]
Message-ID: <9ve6114z6hyh$.2ld32vp2se0y.dlg@40tude.net> (raw)
In-Reply-To: op.wjstk5uxka8ora@aspire.local
On Wed, 29 Aug 2012 14:47:19 +0400, Vasiliy Molostov wrote:
> Dmitry A. Kazakov <mailbox@dmitry-kazakov.de> яПНяПНяПНяПНяПН(яПН) яПН яПНяПНяПНяПНяПН яПНяПНяПНяПНяПНяПН Wed,
> 29 Aug 2012 11:25:00 +0400:
>
>> There is an important operation on bodies: composition:
>>
>> type Float_Valued is function (X : Float) return Float;
>> X : Float_Valued := begin ... end;
>> Y : Float_Valued := begin ... end;
>> Z : Float_Valued := Y * X;
>>
>> Another operation is inheritance. That is when one body operates T
>> another
>> S and S <: T, inheritance is the body of T composed with type conversion
>> S to T.
>
> Intriguing. Perhaps this can be distributed on other things,
> where subprogram can be simply implemented by X * Y.
Already Ada 83 had this, though in a very rudimentary ad-hoc form when type
conversion applied to the argument of a call. It works for all modes, e.g.
for out:
procedure Foo (X : in out Integer);
Y : Float;
begin
Foo (Integer (Y)); -- This is legal Ada 83
>> And of course, parametrization, AKA instantiation of a generic body. Simple
>> non-generic form could deploy discriminants. That would give
>> specialization:
>>
>> type Integrator (Method : ...) is
>> function (X : Float; ...) return Float;
>
> matching parameters by position only is awkward, perhaps. What about
>
> type Integrator (Method : ...) is
> function (X : Float := Method; ...) return Float;
>
> or
>
> type Integrator (Method : ...) is
> function (Method : Float; ...) return Float;
It is not different from how discriminants are used in record types.
There are various applications for discriminants to constraint the
instance:
type Multiplicative (Left, Right : Unit) is
function (X : Dimensioned (Left); Y : Dimensioned (Right))
return Dimensioned (Left * Right);
type Additive (Left : Unit) is
function (X, Y : Dimensioned (Left)) return Dimensioned (Left);
> (I dont know what type the Method you mean, but assumed it is a float type)
>
> But this arises a question about X * Y where both are types indeed, and
> can have discriminants. I can not imagine this.
No problem. Compare:
type T (...) is record ... end record;
type S (...) is record ... end record;
type U (...) is record
X : T (...);
Y : S (...);
end record;
Discriminants of the result type must define the discriminants of the
argument types.
It is no matter if the operation is composition or aggregation as in the
example where T and S are record types aggregated into new result type U.
--
Regards,
Dmitry A. Kazakov
http://www.dmitry-kazakov.de
next prev parent reply other threads:[~2012-08-29 11:58 UTC|newest]
Thread overview: 40+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-08-28 8:13 Real syntax problems in Ada Dmitry A. Kazakov
2012-08-28 10:20 ` Georg Bauhaus
2012-08-28 10:47 ` Niklas Holsti
2012-08-28 11:33 ` J-P. Rosen
2012-08-31 13:35 ` Robert A Duff
2012-08-28 13:27 ` Vasiliy Molostov
2012-08-28 15:23 ` Dmitry A. Kazakov
2012-08-28 20:18 ` Vasiliy Molostov
2012-08-29 7:25 ` Dmitry A. Kazakov
2012-08-29 10:47 ` Vasiliy Molostov
2012-08-29 11:58 ` Dmitry A. Kazakov [this message]
2012-08-30 17:38 ` Vasiliy Molostov
2012-08-28 15:14 ` Adam Beneschan
2012-08-28 16:18 ` J-P. Rosen
2012-08-28 16:39 ` Dmitry A. Kazakov
2012-08-28 21:38 ` Randy Brukardt
2012-08-29 6:58 ` Dmitry A. Kazakov
2012-08-29 10:43 ` stefan-lucks
2012-08-29 10:58 ` stefan-lucks
2012-08-29 13:14 ` Niklas Holsti
2012-08-29 17:52 ` stefan-lucks
[not found] ` <fbps38pgcuf8fgioptt39s6u7dme1aqs7r@invalid.netcom.com>
2012-09-02 10:16 ` svaa
2012-08-29 13:33 ` Georg Bauhaus
2012-08-29 17:20 ` Jeffrey Carter
2012-08-29 17:51 ` stefan-lucks
2012-08-30 9:12 ` Georg Bauhaus
2012-08-28 21:49 ` Randy Brukardt
2012-08-28 23:09 ` Adam Beneschan
2012-08-29 7:34 ` Egil Høvik
2012-08-28 19:41 ` Florian Weimer
2012-08-28 20:53 ` Shark8
2012-08-28 21:07 ` Adam Beneschan
2012-08-28 21:25 ` Shark8
2012-08-28 22:59 ` Adam Beneschan
2012-08-29 7:06 ` Dmitry A. Kazakov
2012-08-30 21:08 ` Randy Brukardt
2012-08-30 22:06 ` sbelmont700
2012-08-30 22:34 ` Adam Beneschan
2012-08-30 22:54 ` William Findlay
2012-08-31 7:39 ` Dmitry A. Kazakov
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox