Hacker News new | ask | show | jobs
by dustingetz 3462 days ago
fluent interfaces from OOP are different than composition because they mutate-and-return the object reference; if the instance is aliased anywhere else in the program there is spooky-action-at-a-distance. Composition is about programming with values without mutation. As far as syntax goes it is a trivial macro to translate `x.f().g()` into `g(f(x))` (clojure actually provides it : http://clojure.org/guides/threading_macros)
1 comments

> they mutate-and-return....

Not necessarily; you can easily write instance methods which merely copy the existing object.