public inbox for kawa@sourceware.org
 help / color / mirror / Atom feed
* syntax-rules problem
@ 2017-03-10  9:35 Sascha Ziemann
  2017-03-10 19:04 ` Per Bothner
  0 siblings, 1 reply; 3+ messages in thread
From: Sascha Ziemann @ 2017-03-10  9:35 UTC (permalink / raw)
  To: kawa mailing list

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) ...)
          ...)))))

Some Schemes like Guile, Chez, MIT and Ikarus succeed to evaluate the
following expression.

(define-facts (fathero f c)
  (("Abraham" "Ismael")
   ("Abraham" "Isaac")
   ("Isaac"   "Jacob")
   ("Jacob"   "Benjamin")))

=>

(define (fathero f c)
  (conde
    ((== f "Abraham") (== c "Ismael"))
    ((== f "Abraham") (== c "Isaac"))
    ((== f "Isaac") (== c "Jacob"))
    ((== f "Jacob") (== c "Benjamin"))))

But some fail. Kawa fails with an exception:

/dev/stdin:9:1: evaluating syntax transformer 'define-facts' threw
java.lang.ArrayIndexOutOfBoundsException: 1

I am still not sure, if it is a bug or if this is another undefined
part of Scheme.

Is it a bug?

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2017-03-10 20:11 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-03-10  9:35 syntax-rules problem Sascha Ziemann
2017-03-10 19:04 ` Per Bothner
2017-03-10 20:11   ` Per Bothner

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).