racket / macro-debugger

Other
8 stars 16 forks source link

Step through one expression instead of entire module #41

Open jackfirth opened 2 years ago

jackfirth commented 2 years ago

Today I stepped through this program in the macro stepper:

#lang typed/racket/base

(: mad (Flonum Flonum Flonum . -> . Flonum))
(define (mad a b c)
  (+ (* a b) c))

I was trying to verify that (+ (* a b) c) expands to (unsafe-fl+ (unsafe-fl* a b) c). I did that successfully, but had to step to the end of the whole module's expansion and search through the giant expanded module for just the one (#%app:61 unsafe-fl+ (#%app:62 unsafe-fl* a b) c) expression I was looking for.

It would be really, really nice if I could select just the (+ (* a b) c) expression in the editor and show the macro stepper's steps for only that expression. So it should skip all the steps that change other parts of the module, and when showing me a step it shouldn't show me anything other than what changed in that expression. This would make the macro stepper way, way easier to use IMO.

rmculpepper commented 2 years ago

Yes, I agree. The general problem is tricky, though. The interpretation of a term is determined by its context, and while most macros are "well-behaved", a macro can duplicate an term, treat a term both as an expression and as something else, local-expand it and transform the result, and so on. On the other hand, macro hiding deals with similar issues, so some of the infrastructure is already available, but it would require some work to adapt. No estimate when I'll get to that.