racket-mock
racket-mock copied to clipboard
Use `make-syntax-introducer` instead of `generate-temporary`
This is mostly to make sure I understand the syntax system better.
Currently define/mock and with-mocks communicate in the following manner:
- The
define/mockform creates an identifier for each mocked dependency, opaque value, the implementation of the procedure using mocks, and the one not using mocks. - The
define/mockform bundles up a list of all these identifiers - The
define/mockform binds the given procedure identifier as a rename transformer for the normal implementation that has the list of all identifiers used bydefine/mockstored in the transformer. - The
with-mocksform looks up the stored static information for the procedure it's given and rebinds the normal procedures to the mocks created bydefine/mock.
If I understand Racket's scopes model correctly, instead the mock library could define a mock scope using make-syntax-introducer. Then define/mock could take the identifiers its given for procedures using mocks and mocked dependencies and add that scope, instead of creating new identifiers for each with generate-temporary. I'm fairly certain this would be clearer and easier to implement.