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,FREEMAIL_FROM autolearn=ham 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!news2.google.com!news1.google.com!border1.nntp.dca.giganews.com!nntp.giganews.com!newsfeed00.sul.t-online.de!t-online.de!peer-uk.news.demon.net!kibo.news.demon.net!mutlu.news.demon.net!news.demon.co.uk!demon!not-for-mail From: Simon Wright Newsgroups: comp.lang.ada Subject: Re: Are there noticable differences in Ada acceptance by country? Date: Thu, 20 Mar 2008 22:17:18 +0000 Organization: Pushface Message-ID: 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> NNTP-Posting-Host: pogner.demon.co.uk Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: news.demon.co.uk 1206051439 13499 62.49.19.209 (20 Mar 2008 22:17:19 GMT) X-Complaints-To: abuse@demon.net NNTP-Posting-Date: Thu, 20 Mar 2008 22:17:19 +0000 (UTC) Cancel-Lock: sha1:aBdYlHWht+KeEebLrCmnV//ODAg= User-Agent: Gnus/5.11 (Gnus v5.11) Emacs/22.1.50 (darwin) Xref: g2news1.google.com comp.lang.ada:20518 Date: 2008-03-20T22:17:18+00:00 List-Id: "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; 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? There is some comment-like advantage to subtyping -- rather like AdaCore's library packages with eg subtype Path_Name is String; 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)? Why would things be different if there were rotations involved?