[plt-scheme] box in syntax question

From: Jos Koot (jos.koot at telefonica.net)
Date: Thu Nov 26 07:53:18 EST 2009

Consider the following code extracted from a larger piece of code:

#lang scheme

(define-syntax (make-box stx)
 (syntax-case stx ()
  ((_) #`#,(box 1))))

(define my-box (make-box))

(immutable? my-box) ; --> #t

The box delivered by the expander appears to be immutable, which seems appropriate. However, I do not understand how in this case an immutable box is produced. I checked with check-syntax. Indeed:

(define my-box (make-box)) ==> (define-values (my-box) '#&1)

But inspecting the expansion of (define-syntax (make-box stx) ...) I don't see how transformer make-box produces an immutable box.

NB. This is not a question how to produce a mutable box, for I could easily write
#'(box 1)) in stead of
#`#,(box 1) or even simpler:
(define (make-box) (box 1))
I am simply interested in the background mechanism.

Thanks, Jos
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.racket-lang.org/users/archive/attachments/20091126/ca771a5d/attachment.html>

Posted on the users mailing list.