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

mechanism for obtaining local variable names and values #29366

Closed
JeffBezanson opened this issue Sep 25, 2018 · 4 comments
Closed

mechanism for obtaining local variable names and values #29366

JeffBezanson opened this issue Sep 25, 2018 · 4 comments
Labels
compiler:lowering Syntax lowering (compiler front end, 2nd stage) feature Indicates new feature / enhancement requests

Comments

@JeffBezanson
Copy link
Member

It could be useful for debugging to be able to easily get the names and values of all variables in scope, e.g. so you don't have to manually write them all in a call to @show. This could be provided as a macro @locals (though needs to be implemented specially in lowering, since the set of variables in scope is not available during macro expansion), returning a dictionary, similar to locals() in python: https://docs.python.org/3/library/functions.html#locals

Thoughts?

@JeffBezanson JeffBezanson added compiler:lowering Syntax lowering (compiler front end, 2nd stage) feature Indicates new feature / enhancement requests labels Sep 25, 2018
@ararslan
Copy link
Member

Is this different from varinfo()?

@JeffBezanson
Copy link
Member Author

varinfo only applies to globals. For locals, it can't be implemented as a function, and you'd also probably rather get the values themselves rather than a table summarizing them. names and eval give you everything you need for globals.

@mattcbro
Copy link

This would be super useful. I see some code here but does it actually exist in any version of Julia? I can't seem to find it in Julia 1.0.3. @Locals is not defined in Base.

@KristofferC
Copy link
Member

It exists in the downloadable release candidate for julia 1.1.0.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
compiler:lowering Syntax lowering (compiler front end, 2nd stage) feature Indicates new feature / enhancement requests
Projects
None yet
Development

No branches or pull requests

4 participants