Skip to content
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

Expose functionality for eval in local scope #69

Closed
toivoh opened this issue Mar 28, 2015 · 1 comment
Closed

Expose functionality for eval in local scope #69

toivoh opened this issue Mar 28, 2015 · 1 comment

Comments

@toivoh
Copy link
Owner

toivoh commented Mar 28, 2015

Most of the code in Debug.jl is actually devoted to making it possible to evaluate code in a local scope (through instrumentation, analysis, etc). This is currently only used to evaluate expressions in debug sessions. It would be nice if this functionality could be exposed for wider use.

Possible approach:

  • Introduce a macro @localscope, which evaluates to the Scope representing the local scope, when used inside of @debug
    • Make it raise an error otherwise?
  • Introduce a macro @debug_analyze which works like @debug and allows @localscope but doesn't emit any traps
  • Make @debug_analyze not introduce any more instrumentation than necessary
toivoh added a commit that referenced this issue Mar 28, 2015
* Add `code_analyzed_only` function to be used by macros that only make sense inside analyzed code
    * The code throws an error with custom message in the normal case
    * Make `decorate` recognize it and unwrap the payload instead
* Add `@localscope` macro that evaluates to the local scope
    * Make it produce a new node type `GetLocalScope` wrapped in `code_analyzed_only`
    * Make `instrument_args` emit the local scope symbol for `GetLocalScope`
* Add a `keys` method for `Scope`, returning its set of local variables
* Add simple test

Also change `Debug.Meta.quot` to produce a `QuoteNode`.
toivoh added a commit that referenced this issue Mar 28, 2015
@toivoh
Copy link
Owner Author

toivoh commented Mar 28, 2015

This seems to be working now

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant