chicken-users
[Top][All Lists]
Advanced

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

[Chicken-users] macros / imports


From: Chris Mueller
Subject: [Chicken-users] macros / imports
Date: Fri, 25 Apr 2014 18:51:53 +0200
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:24.0) Gecko/20100101 Thunderbird/24.3.0

Hi,

i'm currently writing some small helper macros for myself, that makes chicken's module system syntactically a little bit more similar to python's one.

I would wish to have a macro that doesn't pollute the current namespace environment by default. It should introduce for each module a seperate prefix

Concretly in chicken the following templates

(imports std.list)

should be expanded to:

(import (prefix std.list std.list/))

Hint:
It's the same problem discussed here in http://lists.nongnu.org/archive/html/chicken-users/2005-08/msg00025.html (2005)
Unfortunetely, it's not uptodate anymore with chicken's API.

1) I have tried to following snippet

(define-syntax imports
  (ir-macro-transformer
    (lambda (x i c)
      (let ((name (cadr x))
            (pre (symbol-append (i (caddr x)) '\.)))
        `(import (prefix ,name ,pre))))))

that expands the top expression to:

(import (prefix std.list std.list/)) correctly.

But here the call seems to fail. Functions and the namespace are not available. If i use directly the expanded
version, it works.



2) If i slighty change the macro definition to give an explicit module prefix by changing (caddr x) to name within the pre let-binding

(import std.list list) expands to (import (prefix std.list list15141515/))


In the sources it's seems at the first view the import system is very tight integrated with the macro expansion.

Any ideas how i get it working, if it's possible?


Best regards,
Chris


fty. I'm not familar with low-level macro transformers :] but I got the prefix symbol extension not working with syntax-rules().













reply via email to

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