One Kind of Binding?

Meta: an originating thread from Qi's meeting notes.


I have not completely followed the abc/syntax-local-value problems, but I think others have covered my own opinions pretty well. That is, there might be a way to do this that that looks like define-syntax as insert-compiler-hook and for-lang as a (possibly implicit) way to insert it.

I especially agree with @shhyou and @notjack 's characterizations: I suggested a similar implementation strategy, and I suspect one motiviation for Sid's desire for a simpler (?) model is that it would make testing Qi's deforestation pipeline easier. In particular, there we care about the results of expansion and the clients' exercise of the macros (in that we should get the same results through a completely different interpretation of the surface code).

2 other open not-so-open (?) questions, in my mind:

  1. If functions manipulating syntax may eventually become macros, they will still need a rich API of syntax operators. You might be able to make syntax-local-value and syntax-local-eval implicit (vis. evaluation of bindings and expressions at the runtime phase of the ordinary function that happens to manipulate syntax), but I don't think you could remove, e.g., syntax-local-lift-require and the rest of the rich API, nor should you want to.

    Perhaps that's not a real obstacle or part of the original proposal, so feel free to ignore me—but syntax-local-lift-require does get back to the testing thing for me. How to test that it works? Especially after my recent trouble integrating it with Frosthaven Manager (see also needing a new testfile to check the results of test programs). I've landed on something like @notjack proposes, which is exercising client code. In my case, I needed to not only check that #lang code compiled as before but now also check the values it computes. This is probably obvious to advanced macrologists, but it's taken me some experimentation and hard-won bugfixes to get here. (Another chapter in my to-be-written book about building large GUI programs?)

  2. What happens for things like (require (for-lang (only-in racket/base add1))) (add1 4)? Presumably that's a expand-time contract-style error that add1 only accepts numbers and was given syntax? (I think that would be on-par with today.)