[racket-dev] Providing macro definitions for BSL programs

From: Nadeem Abdul Hamid (nadeem at acm.org)
Date: Sat Sep 4 16:37:57 EDT 2010

Suppose I make a "teachpack" that defines a macro:

#lang racket
...
(define-syntax (my-macro stx)
  (syntax-case stx (->)
    [(_ (func arg ...) -> rslt)
     #`(check-expect (func arg ...) rslt)]))
(my-macro (+ 4 5) -> 10)
(test)
(provide my-macro)

Running this file works fine.

Now, how exactly do I make this macro available to programs written in
Beginning/Intermediate Student? Opening up a file in BSL level and
typing:
  (require "my-macro.rkt")
  (my-macro (+ 4 5) -> 9)
gives the error:
  my-macro: bad syntax

This macro is a simplification of the real thing I'm working on, but
note that the arguments to this macro include name(s) of functions
defined in the BSL file. I though of maybe using
provide-higher-order-primitive, but it doesn't seem to work either.

--- nadeem


Posted on the dev mailing list.