-
Notifications
You must be signed in to change notification settings - Fork 8
More idiomatic Ruby #1
Comments
LOL. Just noticed who wrote all the code. Maybe I should criticize the specs while I'm at it. ;) |
Hey @booch - thanks for the suggestions! One thing to keep in mind is that we've got transducer libs for other langs, some OO (e.g. java), and some FP (e.g. Clojure) and need to consider the alignment of APIs across languages as we make API decisions. Not saying that alignment always trumps paradigm or lang-specific idioms, but there will likely be some tradeoffs. Also, it's early days and I don't want to do too much that will box us into a corner later. For example, building a DSL around a block passed to We're not accepting PR's (see https://github.com/cognitect-labs/transducers-ruby#contributing), but I'll take these ideas into consideration and credit you in any resulting commits (and reference them from this issue as well). Thanks! |
@dchelimsky I'd suggest using |
Yep, extend self is basically the same (except that the compose/transduce/etc will be public when Transducers module is included somewhere). Thanks! Why do I want this - because I'd like to have a cleaner api than writing Transducers.* or even T.* everywhere. It's much more convenient to have map/filter within object's/class's methods. |
And the ability to make code more convenient is basically free, ie: you don't need to patch any global state, you don't loose anything for that convenience :) |
Not to be a Debby Downer, but this doesn't feel at all like idiomatic Ruby.
I think the biggest improvement would be to mix in a
transduce
method intoEnumerable
, with a signature closer toEnumerable#reduce
. The other thing that feels wrong is that almost everything is a class method. It seems like a more idiomatic way to do it would be with a block usinginstance_eval
, so we could do something like:For composabilitiy:
I'll have to think about this some more, and see if I can contribute some code back to implement a more idiomatic way of doing this in Ruby, while keeping composability in mind.
The text was updated successfully, but these errors were encountered: