vukung
vukung

Reputation: 1884

Change REPL module/namespace in Julia

I'm looking for a way to "enter" a module in the REPL, so that I can access all symbols without qualification (not just the exported ones), and any function (re)defined at the REPL gets in the specified module. (Basically this is the functionality of Common Lisp's in-package macro.)

This would be useful in a REPL-oriented workflow, as I would be able to write the same code in the REPL as in the module I am developing.

The manual recommends a workflow where I qualify everything, but that seems annoying.

Upvotes: 7

Views: 460

Answers (3)

digikar
digikar

Reputation: 588

It's 2020, I'm using Julia 1.4, and was unable to get REPLMods.jl to work. I think the following seem good enough for the time being:

Upvotes: 1

spencerlyon2
spencerlyon2

Reputation: 9686

I started a package called REPLMods.jl for this a while back. It should probably be polished up, but I haven't had the time.

I spoke to core Julia members and there was interest in getting it merged into base once things were clean, but again, no time!

Upvotes: 7

Tasos Papastylianou
Tasos Papastylianou

Reputation: 22255

I know this isn't quite what you're asking, but just in case the 'obvious' had not occured to you (or future visitors to the question), assuming you loaded a module with an annoyingly cumbersome name, e.g.

import LaTeXStrings

and you don't want to have to type LaTeXStrings all the time just to explore its accessibles, i.e.

LaTeXStrings.[TAB]

you can just assign the imported module as a whole to another variable, i.e.

const l = LaTeXStrings

I'm sure in the absence of a more appropriate built-in solution, at least typing l.[TAB] as opposed to LaTeXStrings.[TAB]is a lot more tolerable :)

(I find it odd, in fact, that julia doesn't seem to support the import LaTeXStrings as l syntax ...)

Upvotes: 1

Related Questions