PROPOSAL: Return 'this'

Reinier Zwitserloot reinier at zwitserloot.com
Thu Mar 26 14:06:24 PDT 2009


That argument makes no sense. If you're concerned about lines, try:

with (object) { method1(); method2(); method3(); }


If your coding style guide says that you must neccessarily newline  
after braces and semicolons, then you should question why that rule  
exists, and why it would not exist for the builder pattern.

Incidentally, I like a return this proposal more, because I think it's  
lower impact (no new keyword, we're already familiar with methods that  
return themselves, a complete proposal would just enshrine this  
practice into canon), and looks better. Just saying that 'number of  
lines' is not a valid argument against.

  --Reinier Zwitserloot



On Mar 26, 2009, at 21:16, Marek Kozieł wrote:

> W dniu 26 marca 2009 19:30 użytkownik Gabriel Belingueres
> <belingueres at gmail.com> napisał:
>> Wouldn't it be simpler to add a Pascal-like "with" statement? This
>> would solve at least the method chaining issue:
>>
>> with(object) {
>>  method1();
>>  metohd2();
>>   ...
>>  methodN();
>> }
>>
>
> Simpler?
> Yes.
>
> Better?
> No. this would look like method execution from current class.
> This would be better:
> with(object) {
>  .method1();
>  .metohd2();
>   ...
>  .methodN();
> }
>
> Other problem are lines, this solution use n+2 lines: it's exactly
> kind of problem that people want to prevent.
>
> -- 
> Pozdrowionka. / Regards.
> Lasu aka Marek Kozieł
>
> http://lasu2string.blogspot.com/
>




More information about the coin-dev mailing list