[plt-scheme] Null syntax / Conditional definition

From: Chihiro Kuraya (rxqvw at yahoo.co.jp)
Date: Sun Jun 19 12:53:37 EDT 2005

> (2) Is it possible to switch syntax definition (or normal definition)
> depending on some flags?
> 
> [Example]
> (if-defined WIN32
>   (define ABC 123)
>   (define-syntax XYZ ...))
> 
> (if-defined MACOSX
>   (define ABC 567)
>   (define-syntax XYZ ...))

I struggled to find a way to implement this.

-----------------------------------------------------------------------
(module m1 mzscheme
  (provide if-for-syntax)
  (define-syntax (if-for-syntax stx)
    (syntax-case stx ()
      ((_ TEST THEN ELSE)
       (if (eval #'TEST)
           #'THEN
           #'ELSE))))
  )

(module m2 mzscheme
  (require m1)
  (define OS 'windows)

  (if-for-syntax (eq? OS 'windows)
    (begin
      (define OS-name "Windows"))
    (begin
      (define OS-name "Unknown")))
  )
-----------------------------------------------------------------------

But the following error message was displayed.

-----------------------------------------------------------------------
require: broken compiled code (phase 0, defn-phase 0): 
cannot find module m2 in: OS
-----------------------------------------------------------------------

I can't understand why this code doesn't work
and what means this error message.

Doesn't #'TEST syntax object have lexical context which 
contains OS identifier ?


Chihiro Kuraya
__________________________________
Save the earth
http://pr.mail.yahoo.co.jp/ondanka/



Posted on the users mailing list.