3 ms·
Arguably it's not a multi-line anonymous function, but several statement-level 'named variables' rather than block-level 'named variables'. Haskell doesn't real
by halo 18y ago
Arguably it's not a multi-line anonymous function, but several statement-level 'named variables' rather than block-level 'named variables'. Haskell doesn't really have the concept of "blocks" to begin with as it isn't an imperative language, so it's not really a fair comparison.
The Haskell solution is very similar to how Python currently deals with this situation, similar to your Perl and Lisp examples, by allowing named local functions within a block (rather than at statement-level), and also allowing a syntax for single-line anonymous functions (via "lambda").
I did actually ponder a Haskell-like syntax for Python, but decided it's less than ideal. Allowing assignment after a statement makes things more difficult to read, especially in imperative languages.