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 09:04:10 PST Path: archiver1.google.com!news1.google.com!newsfeed.stanford.edu!newsfeed.berkeley.edu!ucberkeley!hammer.uoregon.edu!skates!not-for-mail From: Stephen Leake Newsgroups: comp.lang.ada Subject: Re: Safe Units Handling in Ada Date: 23 May 2002 12:03:41 -0400 Organization: NASA Goddard Space Flight Center (skates.gsfc.nasa.gov) Message-ID: References: <3CEB7124.4050604@blancolioni.org> <3CECC193.3050000@blancolioni.org> NNTP-Posting-Host: anarres.gsfc.nasa.gov Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: skates.gsfc.nasa.gov 1022170242 7245 128.183.220.71 (23 May 2002 16:10:42 GMT) X-Complaints-To: usenet@news.gsfc.nasa.gov NNTP-Posting-Date: 23 May 2002 16:10:42 GMT User-Agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.2 Xref: archiver1.google.com comp.lang.ada:24588 Date: 2002-05-23T16:10:42+00:00 List-Id: Fraser writes: > Someone will have to remind me how the cross product is calculated! I've got a generic vector package that does everything I need. It's in SAL at http://users.erols.com/leakstan/Stephe/Ada/Sal_Packages/index.htm, file sal-gen_math-gen_vector.ads. It's instantiated in files sal-gen_math-gen_dof_3.ads and sal-gen_math-gen_dof_6.ads. That's what I need adapted to units. > 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; > This looks promising. I think it should be in a second input file, and produce a second package; some parts of the system need vectors, some don't. > There would have to be some sort of syntax for specifying the vector > index type (or to ask for a record type instead). Yes; I use an enumeration type for some vectors, integers for others. > 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. And lots more in my package. > 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. Yes, make it easy to parse, and easy to generate friendly error messages. -- -- Stephe