chicken-users
[Top][All Lists]
Advanced

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

[Chicken-users] Expanding ellipsis on lists of different length


From: Tobia Conforto
Subject: [Chicken-users] Expanding ellipsis on lists of different length
Date: Wed, 27 Aug 2008 18:57:58 +0200

(define-syntax test
  (syntax-rules ()
    ((test (a ...) (b ...))
     (quote ((a b) ...)))))

What happens if one calls this macro on two lists of different lengths? According to various online tutorials, the expansion should abort with an error. In current hygienic Chicken the behaviour depends on which list ends first:

(test (1 2) (10 20 30))
=> ((1 10) (2 20))

(test (1 2 3) (10 20))
Error: (map) during expansion of (test ...) - lists are not of same length: (())

R5RS is pretty vague, but does hint at an error condition in the last sentence: "Pattern variables that occur in subpatterns followed by one or more instances of the identifier ... are allowed only in subtemplates that are followed by as many instances of .... They are replaced in the output by all of the subforms they match in the input, distributed as indicated. It is an error if the output cannot be built up as specified."


Tobia




reply via email to

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