Skip to content

Commit c49f86a

Browse files
committed
FEAT: Set local-lib to refer to the local import library
resolves: Oldes/Rebol-wishes#13 Instead of having the local import library object have no referent once the module is running except the words you bound from it, set the word local-lib in the module context to refer to it. This will let the developer control overrides, just like lib does globally. Also set local-lib to system/contexts/user in the script context. Even though there is nothing for scripts like the object target of local imports in modules, presetting the word will prevent it from being a problem when modules unnecessarily export it, and it will serve as a shortcut way to refer to the context, like lib. (cherry picked from commit 69667f0)
1 parent 52ee407 commit c49f86a

File tree

2 files changed

+3
-1
lines changed

2 files changed

+3
-1
lines changed

src/mezz/sys-base.reb

+2
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,7 @@ make-module*: func [
132132
if find spec/options 'extension [
133133
append obj 'lib-base ; specific runtime values MUST BE FIRST
134134
]
135+
append obj 'local-lib ; local import library for the module
135136

136137
unless spec/type [spec/type: 'module] ; in case not set earlier
137138

@@ -183,6 +184,7 @@ make-module*: func [
183184
]
184185

185186
bind body obj
187+
obj/local-lib: any [mixins make object! 0] ; always set, always overrides
186188
if block? hidden [protect/hide/words hidden]
187189
obj: to module! reduce [spec obj]
188190
do body

src/mezz/sys-start.reb

+1-1
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ start: func [
131131

132132
;-- Make the user's global context:
133133
tmp: make object! 320
134-
append tmp reduce ['system :system]
134+
append tmp reduce ['system :system 'local-lib :tmp]
135135
system/contexts/user: tmp
136136

137137
;boot-print ["Checking for user.reb file in" file]

0 commit comments

Comments
 (0)