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,c1400b61b3f80c1e X-Google-Attributes: gid103376,public,usenet X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news1.google.com!news1.google.com!proxad.net!feeder1-2.proxad.net!usenet-fr.net!club-internet.fr!feedme-small.clubint.net!npeer.de.kpn-eurorings.net!npeer-ng2.kpn.DE!newsfeed.arcor.de!newsspool1.arcor-online.net!news.arcor.de.POSTED!not-for-mail From: "Dmitry A. Kazakov" Subject: Re: Are there noticable differences in Ada acceptance by country? Newsgroups: comp.lang.ada User-Agent: 40tude_Dialog/2.0.15.1 MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Reply-To: mailbox@dmitry-kazakov.de Organization: cbb software GmbH References: <87d4pr6413.fsf@ludovic-brenta.org> <47e0fc15$0$89167$157c6196@dreader1.cybercity.dk> <13u2t1a2s141531@corp.supernews.com> <1fac7b25-a11f-4199-97ad-45688318e424@u69g2000hse.googlegroups.com> <1kv438li1fcvq.ox99qnglkog5.dlg@40tude.net> Date: Fri, 21 Mar 2008 08:52:38 +0100 Message-ID: <15bxm1vkv9k10.1s13j5278f2xn$.dlg@40tude.net> NNTP-Posting-Date: 21 Mar 2008 08:52:40 CET NNTP-Posting-Host: 65acb1f8.newsspool1.arcor-online.net X-Trace: DXC=TIf^Bk?Hm:6lIh70@4Fo<]lROoR18kF On Thu, 20 Mar 2008 22:17:18 +0000, Simon Wright wrote: > "Dmitry A. Kazakov" writes: > >> On Thu, 20 Mar 2008 20:22:22 +0000, Simon Wright wrote: >> >>> gpriv@axonx.com writes: >>> >>>> I think strong typing should not be dismissed. Unfortunately Java- >>>> based (and C/C++/C#) courses don't explain to students that X and Y >>>> coordinates being fundamentally integer (or float) types are not the >>>> same thing. >>> >>> I always disliked an X binding which had (sub)types for X, Y >>> coordinates. Wrong level of abstraction, I thought: use something like >>> >>> type Position is record >>> X : Float; >>> Y : Float; >>> end record; >>> >>> and you get a _lot_ less scope for confusion. >> >> If no rotations involved I would suggest: >> >> type Horizontal_Coordinate is new Float; >> type Vertical_Coordinate is new Float; >> type Position is record >> X : Horizontal_Coordinate; >> Y : Vertical_Coordinate; >> end record; >> >> In some cases I would consider making absolute positions and relative >> offsets different types, similar to Time and Duration. > > Well, to be fair, I suppose I would have used Metres (or Pixels) > rather than plain Float. > > subtype Metres is Float; I would probably use fixed point for that. > But I don't see the real advantage in using different types for H_C > and V_C. How ofen are users actually going to get this wrong? Quite often in GUI applications. > There is > some comment-like advantage to subtyping -- rather like AdaCore's > library packages with eg > > subtype Path_Name is String; Interesting, actually in my libraries, I indeed use Item_Path and Item_Name both different new types from String. That helped not to mix paths and names in the subprograms like Get_Directory, Get_Name, compose path from parent's path and name etc. I had some nasty bugs using Ada.Directories, which treats path and names subtypes, therefore I decided to make them separate types. > but full typing is only going to clutter the place up with > conversions. Or perhaps you lie to provide all the operations a person > could need (acceleration x duration -> speed etc)? Maybe. But these are different cases to me. I think it is true that dimensional algebra should be better built on subtypes. But dimensioned values are often applied to some reference points. Like distances measured from different places. These cannot be mixed even if they have same dimensions. So "meter" is more like "float." You could possibly wish to have type Distance_From_My_Office is new Meter; (Actually it should produce a whole new dimensional algebra of types.) > Why would things be different if there were rotations involved? Because with rotations coordinates become linear combinations with dimensionless coefficients. (The rotation matrix is a matrix exponent so that cannot be made dimensioned.) -- Regards, Dmitry A. Kazakov http://www.dmitry-kazakov.de