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=-1.9 required=5.0 tests=BAYES_00 autolearn=unavailable autolearn_force=no version=3.4.4 Path: eternal-september.org!reader01.eternal-september.org!reader02.eternal-september.org!news.eternal-september.org!news.eternal-september.org!feeder.eternal-september.org!aioe.org!.POSTED!not-for-mail From: "Dmitry A. Kazakov" Newsgroups: comp.lang.ada Subject: Re: Community Input for the Maintenance and Revision of the Ada Programming Language Date: Fri, 11 Aug 2017 10:34:39 +0200 Organization: Aioe.org NNTP Server Message-ID: References: <1395655516.524005222.638450.laguest-archeia.com@nntp.aioe.org> <1502382504.2184.6.camel@obry.net> <466561720.524077501.729508.laguest-archeia.com@nntp.aioe.org> NNTP-Posting-Host: MajGvm9MbNtGBKE7r8NgYA.user.gioia.aioe.org Mime-Version: 1.0 Content-Type: text/plain; charset=iso-8859-15; format=flowed Content-Transfer-Encoding: 7bit X-Complaints-To: abuse@aioe.org User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:52.0) Gecko/20100101 Thunderbird/52.2.1 Content-Language: en-US X-Notice: Filtered by postfilter v. 0.8.2 Xref: news.eternal-september.org comp.lang.ada:47702 Date: 2017-08-11T10:34:39+02:00 List-Id: On 2017-08-11 09:57, Stefan.Lucks@uni-weimar.de wrote: > If you want tuples, then it would be a lot more consistent to actually > propose the introduction of tuples (i.e., constant records) into the Ada > type system, e.g., > > type May_Be_Integer(Valid: Boolean := True) is constant record > case Valid is > when True => Value: Integer; > when False => null; > end case; > end record; Hmm, isn't it simply a subtype: type May_Be_Integer (Valid: Boolean := True) is record case Valid is when True => Value : Integer; when False => null; end case; end record; subtype Surely_Integer is May_Be_Integer (True); > Then you can the kind of functions you are requesting: > > function Calculate(A, B, C: Integer; D, E, F: Float) return Numeric; > -- returns either Integer or Float [...] This looks awful to me. IMO the right approach, which I deployed on several occasions a tagged abstract type Numeric with descendants Integer_Number and Float_Number. Then "+" is multiple-dispatch emulated via cascaded dispatch: function "+" (A : Numeric; B : Numeric'Class) return Numeric'Class; I don't see any relation to tuples. However it has a relation to pure compile time subroutines. Because the above can be made statically checkable if the body could be split into pure and impure parts. The pure part would run at compile time if tags are statically known and fold the constants. The impure part will run if tags are unknown. A similar case is dimensioned arithmetic which is closer to what you proposed when the dimension is packed in a discriminant rather than tag. Here again we want statically known discriminants eliminated and pure dimension checks in static cases. -- Regards, Dmitry A. Kazakov http://www.dmitry-kazakov.de