3 ms·
Having written both imperative and having written a lot of FP code in Scheme, I somehow find the passing of lambdas to be more readable by now. I think it is a
by zelphirkalt 6y ago
Having written both imperative and having written a lot of FP code in Scheme, I somehow find the passing of lambdas to be more readable by now.
I think it is a matter of individual taste or matter of what one has used a lot recently. I like to be able to minimalize the things I need to keep in mind at one moment. The lambdas are in themselves sort of units of code, which I can look at separately, without considering the path, how the execution of the code gets there. They do not have side-effects except for printing something (lets not be too strict, but yes OK that's a side-effect as well, but it has to live somewhere). If only I give these lambdas to other procedures in the right places, then if the lambda is correct, the whole will work correctly. I can focus on that one lambda or generalized I can focus on that one expression, instead of keeping the surrounding code in mind.
Such kind of style makes it simple to copy paste expressions and be sure, that they work the same in a different place. For which I actually like the parentheses a lot (again an individual preference), because they are natural markers for start and end of an expression and I can have a key binding, which allows me to copy, cut, wrap, replace, whatever, that expression. This also applies to forms like lets or bindings introduced in lets, so even smaller parts than whole expressions. Basically ease of code editing.
- kkylin 6y agoI remember trying to grok Sussman's pattern matching code for 6.001. IIRC this was written in CPS or CPS-like way. It seemed very foreign at the time, but when I finally thought I got it, it made sense. I don't find search & backtracking easy no matter what one does, but as you say, continuations + good discipline makes it easier to focus on one thing at a time.