Skip to content

Commit

Permalink
importall Base.Operators by default
Browse files Browse the repository at this point in the history
  • Loading branch information
JeffBezanson committed Feb 8, 2013
1 parent 9e8da90 commit 7c763d4
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 4 deletions.
5 changes: 3 additions & 2 deletions src/init.c
Original file line number Diff line number Diff line change
Expand Up @@ -439,8 +439,9 @@ void julia_init(char *imageFile)
// the Main module is the one which is always open, and set as the
// current module for bare (non-module-wrapped) toplevel expressions.
// it does "using Base" if Base is available.
if (jl_base_module != NULL)
jl_module_using(jl_main_module, jl_base_module);
if (jl_base_module != NULL) {
jl_add_standard_imports(jl_main_module);
}
// eval() uses Main by default, so Main.eval === Core.eval
jl_module_import(jl_main_module, jl_core_module, jl_symbol("eval"));
jl_current_module = jl_main_module;
Expand Down
1 change: 1 addition & 0 deletions src/julia.h
Original file line number Diff line number Diff line change
Expand Up @@ -893,6 +893,7 @@ void jl_module_using(jl_module_t *to, jl_module_t *from);
void jl_module_import(jl_module_t *to, jl_module_t *from, jl_sym_t *s);
void jl_module_importall(jl_module_t *to, jl_module_t *from);
DLLEXPORT void jl_module_export(jl_module_t *from, jl_sym_t *s);
void jl_add_standard_imports(jl_module_t *m);

// external libraries
DLLEXPORT uv_lib_t *jl_load_dynamic_library(char *fname);
Expand Down
14 changes: 12 additions & 2 deletions src/toplevel.c
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,15 @@ jl_module_t *jl_old_base_module = NULL;

jl_value_t *jl_toplevel_eval_flex(jl_value_t *e, int fast);

void jl_add_standard_imports(jl_module_t *m)
{
// using Base
jl_module_using(m, jl_base_module);
// importall Base.Operators
jl_module_importall(m, (jl_module_t*)jl_get_global(jl_base_module,
jl_symbol("Operators")));
}

extern int base_module_conflict;
jl_value_t *jl_eval_module_expr(jl_expr_t *ex)
{
Expand Down Expand Up @@ -60,8 +69,9 @@ jl_value_t *jl_eval_module_expr(jl_expr_t *ex)

// add standard imports unless baremodule
if (std_imports) {
if (jl_base_module != NULL)
jl_module_using(newm, jl_base_module); // using Base
if (jl_base_module != NULL) {
jl_add_standard_imports(newm);
}
}

JL_GC_PUSH(&last_module);
Expand Down

0 comments on commit 7c763d4

Please sign in to comment.