[plt-scheme] literal matching in syntax-case

From: Dimitris Vyzovitis (vyzo at media.mit.edu)
Date: Mon Apr 30 03:48:21 EDT 2007

I am seeing unexpected behavior from literal matching in syntax case and
custom language modules. An example follows where redefinition of define
in a custom language breaks a macro in plain mzscheme that literal
matches on define.

My understanding of literal matching is that they should match regardless
of such redefinitions, but perhaps I am missing something here.

Example:
macro.ss:
(module macro mzscheme
  (define-syntax (test stx)
    (syntax-case stx (define)
      ((_ (define id expr)) (syntax #t))
      (_ (raise-syntax-error #f "no milk today" stx))))
  (provide (all-defined)))

lang.ss:
(module lang mzscheme
  (define-syntax (my-define stx)
    (syntax-case stx ()
      ((_ id expr)
       #'(define id expr))))

  (provide (all-from-except mzscheme define)
           (rename my-define define)))

repl:
Welcome to MzScheme v369.11 [3m], Copyright (c) 2004-2007 PLT Scheme Inc.
> (require "macro.ss")
> (test (define x y))
#t
> (require "lang.ss")
> (test (define x y))
stdin::81: test: no milk today in: (test (define x y))

-- vyzo
-------------- next part --------------
(module macro mzscheme
  (define-syntax (test stx)
    (syntax-case stx (define)
      ((_ (define id expr)) (syntax #t))
      (_ (raise-syntax-error #f "no milk today" stx))))
  (provide (all-defined))
  )
-------------- next part --------------
(module lang mzscheme
  (define-syntax (my-define stx)
    (syntax-case stx ()
      ((_ id expr)
       #'(define id expr))))
  
  (provide (all-from-except mzscheme define)
           (rename my-define define)))


Posted on the users mailing list.