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-Thread: 103376,635cd9622b25ae59 X-Google-Attributes: gid103376,public X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news2.google.com!news3.google.com!news4.google.com!newsfeed.stanford.edu!news.tele.dk!news.tele.dk!small.news.tele.dk!newsfeed.cw.net!cw.net!news-FFM2.ecrc.de!noris.net!newsfeed.arcor.de!news.arcor.de!not-for-mail Date: Thu, 27 Apr 2006 17:39:39 +0200 From: Georg Bauhaus User-Agent: Thunderbird 1.5.0.2 (Windows/20060308) MIME-Version: 1.0 Newsgroups: comp.lang.ada Subject: Re: Type safety, C++ and code generation References: <1146143954.169807.207080@t31g2000cwb.googlegroups.com> <1146148380.102042.119860@y43g2000cwc.googlegroups.com> In-Reply-To: X-Enigmail-Version: 0.94.0.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Message-ID: <445101bf$0$11061$9b4e6d93@newsread4.arcor-online.net> Organization: Arcor NNTP-Posting-Date: 27 Apr 2006 19:39:11 MEST NNTP-Posting-Host: f6ddbe12.newsread4.arcor-online.net X-Trace: DXC=fHNg?`DRaYka1IKbSTkC[i:ejgIfPPlddjW\KbG]kaMh]kI_X=5Keaf\m@?J;XLOUlhP3YJKgE\jlDVfi7HR?MomTaST0T@UMJo X-Complaints-To: usenet-abuse@arcor.de Xref: g2news2.google.com comp.lang.ada:3966 Date: 2006-04-27T19:39:11+02:00 List-Id: Maciej Sobczak wrote: > type ranged_type Speed; > Speed s1, s2, s3; // with some values > s1 = s2 + s3; // OK > s1 = s2 * s3; // not OK > > The addition is fine, but the multiplication should not be provided, > because speed multiplied by speed is not a speed. Can you extend your > class so that the compiler will refuse to compile the second operation > above? > (Ada, anyone? :) ) Just so it is visible: procedure useop is s1, s2, s3: SPEED; -- with some values begin s3 := s1 * s2; end useop; 8. s3 := s1 * s2; | >>> cannot call abstract subprogram "*" where package Op is type SPEED is range 0 .. 250; function "*"(a, b: SPEED) return SPEED is abstract; end Op;