Open Zambito1 opened 1 year ago
Yeah, iirc it was in my todo list but never got around implementing it.
Care for a pr? It shouldnt be all that hard.
We can also just document it as a limitation, waiting for the next hacker to be annoyed enough to fix it ;)
Ah btw, :::
is a keyword!
So you should |:::|
or use an identifier.
I think this is not a bug?
Using a keyword is wrong, but still, custom ellipsis is not implemented atm. It is not a bug per se, more of an omission, that is readily fixable.
I will try to fix it for v0.18.2.
You can also give it a go if you want!
I found a way to workaround this
❯ rlwrap gerbil
Gerbil v0.18.1 on Gambit v4.9.5-78-g8b18ab69
> (define-syntax foo (syntax-rules () ((_ x . xs) (+ x 1 . xs))))
> (foo 1)
2
> (foo 2)
3
>
You can also give it a go if you want!
I looked at the code in core.scm
and I don't know what I was looking at.
it seems to be something like this:
(define-syntax ... (syntax-rules () (_ (unquote-splicing xs))))
It needs to be supported by syntax-case, it is in src/gerbil/expander/stxcase.ss
It seems like i just need to replace ellipsis?
with a custom one. Is the symbol lexical in Gambit? Can I just replace that somehow?
yes, it is simple.
Add an optional argument for the ellipsis? procedure, defaulting to the real ellipsis?.
You will the have to change the syntax-rules macro a bit to recongize and pass the parameter as free-identifier=? the user's identifier.
is it possible to nest ellipsis somehow?
for example:
(syntax-rules ...a () ((_ ...a)
(syntax-rules ...b () ((_ ...b)
(test ...a)
))
))
yes, (... ...)
I don't know enough about Gerbil to patch this. Is it possible to rewrite the body before it is sent to src/gerbil/expander/stxcase.ss
?
nah, no need. I will add it to my todo list.
In R7RS,
syntax-rules
has an optional extra argument to specify the term to use for the ellipsis. https://index.scheme.org/filterset/r7rs_small/%28scheme%2520base%29/syntax-rulesThis does not seem to be handled correctly by Gerbil.