Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

syntax-rules does not support patterns beginning with ellipsis, like (... ...) #704

Open
jpellegrini opened this issue Dec 20, 2024 · 1 comment

Comments

@jpellegrini
Copy link
Contributor

Hi @egallesio - happy holidays!

In page 24 of R7RS, the specification of patterns for syntax-rules contains this:

A template of the form (<ellipsis> <template>) is identical to <template>, except that ellipses within the template have no special meaning. That is, any ellipses contained within <template> are treated as ordinary identifiers. In particular, the template (<ellipsis> <ellipsis>) produces a single <ellipsis>. This allows syntactic abstractions to expand into code containing ellipses.

(define-syntax be-like-begin
  (syntax-rules ()
    ((be-like-begin name)
      (define-syntax name
        (syntax-rules ()
          ((name expr (... ...))
            (begin expr (... ...))))))))

(be-like-begin sequence)
(sequence 1 2 3 4)      ;; => result should be 4

But in STklos this raises an error when using the macro:

stklos> (be-like-begin sequence)
**** Error:
map: malformed list '#f'
	(type ",help" for more information)

I'll take a look into this, probably before the beginning of 2025 -- but I wanted to report the issue already.

@jpellegrini
Copy link
Contributor Author

However... Most Schemes don't support that. And those who do don't seem to agree:

$ chibi-scheme
> (define-syntax f
  (syntax-rules ()
    ((f) '(a b (... c ... d) e))))
> (f)
(a b (c ... d) e)
gosh$ (define-syntax f
......  (syntax-rules ()
......    ((f) '(a b (... c ... d) e))))
#<undef>
gosh$ (f)
(a b c e)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant