Path: csiph.com!x330-a1.tempe.blueboxinc.net!newsfeed.hal-mli.net!feeder1.hal-mli.net!border3.nntp.dca.giganews.com!Xl.tags.giganews.com!border1.nntp.dca.giganews.com!nntp.giganews.com!local2.nntp.dca.giganews.com!nntp.earthlink.com!news.earthlink.com.POSTED!not-for-mail NNTP-Posting-Date: Sun, 24 Jul 2011 14:53:13 -0500 Date: Sun, 24 Jul 2011 12:53:07 -0700 From: Patricia Shanahan User-Agent: Mozilla/5.0 (Windows NT 5.2; WOW64; rv:5.0) Gecko/20110624 Thunderbird/5.0 MIME-Version: 1.0 Newsgroups: comp.lang.java.programmer Subject: Re: Arithmetic overflow checking References: <015aeb15-57db-48ab-9cd4-77f8448b632f@w24g2000yqw.googlegroups.com> <4e262731$0$314$14726298@news.sunsite.dk> <4e26300b$0$309$14726298@news.sunsite.dk> <4e26b4ed$0$2501$db0fefd9@news.zen.co.uk> <4e28097f$0$2533$da0feed9@news.zen.co.uk> <7a23c9d2-508f-4dbd-af91-8cdf2a9764e1@p29g2000pre.googlegroups.com> In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Message-ID: Lines: 23 X-Usenet-Provider: http://www.giganews.com NNTP-Posting-Host: 70.230.200.239 X-Trace: sv3-rPbRVio5SKI2MlkkoQFjoF7d+E/2mCTJtoTx6QXolPLx1iQU+zLSSrZ/LMIxWvR0bHj9lTW82OoIs+t!kL4Qnh9Aaf/bjB0JUfTIa5vqyq13BZ0YH1skvAAL0F7jjOHy5FmcDOKa2Tb1fozHY4BL0FnQSvoD!1aznwRtaNvz1rsB3jY7f68IuhXSqFQOczmv/E3bA83dTGxw= X-Abuse-and-DMCA-Info: Please be sure to forward a copy of ALL headers X-Abuse-and-DMCA-Info: Otherwise we will be unable to process your complaint properly X-Postfilter: 1.3.40 X-Original-Bytes: 2849 Xref: x330-a1.tempe.blueboxinc.net comp.lang.java.programmer:6517 On 7/24/2011 11:09 AM, markspace wrote: > On 7/24/2011 10:54 AM, Patricia Shanahan wrote: >> meanwhile complex would be forced to provide a meaningless conversion to >> byte. > > > It could just throw an error. Collections uses this technique to make > unmodifiable Collection's. An unmodifiable List for example throws > UnsupportedOperation if add() is invoked. 'Taint the prettiest but it > works. > > As well as not being particularly pretty, it changes what could be a compile time error to an exception during execution. Note that misuses of arithmetic operator overloading can use exactly the same technique - extend Number and throw exceptions for the Number methods. I still don't see the advantage over a marker interface. Patricia