[plt-scheme] Expand-syntax and fully expanded programs

From: Jens Axel Søgaard (jensaxel at soegaard.net)
Date: Thu Jul 16 19:13:59 EDT 2009

Is it possible for expand-syntax to non-fully expanded code?
I am seeing lambda-s instead of #%plain-lambda-s.

Consider the following:

The file "a.scm" contains:

#lang scheme/base
(require (for-syntax scheme/base))
(provide x inc-x! mx)
(define x 0)
(define-syntax mx (lambda (stx) #'x))
(define (inc-x!) (set! x (+ x 1)))
(if 1 2 3)
(set! x 4)

In the DrScheme REPL:

  (read-accept-reader #t)
  (parameterize ([current-namespace (make-base-namespace)])
    (namespace-require 'scheme)
    (namespace-require '(for-syntax scheme))
      (namespace-syntax-introduce ; make sure "module" is a known construct ...
       (with-input-from-file "a.scm"
         (lambda () (read-syntax)))))))

The result:

(module a scheme/base
   (#%require (for-meta 1 scheme/base))
   (#%provide x inc-x! mx)
   (define-values (x) '0)
   (define-syntaxes (mx) (lambda (stx) (quote-syntax x)))
   (define-values (inc-x!) (lambda () (set! x (#%app + x '1))))
   (#%app call-with-values (lambda () (if '1 '2 '3)) print-values)
   (#%app call-with-values (lambda () (set! x '4)) print-values)))

Besides the fishy lambda, the two last #%app-s are fishy too.
They won't match #%app from scheme/base (I think).

Jens Axel Søgaard

Posted on the users mailing list.