resyntax
resyntax copied to clipboard
Pull `let` out of function arguments
#lang resyntax/test
test: "let in function argument can be extracted"
--------------------
#lang racket
(define (f)
(g (let ([x 42])
(* x 2))
(let ([y 100])
(* y 3))))
--------------------
--------------------
#lang racket
(define (f)
(define x 42)
(define y 100)
(g (* x 2)
(* y 3)))
--------------------
This is only safe when it can be proved that g isn't a macro and that the surrounding expression is a function application expression. The best way to do this would probably be for either Resyntax or the Racket macro expander to look at the expanded code and add a syntax property to all function application expressions.
Note: this can change evaluation order and may not be safe when some of the argument expressions have side effects.