chicken-users
[Top][All Lists]
Advanced

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

[Chicken-users] two-dimensional syntax-rules


From: Sascha Ziemann
Subject: [Chicken-users] two-dimensional syntax-rules
Date: Fri, 10 Mar 2017 09:31:38 +0100

I have the following macro:

(define-syntax define-facts
  (syntax-rules ()
    ((_ (name a0 a1 ...) ((v00 v01 ...) (v10 v11 ...) ...))
     '(define (name a0 a1 ...)
        (conde
          ((== a0 v00) (== a1 v01) ...)
          ((== a0 v10) (== a1 v11) ...)
          ...)))))

In Guild 2.0.9 it works as expected:

scheme@(guile-user)> (define-facts (fathero f c)
  (("Abraham" "Ismael")
   ("Abraham" "Isaac")
   ("Isaac"   "Jacob")
   ("Jacob"   "Benjamin")))
$1 = (define (fathero f c) (conde ((== f "Abraham") (== c "Ismael"))
((== f "Abraham") (== c "Isaac")) ((== f "Isaac") (== c "Jacob")) ((==
f "Jacob") (== c "Benjamin"))))

But in Chicken csi get the following error:

CHICKEN
(c) 2008-2013, The Chicken Team
(c) 2000-2007, Felix L. Winkelmann
Version 4.8.0.5 (stability/4.8.0) (rev 5bd53ac)
linux-unix-gnu-x86-64 [ 64bit manyargs dload ptables ]
compiled 2013-10-03 on aeryn.xorinia.dim (Darwin)

#;1> (define-syntax define-facts
  (syntax-rules ()
    ((_ (name a0 a1 ...) ((v00 v01 ...) (v10 v11 ...) ...))
     '(define (name a0 a1 ...)
        (conde
          ((== a0 v00) (== a1 v01) ...)
          ((== a0 v10) (== a1 v11) ...)
          ...)))))
#;2> (define-facts (fathero f c)
  (("Abraham" "Ismael")
   ("Abraham" "Isaac")
   ("Isaac"   "Jacob")
   ("Jacob"   "Benjamin")))

Error: (map) during expansion of (define-facts ...) - lists are not of
same length: (() (("Jacob") ("Benjamin")))

        Call history:

        <eval>    (##sys#map-n (lambda8 (a1 v01) (##sys#cons (rename14
(##core#syntax ==)) (##sys#cons a1 (##sys#cons v01...
        <eval>    (##sys#cons (rename14 (##core#syntax ==))
(##sys#cons a1 (##sys#cons v01 (quote13 ()))))
        <eval>    (rename14 (##core#syntax ==))
        <eval>    (##sys#cons a1 (##sys#cons v01 (quote13 ())))
        <eval>    (##sys#cons v01 (quote13 ()))
        <eval>    (##sys#map-n (lambda8 (v10 a1 v11) (##sys#cons
(##sys#cons (rename14 (##core#syntax ==)) (##sys#cons......
        <eval>    (##sys#cons (##sys#cons (rename14 (##core#syntax
==)) (##sys#cons a0 (##sys#cons v10 (quote13 ()))))...
        <eval>    (##sys#cons (rename14 (##core#syntax ==))
(##sys#cons a0 (##sys#cons v10 (quote13 ()))))
        <eval>    (rename14 (##core#syntax ==))
        <eval>    (##sys#cons a0 (##sys#cons v10 (quote13 ())))
        <eval>    (##sys#cons v10 (quote13 ()))
        <eval>    (##sys#map-n (lambda8 (v11) (##sys#cons (rename14
(##core#syntax ==)) (##sys#cons a1 (##sys#cons v11...
        <eval>    (##sys#cons (rename14 (##core#syntax ==))
(##sys#cons a1 (##sys#cons v11 (quote13 ()))))
        <eval>    (rename14 (##core#syntax ==))
        <eval>    (##sys#cons a1 (##sys#cons v11 (quote13 ())))
        <eval>    (##sys#cons v11 (quote13 ())) <--

I am not sure if it is a bug, because Chibi and Gambit fail, too. But
Petite Chez does it like Guile.

Is it a bug?



reply via email to

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