On 2020-01-16 22:35, Arne Babenhauserheide wrote:
Can we get this into the Scheme standard, too?
If you want a portable implementation, you can actually hack it using
macros. Re-define lambda, define, let(*,-values,letrec,letrec*) and
begin to rewrite everything to letrec and you are done! The problem is
that it will be slower than using let* for the bindings that don't
require letrec in many schemes, since the don't do the equivilent of
guile's letrectification pass (described in the paper "Letrec done right
(reloaded)" iirc).
I have a syntax-rules implementation of it if you are interested, that
also supports a simplified define-like binding that converts to let*.
That one does _not_ convert the body to one letrec, only defines
following eachother.
so
(define a 1)
(when (even? a) (error "ERROR"))
(define b 2)
becomes
(letrec ((a ...))
(when (even? a) (error "ERROR"))
(letrec ((b 2))
...)
This is not compatible with guile, but is trivial to fix!
Trivially portable to any other scheme, since it uses no fancy features
except the usual module things:
https://hg.sr.ht/~bjoli/guile-define/