chicken-users
[Top][All Lists]
Advanced

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

Re: [Chicken-users] Problem accessing macro from module


From: Abdulaziz Ghuloum
Subject: Re: [Chicken-users] Problem accessing macro from module
Date: Mon, 22 Jan 2007 12:50:20 -0500


On Jan 22, 2007, at 12:00 PM, address@hidden wrote:

Date: Sun, 21 Jan 2007 14:05:27 -0500

From: John Cowan <address@hidden>

Subject: Re: [Chicken-users] Problem accessing macro from module

To: Peter Wright <address@hidden>

Cc: address@hidden

Message-ID: <address@hidden>

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,,,

reply via email to

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