Hacker News new | past | comments | ask | show | jobs | submit login

I admit the examples need some work. Note that the features are introduced one at a time, and each example tries to be self-contained in a few lines. This limits what they can convey. I'll definitely revisit them!

As for what the examples do, the lines with "===" show you what happens, eg.

    count = plumb([len , "baz"])
    count(None) == 3
The first line defines a "count" function, the second shows how it behaves. In this trivial example, "count" is just applying the "len" function to the string "baz". Since this call is happening in a function (ie. in [square brackets]), we need to actually call it in order to get the result. In other words, it's showing how to define thunks.

This is obviously silly for calculating a length, but can be handy for delaying expensive function calls.

> What if there were 1 nested bracket in the third line instead of 2? If I were scanning for bugs, I might not catch that quickly.

Did you read the intro? The "When not to use Plumb" section says "When your Plumb spans more than a couple of lines" ;)




The "delaying expensive function calls" part gave me more of a clue than anything. I still have to admit that I don't get the benefit of plumb over existing lambda syntax, and that benefit still would have to be weighed against the additional requirement of learning plumb syntax for someone new to my code base.

I did read "When not to use Plumb" but, from the example, was looking at a single line. I meant that that single line is difficult to look at and say, "My bug isn't in that line."


I originally wrote Plumb for PHP, which has much more cumbersome lambda notation than Python, so the Python port is less useful; it's more for completeness (I'm playing with a Haskell version too, which is even less necessary).

Since the main point of Plumb is that its syntax is compatible with other languages, we might as well embed it in anything that works :)

As a bonus, the Python version will curry everything you give it. This is nice, since non-curried functions are unnecessarily painful to work with, but you could do that without using Plumb.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: