Re:Legible Mathematics: Sketches of interactive arithmetic f...
by andrewla on Monday February 24, 2020 @02:39PM
(#22407598)
I think S-expressions are annoying in that they tend to infect a language. If you're not careful, every function invocation becomes an s-expr, and you're left with the idea that + is no different from any other function, so we could write things like "plus(a, b, divide(c,2))" if we wanted to make a functional notation. And S-exprs don't save us from associativity, here you've made + associative, which is, fine, I guess, but what does (- a b c) mean, or (/ a b c)? This sort of asymmetry is a burden that isn't worth dealing with in my mind.
On thing that I think imperative languages bring to the table is naming intermediate values through assignment, so we can do things like
base_index = root_index + offset
midpoint = length / 2
final_index = base_index + midpoint
It's rarely useful to be so verbose, but it's nice to have the ability.
Re:Legible Mathematics: Sketches of interactive arithmetic f...
by BalinKing on Tuesday February 25, 2020 @12:37AM
(#22411158)
(Assuming I'm understanding correctly,) I'm honestly curious why `+` _should_ be different from any other function.
(Also, AFAIK the ability of naming intermediate values is totally separate from imperativeness; see Haskell's `let` form, for example.)
Or how about... (+ a b (/ c 2))