3 ms·
Am I the only one who thinks yuck? Instead of writing: a().b().c().d(), it's much nicer to write: d(c(b(a()))), or perhaps (d ∘ c ∘ b ∘ a)().
by amelius 2y ago
Am I the only one who thinks yuck?
Instead of writing: a().b().c().d(), it's much nicer to write: d(c(b(a()))), or perhaps (d ∘ c ∘ b ∘ a)().
- vinceguidry 2y agoWhy, if you don't have to, would you write the functions in reverse order of when they're applied?
- gloxkiqcza 2y agoPresumably because they’ve been doing so for decades so it seems logical and natural in their head while the new thing is new and thus unintuitive.
- dboreham 2y agoBecause it makes more sense?
- Mond_ 2y agoDoes it actually make more sense, or is it just more familiar?
- kortex 2y agoI would wager within a rounding error, all humans have a lifetime of experience in following directions of the form: 1. do the first step in the process 2. then do the next thing 3. followed by a third action I struggle to think of any context outside of programming, retrosynthesis in chemistry, and some aspects of reverse-Polish notation calculators, where you conceive of the operations/arguments last-to-first. All of which are things typically encountered pretty late in one's educational journey.
- amelius 2y agoConsistency is more important. If you ever wrote: a(b()) then you're already breaking your left-to-right/first-to-last rule.
- ndriscoll 2y agoThere are some math books out there that use (x)f. My understanding is (some) algebraists tried to make it a thing ~60 years ago but it never really caught on.
- hollerith 2y agoThere are, but they leave out the parens and use context to distinguish function application from multiplication.
- regular_trash 2y agoThis is a foolish consistency, and a contrived counterexample. Consistency is not an ideal unto itself.
- deleted 2y ago[deleted]
- nh23423fefe 2y agofunction application is right associative?
- tgv 2y agoIt's a bit snarky, but would you rather write FORTH then? So instead of draw(line.start, line.end); print(i, round(a / b)); you'd write line.start, line.end |> draw; i, a, b |> div |> round |> print;
- sph 2y agoStill too much syntax for a Forth. It should be line.start line.end draw i a b div round print
- deleted 2y ago[deleted]
- deleted 2y ago[deleted]
- queuebert 2y agoIt probably wouldn't hurt for languages to steal more ideas from APL.
- duped 2y agoA subtlety that I think many people overlook is that putting function application in lexicographical order means that tools can provide significantly better autocomplete results without needing to add a magic keybinding.
- adzm 2y agoWhen a b c d are longer expressions, the pipeline version looks more readable especially when split on multiple lines since it only has one level of indentation and you don't have to think about the number of parentheses at the end.
- archargelod 2y agoAdd a couple more arguments to each function and you'll get that first variant is a lot nicer: a(axe).b(baz, bog).c(cid).d(dot) vs d(c(b(a(axe), baz, bog), cid), dot)