Greg Ewing writes:
- Very often [mathematicians] *do* write out the subsequently-defined terms formally.
It strikes me that this is just the tension between the declarative style of coding, and the imperative style of doing the same thing. *The same code ends up being written* (modulo a bit of syntactic sugar like "where:" or "given:"), just the statement order is permuted.
I have nothing against the declarative style. But at least for these simple examples including this syntax in Python violates TOOWTDI, and my experience in Lisp is that indeed the extra flexibility hinders readability because whichever style one personally favors, lots of folks use the other one.
Python already allows you to (verbosely) use this style, anyway.
def behavior_of_experimental_subject (subject):
def behavior(now, later): return now + later
now = subject.randomness() later = subject.perversity() return behavior(now, later)
My feeling here is that if the declarative order is not sufficiently important to justify the local function and the extra return statement, using the imperative order won't be that costly in readability terms.