I am configuring the automatic start of OhMyREPL.jl. The document advise putting the following code in the .julia/config/startup.jl file:
atreplinit() do repl
    try
        @eval using OhMyREPL
        println("OhMyREPL imported")    # I add this line
    catch e
        @warn "error while importing OhMyREPL" e
    end
end
Now I have some questions on this code:
- Why do I have to write the try...catch...endcode segment into theatreplinit() do repl...end?
- Why do I have to add an @evalbeforeusing OhMyREPLbut unnecessarily do that beforeprintln(“OhMyREPL imported”)?
 
            
              
              
              
            
            
           
          
            
            
              Thanks for response!
In my first question I actually want to know why is the atreplinit() do repl ... end block necessary?
             
            
              
              
              
            
            
           
          
            
            
              From the docs
help?> atreplinit
search: atreplinit
  atreplinit(f)
  Register a one-argument function to be called before the REPL interface is initialized in interactive sessions; this is useful to customize the interface. The
  argument of f is the REPL object. This function should be called from within the .julia/config/startup.jl initialization file.
It is added so that OhMyREPL is only loaded when running interactively.
If you are using Julia just to run a script once, like julia compute_something.jl, then you likely don’t need OhMyREPL, so the above prevents that.
             
            
              
              
              3 Likes