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 02:59:58 PST Path: archiver1.google.com!news1.google.com!newsfeed.stanford.edu!newsfeeds.belnet.be!news.belnet.be!newsfeed.wxs.nl!newsfeed.wirehub.nl!transit.news.xs4all.nl!not-for-mail From: Fraser Wilson Newsgroups: comp.lang.ada Subject: Re: Safe Units Handling in Ada Date: Thu, 23 May 2002 12:01:25 +0200 Organization: Anago Message-ID: <3CECBDF5.8050002@anago.nl> References: 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 1022148142 19930 80.126.24.12 (23 May 2002 10:02:22 GMT) X-Complaints-To: abuse@xs4all.nl NNTP-Posting-Date: 23 May 2002 10:02:22 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:24570 Date: 2002-05-23T10:02:22+00:00 List-Id: Russ wrote: > I downloaded this, and it contains a large number of files. Yes, this is a problem. That's mainly because none of you have WL, GCS or Sourcegen installed (but since I've never released them, you don't have to feel bad). > Perhaps you could > explain how it works and give a simple example. Yes, that's a good idea. The important bits as far as units are concerned is under the Macks package hierarchy. Macks.Parser reads a source file which describes the system, and Macks.Writer emits Ada source code. Macks.Table is a simple symbol table. Each unit type in the Macks source file has a number of operator functions generated for it. Common to all units are the following: function "*" (Left, Right : Unit) return Unit is abstract; function "/" (Left, Right : Unit) return Unit is abstract; function "*" (Left : Float_Type; Right : Unit) return Unit; function "*" (Left : Unit; Right : Float_Type) return Unit; function "/" (Left : Unit; Right : Float_Type) return Unit; function "/" (Left : Unit; Right : Unit) return Float_Type; Derived units have in addition operators corresponding to their definition or definitions in the .macks file; for example, if Speed is Meter / Second; then the following operators are generated: function "/" (Left : Meter; Right : Second) return Speed; function "*" (Left : Speed; Right : Second) return Meter; function "*" (Left : Second; Right : Speed) return Meter; function "/" (Left : Meter; Right : Speed) return Second; The file example.macks contains a simple Macks specification, which only deals with a few derived units. However, that's enough to create an 800 line Ada package spec (which is what motivated this sort of thing in the first place). Macks.Driver is the main procedure; with Gnat you can use the command gnatmake -o macks macks-driver.adb to get an executable; this can be invoked with macks example.macks for example. .macks generates .ads and .adb. To use the generated files, with and use/use type them, then declare your quantities and act natural. If operations that should work don't, let me know. I hope this helps; more thorough documentation is expected shortly. cheers, Fraser.