Am Mi., 10. Juni 2020 um 10:21 Uhr schrieb Linus Björnstam <xxxxxx@veryfast.biz>:
On Wed, 10 Jun 2020, at 09:37, Marc Nieper-Wißkirchen wrote:

> How do you want to correctly check for nested syntax? Recursively
> scanning the forms would be broken because some of the forms may be
> binding constructs, other maybe macro calls whose effect you don't know:
>
> (megacut (display '%3)) => ???
>
> (megacut (let ((%3 'foo)) (display %3))) => ???
>
> (let-syntax ((foo (identifier-syntax %3)))
>  (megacut (display foo)) => ???
>
> It's pretty clear what "???" should be under the Scheme hygiene rules.
> But it is not so clear to me how to implement it. With syntax
> parameters, one would get the lexical scoping right, but how do you
> then check for the highest parameter number used?

I carefully refrained to call my code hygienic. I said that the part detecting nested use is less hygienic than it can be. I am very well aware of the issues with the rest.

This is why I have refrained  from doing it before: doing it in a way other than "here is some code. Use it responsively because it might not work in some cases" is prohibitively hard. Saying "don't do x y z because this is just a hack" feels icky. Especially since you know someone learning the language will inevitably try it :)

I use the shorthand mostly at the repl where it saves quite a lot of key presses, but that isn't really a reason to srfi it. If there is interest I could probably make something that will leave everyone feeling slightly unsatisfied, but that is about it. I just thought I should ask the question.

I didn't want to say that your code is useless; on the contrary, I find it interesting and, as you say, it may help for quick coding at the REPL.

But (at least in my opinion) the bar for something that goes into a SRFI is much higher (and even higher if it is to be included in some future standard).  The existing RnRS and a lot of existing SRFIs have set the height of the bar and have made Scheme into the beautiful hygienic (in many senses of the word) language it is now.

This should not dissuade us from taking a closer look at syntax like that of `megacut'.  It should encourage us to think of which syntax primitives are still missing in the core of the Scheme expander whose existing would allow to write `megacut'.