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

Plugin that preserves locals between lines #28

Open
hoelzro opened this issue Mar 25, 2014 · 3 comments
Open

Plugin that preserves locals between lines #28

hoelzro opened this issue Mar 25, 2014 · 3 comments
Labels

Comments

@hoelzro
Copy link
Owner

hoelzro commented Mar 25, 2014

Ideas for how this could work:

  • Use debug.sethook to catch the return of our compiled chunk and grab its locals
  • Rewrite source code/bytecode before evaluation
  • Custom interpreter patch to "pcall and get locals"
  • Custom module that dips into internals to "pcall and get locals"
  • Add a chunk of source code to the end of the chunk to grab the locals
@technomancy
Copy link

This PR in the Fennel repl implements this feature using debug.getlocal by splicing in some code to save off and reintroduce locals to every chunk: bakpakin/Fennel#114

I'd be interested to hear what you think about it. Though the PR is for Fennel, the exact same approach should work for Lua.

@hoelzro
Copy link
Owner Author

hoelzro commented Nov 23, 2018

@technomancy I like the approach! If you want to port this logic to a lua-repl plugin, I would be happy to accept it!

@technomancy
Copy link

Thanks; I'm not doing much Lua these days but I might circle back to this at some point. If anyone wants to beat me to it it'd probably happen quicker that way. =)

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

No branches or pull requests

2 participants