Path: csiph.com!x330-a1.tempe.blueboxinc.net!newsfeed.hal-mli.net!feeder1.hal-mli.net!border3.nntp.dca.giganews.com!border1.nntp.dca.giganews.com!nntp.giganews.com!npeer01.iad.highwinds-media.com!news.highwinds-media.com!feed-me.highwinds-media.com!post01.iad.highwinds-media.com!newsfe17.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.15) Gecko/20110303 Thunderbird/3.1.9 MIME-Version: 1.0 Newsgroups: comp.lang.java.programmer Subject: Re: Refactoring discovery References: In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Lines: 38 Message-ID: NNTP-Posting-Host: 67.193.237.254 X-Complaints-To: abuse@cogeco.net X-Trace: newsfe17.iad 1301515850 67.193.237.254 (Wed, 30 Mar 2011 20:10:50 UTC) NNTP-Posting-Date: Wed, 30 Mar 2011 20:10:50 UTC Date: Wed, 30 Mar 2011 16:10:48 -0400 Xref: x330-a1.tempe.blueboxinc.net comp.lang.java.programmer:2606 On 25/03/2011 10:44 PM, Lawrence D'Oliveiro wrote: > In message, Eric Sosman wrote: >> You'd want something that could attach names to the pieces of the >> assignment target, and match them up with names in the expression value. >> Something like >> int r, g, b; >> (r.red, g.green, b.blue) = backgroundColor; // drop alpha > > In Python you can write > r, g, b = (getattr(backgroundColor, f) for f in ("red", "green", "blue")) > But really, is it such a big deal? In conventional languages like C we > happily write > > q = y / z; > r = y % z; > > and leave it to the compiler to do the dataflow analysis for us. Quotient and remainder of division are a very special case. The hardware sometimes has a single operation that produces both, and knowledge that / and % are closely related operations is built into the language. With first = longComplexOperation(lots of arguments) second = anotherLongComplexOperation(same set of arguments) it's going to take a very sophisticated compiler to synthesize (first, second) = combinedLongOperation(same set of arguments) and it's going to have to solve the Halting Problem, too. We already write "combined operations" in other contexts. if (x.hasKey(y)) then x.addPair(y, someVeryBigThingIDidn'tWantToSysnthesizeUnlessIHadTo) sometimes gets implemented as whereToInsert = x.findLocation(y); if (whereToInsert.keyIsntAlreadyThere()) whereToInsert.addPair(y,...) Or possibly whereToInsert is internal state in x and x.addPair(y,z) is x.addAtSpotDeterminedByLastHasKey(z).