<div class="gmail_quote"><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;"><div class="Ih2E3d">
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
For example, there's no reason the pattern (_ (name value) ... expr) could not be made to work, since 'expr' is a less specific matcher than '(name value)'. '(name value) ...' would consume input expressions until it hit a non-list expression, then 'expr' would take over. So firstly, are there counterexamples to prove this wouldn't work, and if it would work, can you implement it using Scheme macros themselves? I'd also like to do something similar with keywords, so that for example (_ expr ... stop stmt ...) would work if 'stop' is a keyword for the syntax.<br>
</blockquote>
<br></div>
And in fact it already works in PLT Scheme:<br>
<br>
#lang scheme<br>
<br>
(define-syntax foo<br>
(syntax-rules ()<br>
[(foo a b ... c)<br>
'(a b ... c)]))<br>
<br>
(foo 1 2 3) ; =: (1 2 3)<br>
<br>
<br>
(define-syntax bar<br>
(syntax-rules ()<br>
[(foo a b ... ignore)<br>
'(a b ...)]))<br>
<br>
(bar 1 2 3) ; => (1 2)</blockquote><div><br><br>Okay, I tried that out in mzscheme and it was fine. I ask because I'm implementing R5RS myself, and I was wondering whether it's possible to implement some of the R6RS additions (like infix ellipses) as R5RS macros. If you have examples that would be great.<br>
<br>I'd also like keywords to be used to stop ellipses consuming input, i.e. the following would be fine:<br><br>(define-syntax foo<br>
(syntax-rules (word)<br>
[(foo a b ... word c ...)<br>
'(a b ... c)]))<br></div></div><br>This would allow very flexible custom syntaxes but mzscheme choked when I tried it. Is it possible to implement this using macros or does the host implementation need to provide explicit support for it?<br>
<br>(Sorry if any of this seems obtuse and impractical, I'm just poking around to improve my understanding.)<br>