Earlier quoted context omitted.
Nothing but when you nest them a whole bunch they are far harder to read and understand that if/else.
I frankly find it hard to imagine an expression form of if...else that's more readable than either the JS or Scheme versions of the code. In fact, I believe the problem with the JS example's readability is the formatting. Here's how I'd format the same code, and I find this quite readable: function deriv(exp, variable) { return is_number(exp) ? 0 : is_variable(exp) ? is_same_variable(exp, variable) ? 1 : 0 : is_sum(e…
function deriv(exp, variable) {
return if(is_number(exp))
0
else if(is_variable(exp))
if(is_same_variable(exp, variable))
1
else
0
else if(is_sum(exp))
make_sum(
deriv(addend(exp), variable),
deriv(augend(exp), variable)
)
else if(is_product(exp))
make_sum(
make_product(multiplier(exp), deriv(multiplicand(exp), variable)),
make_product(deriv(multiplier(exp), variable), multiplicand(exp))
)
else error(exp, "unknown expression type -- deriv");
}