I have Scheme interpreter written in JavaScript. And named let macro expand into letrec with lambda expression. But the problem is the Petrofsky let
(test.failing "std: Petrofsky let"
(lambda (t)
(t.is (let - ((n (- 1))) n) -1)))
It expands into:
(letrec ((- (lambda (n) n))) (- (- 1)))
Is there a way to implement named let as scheme code that will work for Petrofsky let and return -1? Or do I need to implement named let as a basic construct in JavaScript?
I will probably implement it in JavaScript, because named let was kind of quick hack added without thinking. But I still want to know if it's possible to do this in Scheme.
I came up with this implementation:
Where
#:argsis unique value that can't appear inside user code. In my case, it was a gensym.