public inbox for kawa@sourceware.org
 help / color / mirror / Atom feed
* Recursive define-syntax
@ 2021-09-26 12:08 Philippe de Rochambeau
  2021-09-26 21:04 ` Per Bothner
  0 siblings, 1 reply; 5+ messages in thread
From: Philippe de Rochambeau @ 2021-09-26 12:08 UTC (permalink / raw)
  To: kawa


Hello,

the following procedure, excerpted from « A Pamphlet Against R » 

(define (dim m)
 (match m
   ((first . rest)
     `(,(length m) . ,(dim first)))
    (_
      '())))

… causes Kawa to display the following error message:

/dev/tty:6:5: unrecognized pattern operator first


I tried rewriting the dim procedure using define-syntax:


(define m0 '((1 2 3 4)(0 4 5 8)(0 0 7 6)))

(define-syntax dim 
    (lambda (m)
        (syntax-case m ()
            ((_ frst . rst)
                #`(#,(length m) . #,(dim first)))
            (_
                '()))))
    
…but to no avail:

matrix1.scm:7:17: duplicated pattern variable frst
matrix1.scm:7:13: duplicated pattern variable rst
matrix1.scm:7:17: duplicated pattern variable frst
matrix1.scm:7:13: duplicated pattern variable rst
…

Are recursive « syntaxes »  not possible in Kawa?

Many thanks.

Philippe

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

end of thread, other threads:[~2021-09-27 16:07 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-09-26 12:08 Recursive define-syntax Philippe de Rochambeau
2021-09-26 21:04 ` Per Bothner
2021-09-27  5:05   ` Philippe de Rochambeau
2021-09-27  5:31     ` Philippe de Rochambeau
2021-09-27 16:06       ` 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).