blackhole icon indicating copy to clipboard operation
blackhole copied to clipboard

Implement syntax-case macros

Open per-gron opened this issue 14 years ago • 1 comments

Black Hole supports ER macros, macros through syntactic closures and syntax-rules macros, but not syntax-case. It would be nice to have.

Implementing this would probably consist of creating a file similar to syntax-rules.scm and implement the main functionality of syntax-case there. Because of how similar the pattern matching is, it might be good to take out some of that code from syntax-rules.scm and share it.

One difficulty is that syntax-case macros (IMO completely stupidly) assume that a macro transformer is a function that takes one argument, its syntactic parameter. But BH macros are implemented with functions that take three arguments: the syntax, the hygienic environment for the expansion place and the hygienic environment of the macro. I don't know how to solve it, the best way to do it might be to create a compound data structure with all three arguments to the macro.

per-gron avatar Mar 22 '10 00:03 per-gron

This link might be of interest: http://www.scheme.com/tspl2d/syntax.html

The best way of implementing syntax-case might be to take the syntax-rules code and extend it to become syntax-case and then re-implement syntax-rules in terms of syntax-case. I'm not sure if that's feasible, but it's worth investigating; it would save quite a lot of duplication. And optimizations made to syntax-case would apply to syntax-rules as well.

per-gron avatar Mar 22 '10 08:03 per-gron