3 ms·
Interesting, I didn't know about this at all. Is it that common in Scheme to write functions that immediately return other functions? Seems like an oddly "bless
by nerdponx 6y ago
Interesting, I didn't know about this at all. Is it that common in Scheme to write functions that immediately return other functions? Seems like an oddly "blessed" usage of syntax that IMO could be better used for something like pattern matching.
Looking at this example from the linked SRFI [0]:
(define ((greet-with-prefix prefix) suffix)
(string-append prefix " " suffix))
(define greet (greet-with-prefix "Hello"))
(greet "there!") => "Hello there!"
I'm not convinced that this is anything but an obfuscation, compared to the standard R5RS version:
(define (greet-with-prefix suffix)
(lambda (prefix)
(string-append prefix " " suffix)))
(define greet (greet-with-prefix "Hello"))
(greet "there!") => "Hello there!"
What do the experienced Schemers think?
[0]: https://srfi.schemers.org/srfi-219/srfi-219.html https://srfi.schemers.org/srfi-219/srfi-219.html
- watersb 6y agoYour second example is easy to understand. Reading the first example, from this proposal, made my eyes twitch. I haven't done a lot of Scheme since the 20th Century, though I re-visit SICP every couple of years.