chicken-users
[Top][All Lists]
Advanced

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

[Chicken-users] some feedback on van Tonder's macros as implemented in C


From: Michele Simionato
Subject: [Chicken-users] some feedback on van Tonder's macros as implemented in Chicken
Date: Sat, 20 Aug 2005 06:31:34 +0000

Hello everybody,

I did some experiments with van Tonder's macros and module system in 
Chicken and here is my feedback.

First of all, do you remember my long standing complaint that interpreter 
and compiler should work the same, i.e. the interpreter should not 
magically import modules that are not imported by the compiler? It seems
that with simple-macros something similar happens: for instance, I have to 
explicitely import extras, even in interpreted code, whereas usually this 
is automagically imported by the interpreter. Also,the syntax 

(require-extension simple-macros)
(require-extension (module extras)) 
(import extras) 

is quite ugly. Maybe we would need a (require-module extras) to be 
interpreted as (require-extension (module extras)) (import extras)
[in general (require-extension <name>) would load a file named
<name>-module.scm or <name>-module.so and import from it a module 
called <name>].

I also have a bug report. chicken-macros-module.scm has "assert" in the
export list, but it is not defined, so I cannot use "assert".

I cannot use Andrew Wright's 'match' package together with simple-macros.
I understand there is 'matcher' module, however it is only of subset
of Wright's module which I use all the time.

Debugging of simple macros is terrible. Consider this example:

(use simple-macros)
(use (module matcher))
(import matcher)
  
(define-syntax (match-lambda* . args)
  #`(lambda e (match e ,@args)))
     
(define m*
  (match-lambda*
   (() 'no-argument-given)
   ((x) 'one-argument-given)))

(m*) ;=> no-argument-given
(m* 1) ;=> one-argument-given
(m* 1 2); => Error: No match for:: (1 2)

Now, on purpose, I make syntax error in the definition of m*:

(define m*
  (match-lambda*
   () 'no-argument-given)
   ((x) 'one-argument-given))
Syntax error:

Syntax error in definition: (define m*#top (match-lambda*#top ()
(quote no-argument-given#top)) ((x#top) (quote
one-argument-given#top)))

In source context:

  (define m*#top (match-lambda*#top () (quote no-argument-given#top))
((x#top) (quote one-argument-given#top)))

Error: (simple-macros.scm, line 1763) Expansion stopped

This error message is absolutely terrible. I get an unreadable
message (at least the source should be pretty-printed), I get it
twice and the line number information has nothing to do with the
origin of the problem. By contrast, Andrew Wright's match-lambda
has a much saner output:

(define m*
  (match-lambda*
   () 'no-argument-given)
   ((x) 'one-argument-given))
Error: during expansion of (define ...) - (define) too many arguments:
((match-lambda* () (quote no-argument-given)) ((x) (quote
one-argument-given)))

Apart from this example with the pattern matcher, in general simple-macros
error messages would be better if they would provide properly formatted
non-redundant code, possibly with '#top' stripped from the identifiers.
It is also best to have no line number information rather than a misleading
one.

That's all for the moment ...

                Michele Simionato




reply via email to

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