chicken-users
[Top][All Lists]
Advanced

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

Re: [Chicken-users] syntax-case modules questions


From: felix winkelmann
Subject: Re: [Chicken-users] syntax-case modules questions
Date: Fri, 25 May 2007 13:42:15 +0200

On 5/25/07, Andreas Rottmann <address@hidden> wrote:

Since Chicken lacks a built-in module system, I'm playing with the
syntax-case egg. I want to take an extension (say SRFI-39) and make
that (or parts of it) available as a syntax-case module. It seems I
have to use EXPORT-TOPLEVEL instead of the export list, since this
doesn't work:

(module foo (append!)
  (require-extension srfi-1))
===>
Error: missing definition for export(s): (append!)

The module form expects source forms to define the exported
identifiers. "require-extension" just loads compiled code, basically.


This works:

(module foo ()
  (require-extension srfi-1)
  (export-toplevel append!))


Not really: it makes "append!" available under an (unqualified) name
"append!", not as an identifier specific to the module "foo".

So now, the question is what to do about syntax (i.e. macros). The
syntax-case egg docs mention that EXPORT-TOPLEVEL doesn't support
syntax. So how would I export a macro imported from an extension
loaded with REQUIRE-EXTENSION? This doesn't work:

(module spells.parameter (parameterize)
  (require-extension srfi-39)
  (export-toplevel make-parameter))
===>
Error: missing definition for export(s): (parameterize)

Any ideas?


Modules to be "import"ed by client code should always be
available in source code form: the source code is processed
by the syntax-case macro expander and binding information
(of normal variables and macros) is recorded. So to create
an extension, install both the compiled .so and the source files.
This will make the compiled code available for "require-extension"
and the sources for "import". This can be somewhat complicated,
but see various eggs for examples (for example "protobj").

Another thing that I noticed when using the syntax-case egg is that
INCLUDEs are not relative to the file containing the module
declaration, but I think they should be. So given a file
"some/dir/modules.scm":

Yes, that would be an improvement.


cheers,
felix




reply via email to

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