2 ms·
Addition appeared in imperative languages first. Does that mean addition is imperative? It's great that functional languages were first to catch onto these ide
by Veedrac 11y ago
Addition appeared in imperative languages first. Does that mean addition is imperative?
It's great that functional languages were first to catch onto these ideas, but that doesn't mean that anything else that uses them becomes functional. The interface isn't even functional, since in code like
foo = iter((1, 2, 3))
{x for x in foo}
`foo` is mutated. No "true" functional language would accept that ;).
- willtim 11y agoAddition, as implemented by Python, is functional. There are no side effects. A fully imperative encoding of addition would be eg. the x86 add instructions. John Backus gave us "functional" arithmetic with Fortran, but realised all values should should be treated this way, not just numbers. I take your point about the iterators being mutated and the loss referential transparency. That's certainly not functional programming.
- Veedrac 11y ago> Addition, as implemented by Python, is functional. Sure, but Python wasn't the first imperative programming language. (An aside: that's not strictly true anyway; the error thrown when you do 1 + [] is a side effect.)