Path: csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!aioe.org!news.glorb.com!npeer01.iad.highwinds-media.com!news.highwinds-media.com!feed-me.highwinds-media.com!post01.iad.highwinds-media.com!newsfe11.iad.POSTED!00000000!not-for-mail From: David Lamb User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.2.18) Gecko/20110616 Thunderbird/3.1.11 MIME-Version: 1.0 Newsgroups: comp.lang.java.programmer Subject: Re: Arithmetic overflow checking References: <015aeb15-57db-48ab-9cd4-77f8448b632f@w24g2000yqw.googlegroups.com> <2rydnez7l-H5BYnTnZ2dnUVZ_vGdnZ2d@earthlink.com> <4e278a67$0$309$14726298@news.sunsite.dk> <1SSVp.69032$_I7.18660@newsfe08.iad> In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Lines: 25 Message-ID: NNTP-Posting-Host: 67.193.237.254 X-Complaints-To: abuse@cogeco.net X-Trace: newsfe11.iad 1311446745 67.193.237.254 (Sat, 23 Jul 2011 18:45:45 UTC) NNTP-Posting-Date: Sat, 23 Jul 2011 18:45:45 UTC Date: Sat, 23 Jul 2011 14:45:41 -0400 Xref: x330-a1.tempe.blueboxinc.net comp.lang.java.programmer:6474 On 23/07/2011 12:04 PM, supercalifragilisticexpialadiamaticonormalizeringelimatisticantations wrote: > On 23/07/2011 11:23 AM, David Lamb wrote: >> On 21/07/2011 8:32 AM, Andreas Leitgeb wrote: >>> agreeCount = agreeCount.plus(AgreeCount.ONE) >>> on painfulness of non-primitive math. >> >> or if you think ++ is common enough: >> agreeCount.increment(); >> and generally >> agreeCount.add(someOtherAgreeCount) >> and if you decide to have your operators return "this" >> ac0.mul(ac1).plus(ac2)) // ac0 = ac0*ac1+ac2 >> or >> ac = (new AgreeCount(ac0)).mul(ac1).plus(ac2) // ac = ac0*ac1+ac2 > > Eww. Mutable number classes. > > I think I'm going to throw up. > It's what happens to ordinary ints in most machine languages. Feel free to define the less-efficient functional versions that always generate new objects. The main point was that the method calls aren't necessarily all that hard to read.