egallesio / STklos

STklos Scheme
http://stklos.net
GNU General Public License v2.0
69 stars 17 forks source link

`let-syntax` always signals an error #604

Closed jpellegrini closed 1 year ago

jpellegrini commented 1 year ago

Hi @egallesio !

This is probably in your TODO list, but if it isn't, I'm opening an issue: the current let-syntax implementation doesn't work because it calls %find-macro-clause with 4 parameters, and a 5th was added.

stklos> (let-syntax ((f (syntax-rules () ((f) 10)))) (f))
**** Error:
find-clause: 5 arguments required in call to `#[closure find-clause]' (4 provided)

Here is the cause:

(define-macro (let-syntax bindings . body)
  `(%let-syntax
    ,(map (lambda (x)
            (let* ((macro-name (car x))
                   (syn-rules  (cadr x))
                   (keywords   (cons macro-name (cadr syn-rules)))
                   (clauses    (cddr syn-rules)))
              `(,macro-name (lambda args
                              (%find-macro-clause ',macro-name
                                                  args
                                                  ',keywords
                                                  ',clauses)))))  ;; Here! It should pass the ellipsis symbol too!
          bindings)
    ,@body))

The fix would require some rewriting of that macro...

jpellegrini commented 1 year ago

Fixed! :)