chicken-users
[Top][All Lists]
Advanced

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

[Chicken-users] first experiments with "simple-macros"


From: Michele Simionato
Subject: [Chicken-users] first experiments with "simple-macros"
Date: Tue, 2 Aug 2005 08:17:54 +0000

I have installed Chicken 2.0 and I have decided to try Andre' van Tonder
macro system. Here are my findings/feedback/requests.

----

1. First of all, Andre's paper and other documentation should be 
   boundled with the egg. Also, I would like this policy to be valid for 
   all eggs. 

Rationale:

a) in this moment I have a dialup connection, I have downloaded the egg
   assuming the documentation was included (as it happens in other eggs)
   and discovered later that it was missing. Now I have to go back and
   download the rest. This is slighly bothering. If I was in an Internet
   Cafe it would be even more bothering. 

b) I don't see a single good reason to provide the documentation 
   separately, since Chicken eggs are tipically simple, the docs
   are small and who cares about few Kbytes more in the download?
   For instance, the metakit egg, which has one of the longest documentation, 
   contains a PDF file of only 191K, which is nothing, even with a dialup 
   connection.

c) as a matter of principle, I consider documentation and tests an 
   integral part of the application, so I always ship everything together
   when I write code for distribution.

----

2. Various constructs which work in regular Chicken does not work once 
   the simple-macros egg is loaded; for instance define-values:

#;1> (use simple-macros)
; loading /usr/local/lib//simple-macros.so ...
#;2> (define-values (x y) (values 1 2))
Error: unbound variable: y#top

Notice that the error message is pretty confusing (it seems that 
simple-macros is renaming *all* names, not only the names inside
macros defined with define-syntax). Should I assume that
only R5RS forms are recognized? It seems likely, Chicken extensions 
such as '->string' are not recognized either, however 'print', which is not 
R5RS, works just fine (?)

----

3. ,x does not work in the REPL; however macroexpand "somewhat" works,
so it should  be easy to fix.

Experiments with macroexpand confirm me in my hypothesis that *all*
variables are renamed, for instance

  (macroexpand 'x) ;=> x#top

----

4. I was playing with the module system. As an exercise, I wanted to define a
   macro to import identifiers prefixed by the module name. So I tried
  
  (define (symbol-append . symbols)
    (string->symbol (apply string-append (map symbol->string symbols))))

  (define-syntax (import-with-prefix module-name)
    #`(import ,module-name (lambda (sym) (symbol-append ',module-name ': sym))))

  (module m1 (a b)
    (define a 1)
    (define b 2))

  (import-with-prefix m1)

But is does not work. m1:a and m1:b are not imported


  m1:a ;=> Error: unbound variable: m1:a#top

and

  (macroexpand '(import-with-prefix m1))

gives 
  
  (kffd:load-module (quote m1))

which is anyway incorrect, since nor a nor b are imported. 
On the other hand, writing by hand

  (import m1 (lambda (sym) (symbol-append 'm1 ': sym)))
  (list m1:a m1:b) ;=> (1 2)

works, so I am at loss of understanding what the expander is doing.

----

5. Further observations will likely follow later on. 


           Michele Simionato




reply via email to

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