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
831 stars 45 forks source link

Add syntax-case support #456

Open justinethier opened 3 years ago

justinethier commented 3 years ago

It may be possible to support syntax-case by porting the implementation from Chibi: https://github.com/ashinn/chibi-scheme/pull/500/files

arthurmaciel commented 3 years ago

Hi @justinethier! Any plan to implement syntax-case in the near future?

justinethier commented 3 years ago

Hi @arthurmaciel!

There has been discussion of this topic on IRC with the recent voting for the R7RS Large Yellow Edition.

Unfortunately, after reading through the comments and looking at this again, the Chibi implementation uses syntactic closures (SC) as well as ER macros:

2021-10-20 02:56:42 gwatt: the issue, afaik, is that for explicit renaming, symbols are identifiers, whereas in syntax-case, syntax objects are identifiers 2021-10-20 02:59:00 ISTR it works the other way around though: implementing syntax-case on top of er macros 2021-10-20 02:59:58 no, there you have the issue that ER only gives you two contexts to inject identifiers into/grab them from (either using rename or a bare symbol), whereas syntax-case lets you do it at any timestamp for which you already have another marked syntax-object 2021-10-20 03:00:58 Chibi's implementation has to use the 'other' low-level macro system in Chibi, syntactic closures, to work around this. and even then, MNW told me it has some limitations

Since Cyclone does not support SC that would need to be implemented first before any of this code could be ported over.

Anyway, no plans to do this immediately but it will be interesting to see how the Yellow Edition voting goes. As of now there is a lot of support for syntax-case: https://docs.google.com/forms/d/e/1FAIpQLScAfyfkdq2eL5LgrUyatufD-iIcKGCKIOq-A6IrmsKW-RxdkQ/viewanalytics

justinethier commented 2 years ago

syntax-case could potentially be implementing using unsyntax. See: https://github.com/justinethier/cyclone/issues/486

justinethier commented 2 years ago

See also the sample implementation from SRFI 72 - https://srfi.schemers.org/srfi-72/srfi-72.html