justinethier / cyclone

:cyclone: A brand-new compiler that allows practical application development using R7RS Scheme. We provide modern features and a stable system capable of generating fast native binaries.
http://justinethier.github.io/cyclone/
MIT License
823 stars 42 forks source link

Syntactic closures #486

Closed justinethier closed 2 years ago

justinethier commented 2 years ago

These are required if we want to migrate Chibi's syntax-case system to Cyclone.

justinethier commented 2 years ago

For background see:

https://people.csail.mit.edu/jaffer/slib/Syntactic-Closures.html https://github.com/justinethier/cyclone/blob/master/docs/research-papers/syntactic-closures.pdf http://community.schemewiki.org/?syntactic-closures

The following will need to be supported: identifier?, identifier->symbol, identifier=?, make-syntactic-closure and strip-syntactic-closures.

Also, what integration must be provided WRT ER macros? Can we define a macro using ER and then call, EG, identifier=??

mnieper commented 2 years ago

The syntax-case implementation I wrote for Chibi is not a fully correct implementation as syntax-case is more expressive than either ER or SC. Unless I had wanted to replace the core of Chibi, I couldn't do better.

But it certainly doesn't make sense to implement syntactic closures just to port my approximate implementation of syntax-case. A much better solution for Cyclone would be to fully support syntax-case. You can use my Unsyntax expander for that.

justinethier commented 2 years ago

@mnieper Interesting, does Unsyntax provide an R7RS implementation of syntax-case? How hard would it be to extract/reuse those parts?

mnieper commented 2 years ago

Unsyntax is written in portable R7RS. What it currently does is provide a compiler and REPL from R7RS+syntax-case+syntactic extensions to a very basic R7RS subset. It is packaged as a frontend that runs on a host Scheme. I used Chibi for its development and that's what is currently used as a host. If Cyclone's R7RS's implementation is sufficiently faithful, it should be no problem to replace Chibi with a Cyclone backend.

Just extracting the syntax-case implementation from Unsyntax would be more work. In some sense, it makes sense that Unsyntax is monolithic as an expander because the macro system and the module system are inherently interwoven in R6RS and R7RS.

justinethier commented 2 years ago

No plans to support syntactic closures. Closing.