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

Make the REPL re-entrant and easier to debug #6413

Merged
merged 2 commits into from
Apr 4, 2014

Conversation

mbauman
Copy link
Member

@mbauman mbauman commented Apr 4, 2014

The two patches here simplify working with the REPL itself. The first allows for printing of REPL objects in the REPL. The second makes it re-entrant.

Previously, the keymap functions were assigned a name with the eval macro (that is - in global scope). This changes the keymap macro to instead return an anonymous function so that additional instances of the REPL don't clobber the previous keymap functions.

So, you can now start a second REPL inside the first. I've found this particularly useful for testing keybindings, but I could see it being useful in other cases, too.

Base.REPL.run_repl(Base.REPL.LineEditREPL(Base.Terminals.TTYTerminal(get(ENV,"TERM",""),STDIN,STDOUT,STDERR)))

cc: @nolta @loladiro

@StefanKarpinski
Copy link
Member

cc: @loladiro

@Keno
Copy link
Member

Keno commented Apr 4, 2014

LGTM in general, but see Travis failure.

@mbauman
Copy link
Member Author

mbauman commented Apr 4, 2014

Oops. I've made the @keymap API changes to the test file now and all passes on my machine. I should know better than to not run the tests. Sorry about that.

@@ -39,6 +39,9 @@ type Prompt <: TextInterface
hist
end

string(x::Prompt) = string("Prompt(\"", x.prompt, "\",...)")
show(io::IO, x::Prompt) = print(io, string(x))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it suffices to define print and you get both of these automatically.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, you're right, the string method definition is superfluous. The chain goes string -> print -> show.

mbauman added 2 commits April 4, 2014 13:35
Prevent a recursive show call with Prompt objects
Previously, the keymap functions were assigned a name with the eval macro (in global scope). This changes the keymap macro to instead return an anonymous function so that additional instances of the REPL don't clobber the keymap functions of previous ones.
@mbauman
Copy link
Member Author

mbauman commented Apr 4, 2014

I've removed the superfluous string method.

Keno added a commit that referenced this pull request Apr 4, 2014
Make the REPL re-entrant and easier to debug
@Keno Keno merged commit 7d495c0 into JuliaLang:master Apr 4, 2014
@mbauman mbauman deleted the repl-debug branch April 7, 2014 21:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants