[plt-scheme] scribble ultra beginner: macros

From: Eric Tanter (etanter at dcc.uchile.cl)
Date: Tue Apr 27 14:07:32 EDT 2010

Another one:

The following simple/useless macro works, but I cannot include it in a @schemeblock:

#lang scheme

(define-syntax FOO
  (lambda (stx)
    (syntax-case stx ()
      ((FOO val)
       (let ((name (datum->syntax stx 'y)))
         #`(let ((#,name val))
             #,name))))))

> (FOO 10)
10

when I try to put it in a schemeblock:

@schemeblock[
(define-syntax FOO
  (lambda (stx)
    (syntax-case stx ()
      ((FOO val)
       (let ((name (datum->syntax stx 'y)))
         #`(let ((#,name val))
             #,name))))))
]

I get an error: 

Users/etanter/Develop/Scheme/Scribble/test.scrbl:46:20: compile: unbound identifier in module in: name

 === context ===
/Applications/_Extra/Devel/PLT Scheme v4.2.5/collects/scheme/private/map.ss:18:11: map
/Applications/_Extra/Devel/PLT Scheme v4.2.5/collects/scribble/run.ss: [running body]
/Applications/_Extra/Devel/PLT Scheme v4.2.5/collects/scribble/tools/drscheme-buttons.ss:24:3
/Applications/_Extra/Devel/PLT Scheme v4.2.5/collects/scheme/private/more-scheme.ss:158:2: call-with-break-parameterization
/Applications/_Extra/Devel/PLT Scheme v4.2.5/collects/scheme/private/more-scheme.ss:274:2: call-with-exception-handler

what am I doing wrong here?

Thanks!

-- Éric



Posted on the users mailing list.