On Jan 22, 2007, at 12:00 PM, [EMAIL PROTECTED] wrote:

Date: Sun, 21 Jan 2007 14:05:27 -0500
From: John Cowan <[EMAIL PROTECTED]>
Subject: Re: [Chicken-users] Problem accessing macro from module
To: Peter Wright <[EMAIL PROTECTED]>
Cc: [email protected]
Message-ID: <[EMAIL PROTECTED]>
Content-Type: text/plain; charset=us-ascii

Peter Wright scripsit:

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.

That's because the Chicken compiler (like all Scheme compilers, AFAIK)
compiles away all syntax definitions.

Not all Scheme compilers do so. For example, under my (unreleased) compiler:

$ cat pfn.scm
(define-syntax fn
  (syntax-rules
    ()
    ((fn (p ...) body)
     (lambda (p ...) body))
    ((fn name (p ...) body)
     (define (name p ...)
       body))))

(fn hello-world ()
    (display "Hello, world!\n"))


$ cat weird.scm
(load "pfn.so")
(hello-world)
(fn goodbye-world ()
    (display "Goodbye, cruel world!\n"))

(goodbye-world)

$ ikarus
Ikarus Scheme (Build 2007-01-22)
Copyright (c) 2006-2007 Abdulaziz Ghuloum

> (compile-file "pfn.scm" "pfn.so" 'replace)
> ^D

$ ikarus
Ikarus Scheme (Build 2007-01-22)
Copyright (c) 2006-2007 Abdulaziz Ghuloum

> (load "weird.scm")
Hello, world!
Goodbye, cruel world!
> ^D


The problem is that chicken does not have proper integration of psyntax.
This shows up in many places (try changing the value of memv and use
case when syntax-case is loaded; or try changing lambda and use let).
This behavior is found in not only chicken but in almost all systems
that use psyntax (other than Chez and Ikarus).

For compilable macros to work, a few minor changes need to be made to
the psyntax implementation (egg) in chicken.  Mainly, the ctem and rtem
values need to be set to appropriate values when evaluating in the repl
and when compiling a file. (described in psyntax.ss under
 /Initial mode sets/.)

Aziz,,,
_______________________________________________
Chicken-users mailing list
[email protected]
http://lists.nongnu.org/mailman/listinfo/chicken-users

Reply via email to