-
Notifications
You must be signed in to change notification settings - Fork 179
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[macroexpand] Make macroexpand mw delegate the expansion to eval #894
Conversation
a6fed97
to
faa91d0
Compare
Removed tools-deps-testing .This test only exists to ensure LOADER is bound during macroexpansion. By delegating the expansion to eval middleware, LOADER becomes the responsibility of nREPL which always binds it. Besides, since there is no longer a direct function to macroexpand a form, recreating this test would require properly setting up a client-server integration test. I don't feel this is necessary anymore. |
I like the direction of this PR - admittedly I had totally forgot how we had implemented the macroexpansion in the past, and your proposal seems better in every way. (I'm not sure how you've managed to come across this, but I'm glad you did!) A simpler test setup is welcome as well. |
b150967
to
9a90ae7
Compare
540b350
to
f851776
Compare
This test only existed to ensure LOADER is bound during macroexpansion. By deletaging the expansion to eval middleware, LOADER becomes the responsibility of nREPL which always ensures it is bound.
f851776
to
fdeac40
Compare
Ready for review. Testing times dropped to ~11 minutes from ~20. |
Impressive speedup! Great work! 🚀 |
This PR is a quite significant do-over of macroexpansion middleware.
The current implementation of CLJ macroexpander performs the expansion in the "middleware context". Because of that, the middleware has to carefully recreate an eval-like context (bind
*ns*
, ensureLOADER
is bound), and problems like #886 still fall through. But we already have the eval-like context set up in the interruptible-eval middleware. This approach is already used by theinspect
middleware for the initial inspector start command – it is a flavor ofeval
message that is intercepted by inspect mw on its way out.I propose to do the same for macroexpansion – let the
eval
mw perform the expansion with all the correct dynamic bindings and context, just like if the user typed(macroexpand 'form)
at the REPL. Then, intercept the resulting form and perform the "middleware work" (pretty printing, tidying up symbols) in the "middleware context".