From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.5-pre1 (2020-06-20) on ip-172-31-74-118.ec2.internal X-Spam-Level: X-Spam-Status: No, score=-1.9 required=3.0 tests=BAYES_00 autolearn=ham autolearn_force=no version=3.4.5-pre1 Date: 15 Feb 93 01:55:33 GMT From: cis.ohio-state.edu!zaphod.mps.ohio-state.edu!sdd.hp.com!portal!cup.portal .com!R_Tim_Coslet@ucbvax.Berkeley.EDU Subject: Re: What's the difference between... Message-ID: <75650@cup.portal.com> List-Id: In article: adam@irvine.com (Adam Beneschan) wrote: >In article <75591@cup.portal.com> R_Tim_Coslet@cup.portal.com writes: >> Actually, if you know you are going to be multiplying mixed types >> (e.g. APPLES in a crate by CRATES to get APPLES in a shipment) just >> define a new multiply operator on the mixed types so the "conversion" >> is hidden and "units" are enforced by the compiler. >> >> R. Tim Coslet > >This only solves part of the problem, though. It's no problem to >define this function: > > function "*" (left : APPLES; right : CRATES) return APPLES; > >But ideally, you'd like a way to prevent the programmer from doing >something dumb like multiplying apples and apples. Well, if you REALLY want this level of control, creat a package with all your types in it and make them PRIVATE and only define the operations that are actually physically correct. Then the compiler catches everything at compile time. R. Tim Coslet Usenet: R_Tim_Coslet@cup.portal.com technology, n. domesticated natural phenomena