Is it possible to specify mutually-recursive scope in Redex without an
extra layer of nesting expression? I found this example for letrec:

https://github.com/racket/redex/blob/master/redex-examples/redex/examples/letrec.rkt#:34
34  #:binding-forms
...
37  (letrec ([x e_x] ...) #:refers-to (shadow x ...) e_body
#:refers-to (shadow x ...))

But this binding specification for letrec does not work for `define' forms:

expr ::= .... (λ (x_arg ...) (define x_def expr_def) ... expr_body)

I wish to allow (expr_def ...) to refer to (x_def ...) and that (x_def
...) will shadow (x_arg ...), but placing `#:refers-to (shadow x_def
...)' next to expr_def does not work. The workaround I found either
requires an extra nesting level or failed for the first define form.
How to solve this?

;; does not work
#:binding-forms
(λ (x_arg ...)
  (define x_def expr_def) #:refers-to (shadow x_def ... x_arg ...) ...
  expr_body #:refers-to (shadow x_def ... x_arg ...))

;; workaround 1, works mostly but failed for the first definition
#:binding-forms
(λ (x_arg ...)
  (define x_def expr_def)
  #:...bind (vars-defined
             (shadow x_def vars-defined)
             (shadow x_def vars-defined))
  expr_body #:refers-to (shadow vars-defined x_arg ...))

;; workaround 2, requires an extra nesting level
(expr ::= .... (λ (x_arg ...) (begin (define x_def expr_def) ... expr_body)))
#:binding-forms
(λ (x_arg ...)
  (begin
   (define x_def expr_def) ...
   expr_body)  #:refers-to (shadow x_def ... x_arg ...))

;; the term being tested:
(term
 (λ (x)
   (define f (λ (tt) g))
   (define g (λ (tt) h))
   (define h (λ (tt) f))

   (define x (λ (tt) x))

   g))

-- 
You received this message because you are subscribed to the Google Groups 
"Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to