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.3 required=5.0 tests=BAYES_00, REPLYTO_WITHOUT_TO_CC autolearn=no autolearn_force=no version=3.4.4 X-Google-Thread: 103376,6aa1ec264ce25142 X-Google-NewGroupId: yes X-Google-Attributes: gida07f3367d7,domainid0,public,usenet X-Google-Language: ENGLISH,ASCII Received: by 10.180.98.234 with SMTP id el10mr314679wib.3.1346241509138; Wed, 29 Aug 2012 04:58:29 -0700 (PDT) Path: q11ni374385532wiw.1!nntp.google.com!feeder1.cambriumusenet.nl!feed.tweaknews.nl!195.62.100.242.MISMATCH!newsfeed.kamp.net!newsfeed.kamp.net!feeder.erje.net!news.mixmin.net!aioe.org!.POSTED!not-for-mail From: "Dmitry A. Kazakov" Newsgroups: comp.lang.ada Subject: Re: Real syntax problems in Ada Date: Wed, 29 Aug 2012 13:58:32 +0200 Organization: cbb software GmbH Message-ID: <9ve6114z6hyh$.2ld32vp2se0y.dlg@40tude.net> References: <1p5r39cusgc1n$.18nj9sytckk6$.dlg@40tude.net> <1xfc5a70g33xq.6o52bn9evjls$.dlg@40tude.net> Reply-To: mailbox@dmitry-kazakov.de NNTP-Posting-Host: FbOMkhMtVLVmu7IwBnt1tw.user.speranza.aioe.org Mime-Version: 1.0 X-Complaints-To: abuse@aioe.org User-Agent: 40tude_Dialog/2.0.15.1 X-Notice: Filtered by postfilter v. 0.8.2 Content-Type: text/plain; charset="iso-8859-5" Content-Transfer-Encoding: 8bit Date: 2012-08-29T13:58:32+02:00 List-Id: On Wed, 29 Aug 2012 14:47:19 +0400, Vasiliy Molostov wrote: > Dmitry A. Kazakov �����(�) � ����� ������ 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