chicken-users
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Chicken-users] Problem accessing macro from module


From: Peter Wright
Subject: [Chicken-users] Problem accessing macro from module
Date: Sun, 21 Jan 2007 23:50:40 +0900
User-agent: Mutt/1.5.13 (2006-08-11)

Hi all - I'm trying to work out a macro/module problem.

(Chicken 2.5 on Linux)

Example:

;; -------- pfn.scm ---------
(use syntax-case)
  
(define-syntax fn
  (syntax-rules
    ()  
    ((fn (p ...) body)
     (lambda (p ...) body))
    ((fn name (p ...) body)
     (define (name p ...)
       body))))
 
(fn hello-world ()
    (print "Hello, world!"))
;; -------- pfn.scm ---------

I build and install pfn as a module with

$ chicken-setup pfn

It seems to compile/install fine.

Now, however:

;; -------- weird.scm ---------
(use pfn)
  
(hello-world)
  
(fn goodbye-world ()
    (print "Goodbye, cruel world!"))
  
(goodbye-world)
;; -------- weird.scm ---------


When I run this as a script, the hello-world call seems to works
correctly - but the script then fails on the use of fn to create the
goodbye-world function.

Trying to compile weird.scm fails with:

  Error: syntax error - illegal atomic form `()'


Can anyone offer any suggestions re: why the "fn" macro isn't usable
outside of pfn.scm? Am I supposed to do something special to "export"
a define-syntax macro?

Any ideas much appreciated, thanks - this is really confusing me :).

Pete.
-- 
http://flooble.net/blog
I'm a pacifist, and if you don't believe me, I'm going to beat you up.




reply via email to

[Prev in Thread] Current Thread [Next in Thread]