Skip to content

Commit 69667f0

Browse files
committed
Set local-lib to refer to the local import library
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. See http://issue.cc/r3/2116 for details.
1 parent 25033f8 commit 69667f0

File tree

2 files changed

+3
-1
lines changed

2 files changed

+3
-1
lines changed

src/mezz/sys-base.r

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

133134
unless spec/type [spec/type: 'module] ; in case not set earlier
134135

@@ -180,6 +181,7 @@ make-module*: func [
180181
]
181182

182183
bind body obj
184+
obj/local-lib: any [mixins make object! 0] ; always set, always overrides
183185
if block? hidden [protect/hide/words hidden]
184186
obj: to module! reduce [spec obj]
185187
do body

src/mezz/sys-start.r

+1-1
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ start: func [
120120

121121
;-- Make the user's global context:
122122
tmp: make object! 320
123-
append tmp reduce ['system :system]
123+
append tmp reduce ['system :system 'local-lib :tmp]
124124
system/contexts/user: tmp
125125

126126
;boot-print ["Checking for user.r file in" file]

0 commit comments

Comments
 (0)