# Pypes

**URL:** <https://www.ruby-forum.com/t/pypes/133102>\
**Category:** Ruby\
**Created:** [March 27, 2008, 7:22pm UTC](https://www.ruby-forum.com/t/pypes/133102 "2008-03-27T19:22:08Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![Martin\_DeMello](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/f17d59/32.png) [@Martin\_DeMello](https://www.ruby-forum.com/u/Martin_DeMello)\
**Post date:** [March 27, 2008, 7:22pm UTC](https://www.ruby-forum.com/t/pypes/133102/1 "2008-03-27T19:22:08Z")

</div>

[http://www.voidspace.org.uk/python/weblog/arch\_d7\_2008\_03\_22.shtml#e954](http://www.voidspace.org.uk/python/weblog/arch_d7_2008_03_22.shtml#e954)

Nice example of what you can do with generators. Is this sort of thing  
doable efficiently in 1.9?

martin

---

<div class="post-metadata">

**Author:** ![Martin\_DeMello](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/f17d59/32.png) [@Martin\_DeMello](https://www.ruby-forum.com/u/Martin_DeMello)\
**Post date:** [March 27, 2008, 7:34pm UTC](https://www.ruby-forum.com/t/pypes/133102/2 "2008-03-27T19:34:33Z")

</div>

On Mar 27, 2008, at 1:20 PM, Martin DeMello wrote:

> [http://www.voidspace.org.uk/python/weblog/](http://www.voidspace.org.uk/python/weblog/)  
> arch\_d7\_2008\_03\_22.shtml#e954
> 
> Nice example of what you can do with generators. Is this sort of thing  
> doable efficiently in 1.9?

Don’t know if this meets the criteria, but

[http://pragdave.blogs.pragprog.com/pragdave/2007/12/pipelines-using.html](http://pragdave.blogs.pragprog.com/pragdave/2007/12/pipelines-using.html)  
[http://pragdave.blogs.pragprog.com/pragdave/2008/01/pipelines-using.html](http://pragdave.blogs.pragprog.com/pragdave/2008/01/pipelines-using.html)

Cheers

Dave

---

<div class="post-metadata">

**Author:** ![Martin\_DeMello](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/f17d59/32.png) [@Martin\_DeMello](https://www.ruby-forum.com/u/Martin_DeMello)\
**Post date:** [March 27, 2008, 7:46pm UTC](https://www.ruby-forum.com/t/pypes/133102/3 "2008-03-27T19:46:59Z")

</div>

On Thu, Mar 27, 2008 at 11:33 AM, Dave T. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> Don’t know if this meets the criteria, but
> 
> [http://pragdave.blogs.pragprog.com/pragdave/2007/12/pipelines-using.html](http://pragdave.blogs.pragprog.com/pragdave/2007/12/pipelines-using.html)  
> [http://pragdave.blogs.pragprog.com/pragdave/2008/01/pipelines-using.html](http://pragdave.blogs.pragprog.com/pragdave/2008/01/pipelines-using.html)

Yes, exactly what I had in mind. Very nice.

martin

---

<div class="post-metadata">

**Author:** ![Martin\_DeMello](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/f17d59/32.png) [@Martin\_DeMello](https://www.ruby-forum.com/u/Martin_DeMello)\
**Post date:** [March 27, 2008, 7:52pm UTC](https://www.ruby-forum.com/t/pypes/133102/4 "2008-03-27T19:52:16Z")

</div>

On Thu, Mar 27, 2008 at 11:33 AM, Dave T. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> [http://pragdave.blogs.pragprog.com/pragdave/2007/12/pipelines-using.html](http://pragdave.blogs.pragprog.com/pragdave/2007/12/pipelines-using.html)  
> [http://pragdave.blogs.pragprog.com/pragdave/2008/01/pipelines-using.html](http://pragdave.blogs.pragprog.com/pragdave/2008/01/pipelines-using.html)

Tangentially, why did the trick of defining methods with the same name  
as classes, to delegate to Class.new, fall out of favour?

```
tripler = Transformer.new {|val| val * 3}

```

would read more nicely as

```
tripler = Transformer {|val| val * 3}

```

with def Transformer(x); Transformer.new(x); end

I remember it being a commoner practice a few years ago.

martin

---

<div class="post-metadata">

**Author:** ![Martin\_DeMello](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/f17d59/32.png) [@Martin\_DeMello](https://www.ruby-forum.com/u/Martin_DeMello)\
**Post date:** [March 27, 2008, 8:56pm UTC](https://www.ruby-forum.com/t/pypes/133102/5 "2008-03-27T20:56:17Z")

</div>

On Mar 27, 12:20 pm, “Martin DeMello” [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> [http://www.voidspace.org.uk/python/weblog/arch\_d7\_2008\_03\_22.shtml#e954](http://www.voidspace.org.uk/python/weblog/arch_d7_2008_03_22.shtml#e954)
> 
> Nice example of what you can do with generators. Is this sort of thing  
> doable efficiently in 1.9?

some\_date.filter1.filter2.action

What is the advantage of data filters over method chaining in  
practical terms? What am I missing?

Regards,

Dan

---

<div class="post-metadata">

**Author:** ![Martin\_DeMello](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/f17d59/32.png) [@Martin\_DeMello](https://www.ruby-forum.com/u/Martin_DeMello)\
**Post date:** [March 27, 2008, 9:24pm UTC](https://www.ruby-forum.com/t/pypes/133102/6 "2008-03-27T21:24:18Z")

</div>

Daniel B. wrote:

> practical terms? What am I missing?  
> Apparently, PragDave’s filters read one entry at a time, on demand (like  
> unix pipes). Method chaining has to build a complete collection for each  
> step.

---

<div class="post-metadata">

**Author:** ![Martin\_DeMello](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/f17d59/32.png) [@Martin\_DeMello](https://www.ruby-forum.com/u/Martin_DeMello)\
**Post date:** [March 27, 2008, 9:26pm UTC](https://www.ruby-forum.com/t/pypes/133102/7 "2008-03-27T21:26:04Z")

</div>

On Thu, Mar 27, 2008 at 6:51 PM, Martin DeMello  
[removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> with def Transformer(x); Transformer.new(x); end
> 
> I remember it being a commoner practice a few years ago.
> 
> martin

Some of us oldies still use it. But I seem to remember some people  
objected last time I suggested it (ruby-talk[160664]).

Regards,  
Sean

---

<div class="post-metadata">

**Author:** ![Martin\_DeMello](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/f17d59/32.png) [@Martin\_DeMello](https://www.ruby-forum.com/u/Martin_DeMello)\
**Post date:** [March 27, 2008, 9:44pm UTC](https://www.ruby-forum.com/t/pypes/133102/8 "2008-03-27T21:44:58Z")

</div>

Martin DeMello wrote:

> ```
> tripler = Transformer {|val| val * 3}
> 
> ```
> 
> with def Transformer(x); Transformer.new(x); end
> 
> I remember it being a commoner practice a few years ago.
> 
> martin

It looks like a typo when there is no method name after (what looks  
like) a constant name. There’s also the cognitive load of deciding  
whether “Transformer.meth” is “send :meth to the result of method  
Transformer()” or “send :meth to the value of constant Transformer”. My  
brain knows it is the latter, but my eyes don’t.

class T  
def self.meth; “T.meth” end  
def meth; “T#meth” end  
end  
def T; T.new; end

p T.meth  
p T().meth  
p T.new.meth

Quick, which one(s) are calling the class method, T#meth. But maybe  
that’s just me.

As long as we’re playing in the global space, I’d define a lower case  
method, #transformer. Saves a keystroke, too.
