PROPOSAL: Return 'this'

Stefan Schulz schulz at e-spirit.de
Thu Mar 26 15:40:07 PDT 2009


Tom Hawtin schrieb:
> I think what disturbs me about these sort of 'with' extensions, is
> method resolution. How do we decide which object and method 'append'
> applies to. That area of the language is already broken by complexity.

As I wrote, it has some pitfalls. In my blog I noted down the order of 
resolution, which is the way one would expect it to be in Java, analog 
to using inner classes. This is a variant using an instance 
initialization block (legal Java code):

String string = new StringBuilder() {{
   append(person.getName());
   if (person.isMarried()) {
     append("(married)");
   }
}}.toString();

> I suspect that a reasonably complete solution in this area would not fit
> the definition of small, and would be the subject of much conflicting
> opinion. :(

As I, too, stated ;)

Stefan



More information about the coin-dev mailing list