Closed rebolbot closed 8 years ago
Submitted By: BrianH (14-Jun-2009 05:41)
Isolate: true is documented, and does work, but doesn't apply in this case - it actually does the opposite of what you want.
Based on our conversations the file %vprint.r3 is a module. Modules don't export their words into the current context unless the words are explicitly specified in an Exports header, even if the module is called with DO.
Without the source to %vprint.r3 we can't know whether the words are exported, or whether there is another problem. Please provide a link.
Submitted By: maxim (14-Jun-2009 06:08)
vprint isn't a module its just a normal script.
Submitted By: maxim (14-Jun-2009 07:01)
here is a short and explicit example... three files
;--------------------------------------
; application script: %mymodule-do-binding-bug928.r
;--------------------------------------
rebol []
import 'mymodule-bug928
ask "..."
;--------------------------------------
;- module: %mymodule-bug928.r
;--------------------------------------
rebol [
type: 'module
name: 'mymodule-bug928
]
print "TADAM ... mymodule-bug928"
do %myscript.r
myfunc 928
;--------------------------------------
;- script DOne from module: %myscript.r
;--------------------------------------
rebol [
title: "myscript.r"
]
myfunc: func [arg][print arg]
;=========================================
; console output
;=========================================
Evaluating: /D/dev/project/liquid-r3/debug/mymodule-do-binding-bug928.r
TADAM ... mymodule-bug928
Script: "myscript.r" Version: none Date: none
** Script error: myfunc word is not bound to a context
** Where: do applier make if import catch if either either do begin do
** Near: do body obj
Submitted By: BrianH (14-Jun-2009 08:18)
I get it now, thanks.
Modules import words into their contexts with the Needs header. While modules can DO other scripts, any words that leak outside those scripts won't affect the context of the module. The code block of a module is bound to the module's context before it is executed. If you want to rebind some code with new words you need to do so manually.
This is all the result of the module using its own context rather than the global context. This allows the behavior of the module to be predictable, just by tracing its imports.
While non-module scripts can ignore modules and use DO or the IMPORT function, modules need to be written modularly.
This is by design, not a bug.
Submitted By: maxim (14-Jun-2009 08:56)
thanks for the extensive discussion in altme..
the above needs to be added to the module documentation (with a bit more explicit details) and maybe use the supplied scripts as a reference for explanation.
this is important information and must not be lost in the mayhem of development. This information really helps to understand explictitely how the module system is working. :-)
when using DO on a script, within a module, that module doesn't have access to the words defined in the DOne script.
someone suggested using isolate: true in the header, but its not documented, and not working either.
below is a complete module example trying to load a script called vprint, which sets all of the vxxxx words used in the module.