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

repl: add a bunch of types to structs and methods #22377

Merged
merged 6 commits into from
Jun 19, 2017
Merged

Conversation

StefanKarpinski
Copy link
Member

No description provided.

@StefanKarpinski
Copy link
Member Author

CI failure is a timeout.


struct LatexCompletions <: CompletionProvider; end
mutable struct REPLCompletionProvider <: CompletionProvider end
mutable struct ShellCompletionProvider <: CompletionProvider end
Copy link
Member

Choose a reason for hiding this comment

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

Need these two structs continue to be mutable? Above (around old lines 80-84) you changed a couple similar mutable structs to structs, so thought I might ask :).

Base.text_colors[:red],
Base.text_colors[:yellow],
false, false, false, envcolors
)
Copy link
Member

Choose a reason for hiding this comment

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

Odd indentation? Perhaps better the ) simply terminate the preceding line?

Copy link
Member Author

@StefanKarpinski StefanKarpinski Jun 15, 2017

Choose a reason for hiding this comment

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

This is my preferred style for writing this kind of code. Clearly not universally agreed upon, but until we have an official style guide for this, I'm going to write it the way I prefer 😬

Copy link
Contributor

Choose a reason for hiding this comment

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

Also happens to be my and Invenia's preferred style :)

Copy link
Member

Choose a reason for hiding this comment

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

Fair enough :).

repl::LineEditREPL;
hascolor::Bool = repl.hascolor,
extra_repl_keymap::Vector{<:Dict} = Dict{Any,Any}[]
)
Copy link
Member

Choose a reason for hiding this comment

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

The ) placement seems a bit unusual here as well?

Copy link
Member Author

Choose a reason for hiding this comment

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

This is my preferred style, although obviously not everyone agrees.

Copy link
Contributor

Choose a reason for hiding this comment

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

Also happens to be my and Invenia's preferred style :)

Copy link
Member Author

Choose a reason for hiding this comment

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

Glad to know I'm not the only one 😁

Copy link
Member

@rfourquet rfourquet left a comment

Choose a reason for hiding this comment

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

This is excellent, each time I tried to hack around this files I got easily lost by the lack of type annotations. I'm not export here, but as long as the test passes, this LGTM, thanks!

terminal
histprompt
terminal::AbstractTerminal
histprompt # ::HistoryPrompt
Copy link
Member

Choose a reason for hiding this comment

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

Why comment the type annotation here? (similar question in other places, e.g. with CompletionProvider)

Copy link
Member Author

Choose a reason for hiding this comment

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

Because that's the type in practice, but HistoryPrompt doesn't exist yet when this is defined. The reverse dependency is unfortunate and something that should be fixed, but that kind of refactoring is beyond the scope of this PR.


struct LatexCompletions <: CompletionProvider; end
mutable struct REPLCompletionProvider <: CompletionProvider end
mutable struct ShellCompletionProvider <: CompletionProvider end
Copy link
Member

Choose a reason for hiding this comment

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

Seems you can remove the mutable here as you did for other types.

Copy link
Member Author

Choose a reason for hiding this comment

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

I tried that – they have finalizers, so it doesn't work.

Copy link
Member

Choose a reason for hiding this comment

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

Ah ok thanks

function setup_interface(
repl::LineEditREPL;
hascolor::Bool = repl.hascolor,
extra_repl_keymap::Vector{<:Dict} = Dict{Any,Any}[]
Copy link
Member

Choose a reason for hiding this comment

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

did you mean ::Vector{<:Associative} instead of ::Vector{<:Dict} ?

Copy link
Member Author

Choose a reason for hiding this comment

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

I could do that, but in practice only Dicts get stuck in there

Copy link
Member

Choose a reason for hiding this comment

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

Then why not Vector{Dict} ? The subtype operator on a concrete type looks confusing

Copy link
Member Author

Choose a reason for hiding this comment

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

Oh, I see what you're saying. Yes, that makes sense, not sure what I was thinking here.

Copy link
Member

Choose a reason for hiding this comment

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

Yeah, that's funny.

Pedantic question: do we say Dict is concrete without its type parameters? (asDict != Dict{Any,Any} - and if concrete Dict{Any,Any} always finds its way here in practice, I suppose there may be a minor performance difference too).

Copy link
Member

Choose a reason for hiding this comment

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

Oh I got confused, no 100% familiar yet with this {<:T} notation ;-)

