Suggestion: Change precedence of 'new'

Robert Fraser fraserofthenight at gmail.com
Thu Apr 10 12:29:54 PDT 2008


Georg Wrede wrote:
>>>
>>> Just to clarify, how would that look with the proposed precedence?
>>
>>
>> You mean what does it look like in java?  Like this:
>>
>>      new class Runnable {
>>          public void run() {
>>              if (canvas.isDisposed()) return;
>>              render();
>>              canvas.swapBuffers();
>>              canvas.getDisplay().timerExec(15, this);
>>          }
>>      }.run();
>>
>> (it's creating an anonymous subclass of 'Runnable', and running it.)
> 
> So, you gain the omission of one pair of parentheses, but lose in 
> expressional clarity. In the current version, it is very clear to the 
> reader (even to the one not familiar with the particular usage) what is 
> going on. With the proposal, one has to really think hard, if one is not 
> familiar with it from before. That's always a bad sign.
> 
> I'm not absolutely against this, but some more compelling examples would 
> go a long way.

I don't think that particular example is very difficult to read without 
the parentheses, but a new anonymous class expression is actually a 
different type of expression than a new expression, so now we're talking 
changing the precedence of two expressions.



More information about the Digitalmars-d mailing list