I'm trying to build a toy language. Below, "sample.rkt" uses #lang s-exp 
"toy.rkt", where "toy.rkt" provides #%top and #%app. What's the right way to 
get macro expansion to work in "sample.rkt"? 

The following example, as-is, prints:

(ast 'def (list (ast 'fun (list (ast 'a '(b)) (ast 'foo '(a b))))))

However, commenting out the first (provide...) and uncommenting the second 
(provide ...) causes a failure with 

defun: use does not match pattern: (defun name args body0 body ...) in: (defun 
add (a b) (foo a b))

What's the bare-minimum I should be providing from "toy.rkt"?

--- toy.rkt ---

#lang racket

;; This works.
(provide (except-out (all-from-out racket)
                     #%top #%app)
         (rename-out [top #%top] 
                     [app #%app]))

;; This fails.
;(provide #%module-begin
;         #%top-interaction
;         (rename-out [top #%top] 
;                     [app #%app]))

(provide define-syntax-rule)

(struct ast (symbol args) #:transparent)

(define-syntax-rule (top . symbol) 
  'symbol)

(define-syntax-rule (app f arg ...)
  (ast f (list arg ...)))



--- sample.rkt ----

#lang s-exp "toy.rkt"

(define-syntax-rule (defun name args body0 body ...)
  (def (fun args body0 body ...)))

(defun add (a b) (foo a b))

-- 
You received this message because you are subscribed to the Google Groups 
"Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to