soegaard / whalesong

Whalesong: Racket to JavaScript compiler
http://hashcollision.org/whalesong
145 stars 14 forks source link

Replace letrec and letrec-values in kernel.rkt #1

Closed soegaard closed 2 years ago

soegaard commented 10 years ago

The latest Racket compiles the racket letrec and letrec-values into bytecode that checks for access to uninitialized values via check-for-unsafe-undefined. The easiest solution to fix Whalesong is to add these definitions of letrec and letrec-values to kernel.rkt.

(define-syntax (letrec stx) (syntax-parse stx [(_ ([id expr] ...) body ...) (syntax/loc stx (let ([id 'undefined] ...) (set! id expr) ... (let () body ...)))]))

(define-syntax (letrec-values stx) (syntax-parse stx [(_ ([(id ...) expr] ...) body ...) (syntax/loc stx (let ([id 'undefined] ... ...) (set!-values (id ...) expr) ... (let () body ...)))]))