Stream: helpdesk (published)

Topic: regarding ReplMaker


view this post on Zulip arbitrandomuser (Jun 01 2022 at 18:52):

@Mason Protter
How does the
atreplinit() suggestion in the readme work ?

atreplinit() do repl
    try
        @eval using ReplMaker
        @async initrepl(
            apropos;
            prompt_text="search> ",
            prompt_color=:magenta,
            start_key=')',
            mode_name="search_mode"
        )
        catch
        end
    end
end

what i dont understand is why it works with the @async .
while the _atreplinit is being executed in client.jl, the Base.active_repl is not defined right ?
why does then this work with @async ? is this sort of 'relying on a race condition` that Base.active_repl gets
defined before that line in the async is reached ?

edit: okay Base.active_repl isdefined , but not fully instantiated with interfaces and modes ,
either way my question is are we relying on them being instantiated before the @async tries to reach them ?

view this post on Zulip arbitrandomuser (Jun 01 2022 at 19:21):

, alright .. i dont understand this ..
suppose i have this in my startup.jl ...

atreplinit() do repl
        @eval using ReplMaker
        @show methods(initrepl)
        initrepl(
            apropos;
            prompt_text="search> ",
            prompt_color=:magenta,
            start_key=')',
            mode_name="search_mode"
        )
    end

and then i start a repl . i get this error ..

└── julia
               _
   _       _ _(_)_     |  Documentation: https://docs.julialang.org
  (_)     | (_) (_)    |
   _ _   _| |_  __ _   |  Type "?" for help, "]?" for Pkg help.
  | | | | | | |/ _` |  |
  | | |_| | | | (_| |  |  Version 1.7.2 (2022-02-06)
 _/ |\__'_|_|_|\__'_|  |  Official https://julialang.org/ release
|__/                   |

methods(initrepl) = # 1 method for generic function "initrepl":
[1] initrepl(parser::Function; prompt_text, prompt_color, start_key, repl, mode_name, show_function, show_function_io, valid_input_checker, keymap, completion_provider, sticky_mode, startup_text) in ReplMaker at /home/antineutrino/.julia/packages/ReplMaker/ViCwA/src/ReplMaker.jl:42
MethodError: no method matching initrepl(::typeof(apropos); prompt_text="search> ", prompt_color=:magenta, start_key=')', mode_name="search_mode")
Closest candidates are:
  initrepl(::Function; prompt_text, prompt_color, start_key, repl, mode_name, show_function, show_function_io, valid_input_checker, keymap, completion_provider, sticky_mode, startup_text) at ~/.julia/packages/ReplMaker/ViCwA/src/ReplMaker.jl:42
julia>

view this post on Zulip arbitrandomuser (Jun 01 2022 at 19:23):

that exact method exists , as shown by @show . but it still complains of no method matching .. closes candidates which is the same method :thinking:

view this post on Zulip arbitrandomuser (Jun 01 2022 at 19:34):

tl;dr , why the @async


Last updated: Oct 02 2023 at 04:34 UTC