[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Scheme-reports] auxiliary syntax


I'm still trying to understand the problem here, so please bear with me if this is incorrect.

In a nutshell, this seems to be the issue: Alex wants to distribute an SRE library. This library uses certain symbols as syntax for regular expressions. This library may analyze regular expressions either at expansion time or at run time.

At expansion time, we want (for modularity reasons) to be able to rename the symbols if they are going to be confusing. This means that the names that appear in the code may be different than the objects that the macros actually work with, and there's some layer in between that knows how to rename things so that no one gets confused.

However, at runtime, the *procedures* that compile an _expression_ only understand a certain fixed set of symbols, and they can't be renamed. Furthermore, the macros that run at expansion time may want to call the procedures (also at expansion time).

Because of this renaming issue, it is not correct for a macro to simply quote a list it was given and pass the quoted list an argument for the procedure. The only way to make this work is for the magic renamer (that knew about the renamings earlier) to also participate in the renaming that the macro does before it passes its list to a function. So you want some special form meaning "quote, but do renamings first".

Is that a correct summary of the issue?

(If so, it sounds like syntax parameters may be the solution. But at this point I'm just trying to make sure I understand the problem.)

Noah Lavine

On Mon, Jan 7, 2013 at 11:26 AM, John Cowan <cowan@x> wrote:
Alex Shinn scripsit:

> Really, when you want to wrap macros on top of a non-macro-based DSL,
> the only solution is to use unhygienic matching.  But there's no way
> to do this with syntax-rules, which is all we have in both R5RS and
> R7RS small.
> This is a SERIOUS problem.  I'm still unaware of any halfway decent
> solution, and although I don't think we're without hope, I'd appreciate
> it if people stop putting their head in the sand and pretending there
> isn't a problem here.

If I understand this rant correctly (and I'm not sure I do), and if I
understand syntax-parameters correctly (and I'm even less sure of that),
then they seem to be a solution to this problem of adding just a little
controlled non-hygiene to syntax-rules.  What I don't know (and I think
nobody knows) is whether they can be implemented on top of syntactic
closures or explicit renaming.  You are probably in the best position
of anybody to find out the answer to that.

Racket: http://docs.racket-lang.org/reference/stxparam.html
Guile: http://www.gnu.org/software/guile/manual/html_node/Syntax-Parameters.html
Scheme Workshop paper: http://www.schemeworkshop.org/2011/papers/Barzilay2011.pdf

That you can cover for the plentiful            John Cowan
and often gaping errors, misconstruals,         http://www.ccil.org/~cowan
and disinformation in your posts                cowan@x
through sheer volume -- that is another misconception.  --Mike to Peter

Scheme-reports mailing list

Scheme-reports mailing list