Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!us.feeder.erje.net!newsfeed.straub-nv.de!eternal-september.org!feeder.eternal-september.org!.POSTED!not-for-mail From: Joshua Cranmer Newsgroups: comp.lang.java.programmer Subject: Re: refactoring problem Date: Sun, 03 Feb 2013 11:54:49 -0600 Organization: A noiseless patient Spider Lines: 20 Message-ID: References: <7fssg8dakvofmv6pk3sfvp5jmaku55vgmm@4ax.com> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Injection-Date: Sun, 3 Feb 2013 17:54:36 +0000 (UTC) Injection-Info: mx05.eternal-september.org; posting-host="95ab4c362dcce54022543f80bbbb46d3"; logging-data="7256"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX196+Z8lCA6PLujjpUpLlF7HlV/MM8+NXmE=" User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:17.0) Gecko/20130107 Thunderbird/17.0.2 In-Reply-To: <7fssg8dakvofmv6pk3sfvp5jmaku55vgmm@4ax.com> Cancel-Lock: sha1:I7uK/dO5GbmceBrsuHyFq2+/+WQ= Xref: csiph.com comp.lang.java.programmer:22050 On 2/3/2013 8:30 AM, Roedy Green wrote: > I think, why can methods have multiple inputs, but only one output? I > have been thinking that for about 50 years, and it ,seems unlikely to > change soon. The short answer is that grammar makes N-ary arguments easy to express but N-ary returns difficult. Function calls evaluate to a value, so to implement N-ary returns, you have to effectively make tuples first-class values and treat multiple return values as tuple unpacking. In explicitly-typed languages like Java, this would make doing things like initializing multiple values of different types from a multiple-returned value syntactically annoying. Note that this issue doesn't exist in function calls, where the syntax of function calls makes it very easy to expand to more arguments by using an un(der)used "operator", i.e., the comma operator. -- Beware of bugs in the above code; I have only proved it correct, not tried it. -- Donald E. Knuth