Return 'this' proposal

Reinier Zwitserloot reinier at
Thu Mar 19 00:24:22 PDT 2009

I think you misunderstood, Joe.

The idea is not that you can do that with -any- method that returns  
void. The idea is that a method declares that it supports this, by way  
of a flag. This does not change either the signature of that method,  
or the type system. Just like the varargs flag, it's 'magic' that  
tells the code that calls the method that it can/needs to do something  
special (in the case of varargs, create an array. In the case of this  
idea, presume the result of the expression  
"a.methodWithTheReturnThisFlagEnabled()" is "a", and the method call's  
return value, if any, is completely ignored.

Any library author can go back and retro-actively add these markers  
(though obviously they should only do that if their methods always  
'return this;'), without breaking old code, or new code. If a library  
author feels this isn't a good idea, then they don't.

  --Reinier Zwitserloot

On Mar 19, 2009, at 07:52, Joseph D. Darcy wrote:

> Reinier Zwitserloot wrote:
>> Joe,
>> What's the coin viability for a proposal that does NOT change the  
>> type  system, but just introduces syntax sugar that translates:
>> expression.setBar().setBaz();
>> to:
>> TypeOfExpression $unique = expression;
>> $unique.setBar();
>> $unique.setBaz();
> I'm not in favor of language changes which retrofit a fluent  
> interface on an API not designed to have one.
> -Joe

More information about the coin-dev mailing list