"H. S. Teoh" <hst...@quickfur.ath.cx> wrote in message news:mailman.275.1331250663.4860.digitalmar...@puremagic.com... > 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.
That's why I'll always use std.functional.pipe instead of std.functional.compose. (Though if my math background was stronger than my programming backgroud, I'd probably prefer std.functional.compose) >It's the programming language version of top-posting. ;-) > Forth using like just It's. > Unfortunately, the alternative is reverse Polish notation, which isn't > all that readable either. > My Calculus class in high-school uses a graphing calculator that used reverse polish notation. I had less trouble with it than some of the students because of my programming background and prior understanding of stacks. But boy did it still seem goofy. I like the TI's so much better. > 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. > Ziggy says there's an 80% chance you're here to decrease excess parenthesis nesting and set straight what once went backwards.