On Thu, Mar 08, 2012 at 11:54:21PM +0100, deadalnix wrote: > Le 08/03/2012 07:15, Jonathan M Davis a écrit : > >On Thursday, March 08, 2012 00:52:57 Nick Sabalausky wrote: > >>"Ary Manzana"<a...@esperanto.org.ar> wrote in message > >>news:jj94mb$1i7v$1...@digitalmars.com... [...] > >>parent_ids = > >> results > >> .map{|x| x['_source']['parent_ids']} > >> .flatten.uniq > >> .compactHash[ > >> Site.find(parent_ids).map{|x| [x.id, x]} > >> ] > > > >I actually tend to find code like that hard to read, because all of > >the operations are inside out in comparison to normal. But since the > >only difference between his example and yours is the formatting, I > >agree yours is easier to read. Still, I'd much prefer if such code > >didn't use UFCS, since I find it much harder to read that way. It's > >just so backwards. > > > >- Jonathan M Davis > > You got tricked by your experience. You are used to read backward. > The function are written in the order they are executed in the example > above. This isn't very traditional, and may be the reverse order of > what people expect due to previous experience, but definitively is the > forward way.
Yeah, modern function composition syntax is totally backwards. This is most obvious when you use the f∘g notation in math. It means f(g), that is, apply g first, then f. So if you use this notation in functional programming, writing something like a∘b∘c∘d∘e∘f means run steps a..f *backwards*. Written on multiple lines, it totally goes against the flow of control. It's the programming language version of top-posting. ;-) Unfortunately, the alternative is reverse Polish notation, which isn't all that readable either. Chained object notation is a good compromise, which happens quite often when you use jQuery: $(selector) .html(htmlcode) .add(more_nodes) .css(some_styles) .filter(unwanted_nodes) .click(click_handler) .show(); Writing this in function composition order would cause an instant quantum leap in unreadability. T -- I see that you JS got Bach.