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

Add call to expose variables declared with Eval #1385

Closed
firelizzard18 opened this issue Apr 16, 2022 · 0 comments · Fixed by #1387
Closed

Add call to expose variables declared with Eval #1385

firelizzard18 opened this issue Apr 16, 2022 · 0 comments · Fixed by #1387
Labels
area/api change in API area/core enhancement New feature or request
Milestone

Comments

@firelizzard18
Copy link
Contributor

firelizzard18 commented Apr 16, 2022

Proposal

I want a function that lists all of the global variables in package main. Specifically, I want a list of variables declared with Eval("var x = 1") and Eval("y := 1").

// Globals returns a map of global variables and constants in the main package.
func (*Interpreter) Globals() map[string]reflect.Value

Background

I have developed an extension that implements Yaegi-based notebooks for Visual Studio Code. I want to add a variables view, like the Jupyter extension has for their notebooks.

Workarounds

I don't think there are any. I was going to show a horrible hack using the debugging interface, but I don't think that exposes global variables. The Symbols function only returns exported values.

@mvertes mvertes added enhancement New feature or request area/core area/api change in API labels Apr 22, 2022
@mvertes mvertes added this to the v0.11.x milestone Apr 22, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/api change in API area/core enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants