Path: csiph.com!x330-a1.tempe.blueboxinc.net!feeder1.hal-mli.net!news.glorb.com!postnews.google.com!d1g2000yqm.googlegroups.com!not-for-mail From: Paul Cager Newsgroups: comp.lang.java.programmer Subject: Re: Call by Result Date: Mon, 13 Jun 2011 07:53:43 -0700 (PDT) Organization: http://groups.google.com Lines: 28 Message-ID: <2b5e9cc3-e7c8-490b-bd9f-f91f1220751b@d1g2000yqm.googlegroups.com> References: <4df23fe3$0$12157$fa0fcedb@news.zen.co.uk> NNTP-Posting-Host: 81.94.213.9 Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable X-Trace: posting.google.com 1307976824 7606 127.0.0.1 (13 Jun 2011 14:53:44 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: Mon, 13 Jun 2011 14:53:44 +0000 (UTC) Complaints-To: groups-abuse@google.com Injection-Info: d1g2000yqm.googlegroups.com; posting-host=81.94.213.9; posting-account=VsWLXwoAAAB13M2Ptt5-Bo-K_zCx-zyw User-Agent: G2/1.0 X-Google-Web-Client: true X-Google-Header-Order: HNKRUAELSC X-HTTP-UserAgent: Mozilla/5.0 (Windows NT 5.1) AppleWebKit/534.24 (KHTML, like Gecko) Chrome/11.0.696.65 Safari/534.24,gzip(gfe) Xref: x330-a1.tempe.blueboxinc.net comp.lang.java.programmer:5288 On Jun 13, 5:59=A0am, Gene Wirchenko wrote: > What I want is reasonable code size. =A0Such segments as > the above are not too bad if there are only a few, but make it half a > dozen, say, and suddenly a short method is taking up most of a page. I'm not sure I understand the problem here. I think what you want to be able to write (but Java won't let you) is this: String ReturnString=3D""; boolean DidItWork=3DGetString(ReturnString); if (!DidItWork) { handleErrorOrThrowException(); } else { doSomethingWithString(); } Patricia and others have suggested that the idiomatic way in Java to do it is to use an exception like this: try { doSomethingWith(getString()); } catch (SomeErrorOccuredException e) { handleErrorOrThrowException(); } That looks perfectly reasonable to me.