`stty sane`
end,t.in_stream,t.out_stream,t.err_stream)
run((raw ? `stty raw -echo onlcr -ocrnl opost` : `stty sane`),
t.in_stream, t.out_stream, t.err_stream)
Copy link
Member

Choose a reason for hiding this comment

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

👍 :)

ccall(:jl_tty_set_mode,
Int32, (Ptr{Void},Int32),
t.in_stream.handle, raw) != -1
ccall(:jl_tty_set_mode, Int32, (Ptr{Void},Int32), t.in_stream.handle, raw) != -1
Copy link
Member

Choose a reason for hiding this comment

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

Missing space separating tuple arguments?

Copy link
Member

@Sacha0 Sacha0 left a comment

Choose a reason for hiding this comment

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

Superficially lgtm! :) (Modulo minor comments.)

@@ -113,22 +118,17 @@ cmove_right(t::UnixTerminal, n) = write(t.out_stream, "$(CSI)$(n)C")
cmove_left(t::UnixTerminal, n) = write(t.out_stream, "$(CSI)$(n)D")
cmove_line_up(t::UnixTerminal, n) = (cmove_up(t, n); cmove_col(t, 1))
cmove_line_down(t::UnixTerminal, n) = (cmove_down(t, n); cmove_col(t, 1))
cmove_col(t::UnixTerminal, n) = (write(t.out_stream, '\r'); n > 1 && cmove_right(t, n - 1))
cmove_col(t::UnixTerminal, n) = (write(t.out_stream, '\r'); n > 1 && cmove_right(t, n-1))
Copy link
Member

Choose a reason for hiding this comment

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

Why change this?

Copy link
Member Author

Choose a reason for hiding this comment

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

To be consistent with the formatting in the rest of the file, which doesn't have spaces in small arithmetic expressions anywhere else.

Copy link
Member

Choose a reason for hiding this comment

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

Okay, thanks for clarifying

@ararslan ararslan added the REPL Julia's REPL (Read Eval Print Loop) label Jun 15, 2017
include("LineEdit.jl")
include("REPLCompletions.jl")
include("REPL.jl")
include("repl/Terminals.jl")
Copy link
Contributor

Choose a reason for hiding this comment

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

using joinpath if possible may avoid mixed forward and backslashes in backtraces on windows

Copy link
Member

Choose a reason for hiding this comment

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

I finally understand why I see people use joinpath in otherwise trivial cases! Wow.

Copy link
Contributor

Choose a reason for hiding this comment

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

I'd kind of prefer if we used forward slashes for joinpath and everything else even on Windows but that might be unlikely. Most Windows programs can handle forward slashes in paths just fine, but maybe not all.

Copy link
Member Author

Choose a reason for hiding this comment

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

We should probably introduce Path types and have path"repl/Terminals.jl" produce whatever the native path syntax is. That would also allow path"C:\some\where" to work on Windows systems without double backslashes.

Copy link
Member Author

@StefanKarpinski StefanKarpinski Jun 17, 2017

Choose a reason for hiding this comment

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

This matches the style of all other includes in sysimg.jl, so I'm going to leave it. Normalizing path names to included files would probably make sense. I suspect this is not simply a style issue since joinpath is not defined when much of this file runs.

@StefanKarpinski
Copy link
Member Author

Failure is timeout and #22353, not related.

@StefanKarpinski StefanKarpinski merged commit 7affd0c into master Jun 19, 2017
@StefanKarpinski StefanKarpinski deleted the sk/rerepl branch June 19, 2017 01:07
@@ -1057,7 +1062,7 @@ function run_frontend(repl::StreamREPL, backend::REPLBackendRef)
dopushdisplay && popdisplay(d)
end

function start_repl_server(port)
function start_repl_server(port::Int)
Copy link
Contributor

Choose a reason for hiding this comment

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

::Integer ?

Copy link
Member Author

Choose a reason for hiding this comment

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

It's an internal function and if the value is too large, this won't work anyway, so Int is ok.

timholy added a commit that referenced this pull request Jun 14, 2020
This finishes the work started in #22377
JeffBezanson pushed a commit that referenced this pull request Jun 15, 2020
This finishes the work started in #22377
simeonschaub pushed a commit to simeonschaub/julia that referenced this pull request Aug 11, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
REPL Julia's REPL (Read Eval Print Loop)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

10 participants