Path: csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!gegeweb.org!de-l.enfer-du-nord.net!feeder2.enfer-du-nord.net!feeder.erje.net!usenet.ukfsn.org!not-for-mail From: Martin Gregorie Newsgroups: comp.lang.java.programmer Subject: Re: Call by Result Date: Sun, 12 Jun 2011 10:53:24 +0000 (UTC) Organization: UK Free Software Network Lines: 38 Message-ID: References: NNTP-Posting-Host: 84.45.235.129 Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Trace: localhost.localdomain 1307876004 23674 84.45.235.129 (12 Jun 2011 10:53:24 GMT) X-Complaints-To: usenet@localhost.localdomain NNTP-Posting-Date: Sun, 12 Jun 2011 10:53:24 +0000 (UTC) User-Agent: Pan/0.133 (House of Butterflies) Xref: x330-a1.tempe.blueboxinc.net comp.lang.java.programmer:5230 On Sat, 11 Jun 2011 21:06:32 +0000, Andreas Leitgeb wrote: > > I wouldn't exactly call that a "catch". If you change the return type > of a method, you'd f...ing better have a look at all call-sites ;-) At > least, the compiler will help you, if it finds old sGetString() still > referenced somewhere. Without changing the name along with the return- > type, you *might* not notice all calls, and end up with a runtime-crash. > Depends what you're doing. I agree if you, say, are changing the return value from int to long int, but if you change from returning a string value to returning a pointer to an internally allocated string, then the amount of un-necessary work can be quite large. > There's an entirely different catch, however, namely that people might > change the type but *not* the name, and you end up with the same trouble > as without HN, except wrong expectations on seeing sGetString() which > maybe has been changed to return an Integer. > Yes, agreed. I've seen that too. My other objection is three-fold: HN is ugly, it tends to obscure the meaning if a function name, and it goes against Kernighan & Pike's naming recommendations in "The Practise of Programming", which IMO is essential reading for any fledgling programmers regardless of the language they are using. IIRC the original MS C compilers (along with other pre-ANSI C compilers, I should add) weren't nearly as good as their rivals, such as Borland C, so I've always wondered if the use of HN was introduced as a way of forcing the programmer cover for compiler deficiencies in reporting data type mismatches. -- martin@ | Martin Gregorie gregorie. | Essex, UK org |