Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.java.programmer > #2606

Re: Refactoring discovery

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 <dalamb@cs.queensu.ca>
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 <kbgoo6dfrkh58r3ogel9nb6rekrs258it2@4ax.com> <imi0cq$ah4$1@dont-email.me> <imjjus$2cj$1@lust.ihug.co.nz>
In-Reply-To <imjjus$2cj$1@lust.ihug.co.nz>
Content-Type text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding 7bit
Lines 38
Message-ID <e7Mkp.1468$0s5.314@newsfe17.iad> (permalink)
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

Show key headers only | View raw


On 25/03/2011 10:44 PM, Lawrence D'Oliveiro wrote:
> In message<imi0cq$ah4$1@dont-email.me>, 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).

Back to comp.lang.java.programmer | Previous | NextNext in thread | Find similar


Thread

Re: Refactoring discovery David Lamb <dalamb@cs.queensu.ca> - 2011-03-30 16:10 -0400
  Re: Refactoring discovery David Lamb <dalamb@cs.queensu.ca> - 2011-03-30 16:25 -0400
  Re: Refactoring discovery Joshua Cranmer <Pidgeot18@verizon.invalid> - 2011-03-30 17:31 -0400
    Re: Refactoring discovery markspace <-@.> - 2011-03-30 15:52 -0700
    Re: Refactoring discovery Lew <noone@lewscanon.com> - 2011-03-30 23:58 -0400

csiph-web