PROPOSAL: Return 'this'

Marek Kozieł develop4lasu at gmail.com
Thu Mar 26 15:19:01 PDT 2009


2009/3/26 Stefan Schulz <schulz at e-spirit.de>:
> As it happens, I have written about some "with" a while ago, that might
> have advantages to returning this (and surely pitfalls and
> disadvantages). The main idea is to have a block on an object that
> shifts the binding of this to the object itself (as the with being
> proposed here). There is also an alternative by Howard Lovatt, which is
> referenced in my post at:
> http://jroller.com/jadda/entry/support_for_operating_on_a
>
> My idea reuses the "do" keyword:
>
> object do {
>   method1();
>   method2();
>   method3();
> };
>
> It also proposes the block to result in the object itself:
>
> String str = new StringBuilder() do {
>   append(person.getName());
>   if (person.isMarried()) {
>     append("(married)");
>   }
> }.toString();
>
> Instead of blocks, one could think of using expressions as proposed by
> Neal Gafter in an earlier post.
> Though, I think this might be too big for Coin.
>
> Stefan
>
>

class Some{

   void method2(Object..)

   void test(Other other){
      other do {
        method1();
        method2(method2()); // unclear
        method2(Object..);
        method3();
      };
   }
}

class Some{

   void method2(Object..)

   void test(Other other){
      other do {
        .method1();
        .method2(method2()); // clear
        .method2(Object..);
        .method3();
      };
   }
}

We should focus to not create to many interactions, or make people to
wander about 'what's this code do?'
Will that be clear for someone who see method2 in same screen?
Is increasing kinds of blocks good way?
-- 
Pozdrowionka. / Regards.
Lasu aka Marek Kozieł

http://lasu2string.blogspot.com/



More information about the coin-dev mailing list