[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Chicken-users] Help solving this phasing problem.
From: |
Patrick Li |
Subject: |
[Chicken-users] Help solving this phasing problem. |
Date: |
Sat, 12 Feb 2011 16:35:23 -0500 |
Hello everyone,
I'm creating a module that exports two things, a macro and a function. The definition of the macro happens to require the use of the function. I am having problems creating this module. The defined macro cannot access the function.
----------------------Example--------------------------------------------------------------------------
(module tempmodule (convenience-function my-macro)
(import chicken scheme)
(define (convenience-function)
(display "do convenience things\n"))
(define-syntax my-macro
(lambda (_expression_ rename comparison)
(convenience-function)
"My Macro Output"))
);;END MODULE
(import tempmodule)
(my-macro)
=> Error: during expansion of (my-macro ...) - unbound variable: convenience-function
---------------------------------------------------------------------------------------------------
I have a *very* ugly workaround right now.
I define the convenience function twice. Once normally. And again within a begin-for-syntax form.
-------------------Example---------------------------------------------------------------------
(module tempmodule (convenience-function my-macro)
(import chicken scheme)
(define (convenience-function)
(display "do convenience things\n"))
(begin-for-syntax
(define (convenience-function)
(display "do convenience things\n")))
(define-syntax my-macro
(lambda (_expression_ rename comparison)
(convenience-function)
"My Macro Output"))
);;END MODULE
---------------------------------------------------------------------------------------------------
I would appreciate your help if someone knows how to solve this problem properly. Thank you!
-Patrick
- [Chicken-users] Help solving this phasing problem.,
Patrick Li <=