←back to thread

88 points azhenley | 1 comments | | HN request time: 0.291s | source
Show context
shakna ◴[] No.45156755[source]
Probably worth noting that there's already an SRFI for this. [0] And that macro will work on any Scheme implementing the standard since about '98.

    (define-syntax rec
      (syntax-rules ()
        ((rec (NAME . VARIABLES) . BODY)
         (letrec ( (NAME (lambda VARIABLES . BODY)) ) NAME))
        ((rec NAME EXPRESSION)
         (letrec ( (NAME EXPRESSION) ) NAME))))
[0] https://srfi.schemers.org/srfi-31/srfi-31.html
replies(1): >>45158655 #
1. skrishnamurthi ◴[] No.45158655[source]
1. This isn't the same. `rec` names the function. This does not name the function. The point is to illustrate how the name-capture works.

2. The README literally says "Don't Use This Macro!" and references `rec` to use instead:

https://github.com/shriram/anonymous-recursive-function?tab=...