Running `,@ in the REPL does not throw an exception.
What program did you run?
Chez Scheme Version 9.5.7
Copyright 1984-2021 Cisco Systems, Inc.
> `,@0
,@0
> `,@v
,@v
>
What should have happened?
I read the introduction about ,@ in r6rs, I think `,@ must be illegal usage:
If an (unquote-splicing expression . . . ) form appears inside a qq template, then the expressions must evaluate to lists; the opening and closing parentheses of the lists are then “stripped away” and the elements of the lists are inserted in place of the unquote-splicing form.
This is an interesting issue. I think the r6rs specification has some edge cases where the descriptive text doesn't quite do what you'd expect in conjunction with the grammar for quasiquote expressions given at the end of the section. Let's take one of these specific examples and walk it through the grammar.
Starting with the reader expansion of the first example: (quasiquote (unquote-splicing 0))
This enters the grammar with (quasiquote <qq template>), and we follow the productions:
- <qq template> → <qq template 1> (binding
(unquote-splicing 0)) - → <list qq template 1>
- →
(<qq template or slice 1>*)(binding the two list itemsunquote-splicingand0) - → <qq template 1> → <lexeme datum> for both items
This never reaches the <splicing unquotation> production in the grammar.
A separate issue is that Chez Scheme does not validate that the <expression>(s) inside an unquote-splicing evaluate to lists. The spec says they must, but it doesn't say whether the implementation should verify that (or suggest any behavior if they are not). Sometimes the program succeeds, and sometimes it fails:
> `(,@0)
0
> `(0 ,@0)
(0 . 0)
> `(0 ,@0 1)
Exception in append: 0 is not a proper list
Type (debug) to enter the debugger.
In my opinion, the current behavior is consistent with the letter (if perhaps not the spirit) of the spec, and most importantly is consistent with any quasiquotation forms that are correct under more restrictive interpretations of the spec. In any case, I think it unlikely that the current behavior of the Chez Scheme quasiquote will change.