racket-mock icon indicating copy to clipboard operation
racket-mock copied to clipboard

Use `make-syntax-introducer` instead of `generate-temporary`

Open jackfirth opened this issue 9 years ago • 0 comments

This is mostly to make sure I understand the syntax system better.

Currently define/mock and with-mocks communicate in the following manner:

  1. The define/mock form creates an identifier for each mocked dependency, opaque value, the implementation of the procedure using mocks, and the one not using mocks.
  2. The define/mock form bundles up a list of all these identifiers
  3. The define/mock form binds the given procedure identifier as a rename transformer for the normal implementation that has the list of all identifiers used by define/mock stored in the transformer.
  4. The with-mocks form looks up the stored static information for the procedure it's given and rebinds the normal procedures to the mocks created by define/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.

jackfirth avatar Aug 03 '16 20:08 jackfirth