Sorry, last prompt in CL code should be "cl-user", not "foo". So full code should look like this:
;; initially working from cl-user package cl-user> (defpackage foo (:use :common-lisp)) ;; automatically switched to new package foo> (defvar x 1) X foo> x 1 foo> (in-package :cl-user) cl-user> x ;; error: x not defined in :cl-user On Fri, Sep 5, 2014 at 11:58 PM, Andrei <faithlessfri...@gmail.com> wrote: > In module.c in Julia sources I see "jl_set_current_module()" function. Is > it somehow exposed to Julia API? > > To give you some context, in Common Lisp (as well as some other dialects) > there are 2 separate macros for dealing with packages (analogue of modules > in Julia): > > defpackage - defines new package and switches to it > in-package - simply switches to specified package > > One great feature that these macros bring is ability to easily switch > context of execution. E.g. in REPL (code simplified): > > ;; initially working from cl-user package > cl-user> (defpackage foo (:use :common-lisp)) ;; automatically switched > to new package > foo> (defvar x 1) > X > foo> x > 1 > foo> (in-package :cl-user) > foo> x > ;; error: x not defined in :cl-user > > This is extremely helpful for both - package extension and > debugging/interactive development. E.g. we can switch to a module in > question and get all internal variables visible, play around in that > context and go back to main package without stopping REPL. > > So I'm wondering if something like this is possible in Julia at all. >