Why define-values is not bound in a Racket macro with #lang racket/base?

Viewed 53

I am trying to learn how to write Macros in Racket. I've gone through the excellent Fear of Macros tutorial and am now trying to experiment with the basic ideas.

So I defined my-if slightly differently from what was shown in the tutorial, and I am getting an error define-values: unbound identifier; in:

#lang racket/base

(define-syntax (my-if stx)
  (define-values (_ condition yes no)
    (apply values (syntax->list stx)))
  (datum->syntax stx `(if ,condition ,yes ,no)))

If I use #lang racket instead of racket/base it works.

Looking up the definition of define-values in the Manual, it seems to be part of racket/base!

define-values  provided from racket/base, racket

So why is Racket complaining about this?

1 Answers

Use (require (for-syntax racket/base)) to import racket/base also at phase 1 (compile time). Using #lang racket/base provides define-values only at phase 0 (runtime).

Related