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=ham autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII Path: g2news2.google.com!news4.google.com!postnews.google.com!a36g2000yqc.googlegroups.com!not-for-mail From: AdaMagica Newsgroups: comp.lang.ada Subject: Re: Question on types conversions - operations Date: Mon, 15 Jun 2009 03:33:19 -0700 (PDT) Organization: http://groups.google.com Message-ID: References: <4a33cb0b$0$2848$ba620e4c@news.skynet.be> <6e151h.kgc.ln@hunter.axlog.fr> NNTP-Posting-Host: 80.156.44.178 Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable X-Trace: posting.google.com 1245061999 11850 127.0.0.1 (15 Jun 2009 10:33:19 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: Mon, 15 Jun 2009 10:33:19 +0000 (UTC) Complaints-To: groups-abuse@google.com Injection-Info: a36g2000yqc.googlegroups.com; posting-host=80.156.44.178; posting-account=rmHyLAoAAADSQmMWJF0a_815Fdd96RDf User-Agent: G2/1.0 X-HTTP-UserAgent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; .NET CLR 1.1.4322; .NET CLR 2.0.50727; InfoPath.1; .NET CLR 3.0.04506.30; .NET CLR 3.0.4506.2152; .NET CLR 3.5.30729),gzip(gfe),gzip(gfe) X-HTTP-Via: 1.1 webwasher (Webwasher 6.8.3.4555) Xref: g2news2.google.com comp.lang.ada:6477 Date: 2009-06-15T03:33:19-07:00 List-Id: On Jun 15, 10:40=A0am, Jean-Pierre Rosen wrote: > sjw a =E9crit :>> With S :=3D Speed(Float(L) / Float(T)) ? Mmmm ... not n= ice. > > Why not nice? You are performing (for good reasons) a non homogenous > operation. Therefore you go to the no-dimension world (convert to > Float), do your operation there, then return to the dimensioned world > (convert to Speed). Of course not nice because: You introduce different types for safety against mixing different units incorrectly. But then you render physical expressions unreadable by marring them with type conversions - and you lose type checking. So where is the safety? This is only OK when hidden in a body for overloaded versions of multiplying operators. But then: With only three dimensions, there are only a few overloadings necessary; *but* there are also only very simple expressions so that it's improbable that you write wrong expressions. So what do you gain? Do you really gain something? Wrong dimensions deliver abstruse results which should show up immediately in unit tests (when done properly). For more dimensions, you get a nightmare of overloadings. So IMHO it is complete nonesense to try to implement different dimensions with different types like this (with compile-time checking). IMHO, there is no good way to do this in Ada as she is now.