From: Trans Date: 2005-03-24T12:59:50+09:00 Subject: Re: RCR 296: Destructive methods return self Matt Maycock wrote: > So, why not have an operator -> such that > obj->method(*args, &block) > is equivalent to (and more efficient than) > lambda { > obj.method(*args, &block) > obj > } > and, then you can add in ()'s around for better chaining: > obj->(sort.replace(&blocky)) # Still returns obj > > Then, with destructive methods, you can have > obj->sort!->reject!(&no_like)... > > I think this makes sense since the `.' operator is well known as the > `member' operator and for objects, gets the appropriate method (as far > as most languages go). -> has the hanging notion of pointers from > c/c++, but it also makes a bit of conceptual sense here in that we're > sort of `piping' obj forward... the direction of forward is always -> > in left to right reading :-) Interesting. So you can dictate the return of 'self' from the outside with any method you choose irregardless of what it may normally return? Yet that doesn't seem at all useful for non-destructive methods. "obj->strip" would be pointless, I think. It would be more useful if any method could act destructively. As I suggested earlier: "obj!sort". Perhaps a better notation for this would be your suggestion "obj->sort". But this is all quite speculative given that matz has never seemed too keen in pursing generalized in-place modification. T.