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-7-bit X-Google-Thread: 103376,a5f77772dc1375a3 X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2002-05-23 03:15:23 PST Path: archiver1.google.com!news1.google.com!newsfeed.stanford.edu!newsfeeds.belnet.be!news.belnet.be!transit.news.xs4all.nl!not-for-mail From: Fraser Newsgroups: comp.lang.ada Subject: Re: Safe Units Handling in Ada Date: Thu, 23 May 2002 12:16:51 +0200 Organization: XS4ALL Internet BV Message-ID: <3CECC193.3050000@blancolioni.org> References: <3CEB7124.4050604@blancolioni.org> NNTP-Posting-Host: a80-126-24-12.adsl.xs4all.nl Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit X-Trace: news1.xs4all.nl 1022149065 23183 80.126.24.12 (23 May 2002 10:17:45 GMT) X-Complaints-To: abuse@xs4all.nl NNTP-Posting-Date: 23 May 2002 10:17:45 GMT User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.0rc2) Gecko/20020510 X-Accept-Language: en-us, en Xref: archiver1.google.com comp.lang.ada:24572 Date: 2002-05-23T10:17:45+00:00 List-Id: Stephen Leake wrote: > I've done some thinking about how this will integrate with my > Robotics code, and I'll need Cartesian vectors with units. I > currently have: [code snipped] > Now I'll have to have Meters_Cart_Vector_Type and > Velocity_Cart_Vector_Type, etc, with associated operations. Time will > remain a scalar :). > > Any thoughts on extending macks to output that? Someone will have to remind me how the cross product is calculated! This is just off the top of my head: unit Meters_Type; unit Seconds_Type; unit Velocity_Type is Meters_Type / Seconds_Type; vector Meters_Cart_Vector_Type is Meters_Type * 3; vector Velocity_Cart_Vector_Type is Velocity_Type * 3; There would have to be some sort of syntax for specifying the vector index type (or to ask for a record type instead). The operators + and - (binary and unary) would be provided, as well as a cross product if it's a 3 vector, and a dot product in any case. Maybe we don't need a vector keyword, since it's implied by the syntax "identifier operator constant-integer", but on the other hand there's no need to worry about keyword bloat in a language of this size. > I like the origin of "macks"; it warms my physics nerd heart :). Be > sure to put it in the package somewhere. Thanks! I was pretty tickled when I realised the letters spelled a word (sort of). Fraser.