r3wp [groups: 83 posts: 189283]
  • Home
  • Script library
  • AltME Archive
  • Mailing list
  • Articles Index
  • Site search
 

World: r3wp

[!REBOL3-OLD1]

Maxim
14-Jun-2009
[15558x2]
I agree, that is the point of reloading it runtime.
but right now it crashes at the second load.
BrianH
14-Jun-2009
[15560x3]
I could use a minimal header and code block of a module that triggers 
the assertion crash on reimport by filename (bug#923).
Justt something to trace and test with.
Those assertion crashes are caused in the native code, but we need 
to narrow down *which* native code.
Maxim
14-Jun-2009
[15563x3]
I just uploaded an VERY minimal module and application with 3 imports... 
the 2 initial are by name and are fine, the third is by file and 
it crashes.
is that ok for testing?
for (bug#923)
BrianH
14-Jun-2009
[15566]
That's what I thought - it's named. You are only supposed to import 
named modules once per version - subsequent imports are to be by 
name. New versions are supposed to displace the old, and that might 
be where the crash is. This will be interesting to trace.
Maxim
14-Jun-2009
[15567x2]
have fun  ;-)
currently building example scripts for bug#924
BrianH
14-Jun-2009
[15569]
Cool, thanks.
Maxim
14-Jun-2009
[15570x2]
posted 3 file example.
re bug#924 in one test, I even had the print word not bount to any 
context !
BrianH
14-Jun-2009
[15572x2]
OK, I just looked at bug#924 and now get what you want to do. It's 
not a bug, it's by design. The code block of a module is bound before 
the block starts executing. You can't define new words in the module's 
context unless those new words are defined in imported modules or 
in the code itself at the top level, or anywhere in the code if the 
module is isolated.
Sorry, bug#928, not 924.
Maxim
14-Jun-2009
[15574]
why is that?  this means we can't create new words in a module at 
run-time?
BrianH
14-Jun-2009
[15575]
Right. Even if you did you wouldn't be able to use them because the 
code would already have been bound.
Maxim
14-Jun-2009
[15576x2]
aren't module contexts auto-expanding?
but in the script (previously global) context... every word is bound 
to the script context when loaded, why not providing the same for 
modules.  if it hasn't been set when its encountered then you raise 
the proper unset error.
BrianH
14-Jun-2009
[15578]
Not really. They are (using a hack), but the binding of the code 
block is done after the imports are processed and before the code 
block starts executing. Once the code block starts executing the 
module context has already been defined. REBOL's evaluation and binding 
rules preclude any automatic rebinding.
Maxim
14-Jun-2009
[15579x2]
but the word exists in the module before the script is done.... its 
just not set yet... so it should be bound in the module and the script 
sets the value, since its running in the context of the module.
what you are saying is that for modules, we need to start declaring 
words?  not very rebolish. 


 I have to do so in slim to keep words local to the calling context, 
 but I would have tought that modules would do so automatically since 
 they replace the global context.

 any new word in the root of the spec block of the module should be 
 added to the module's context and set to unset! just like R2's global 
 context does.
BrianH
14-Jun-2009
[15581x3]
Um, no, a DOne script is running in its own context if it is a module, 
or the current context if not. The current context is not the context 
of the calling code - it exists independently.
Modules have their own context, but they don';t replace the "global" 
context.
Any set-word in the top-level of the module's code block is added 
to the module's context before the module code runs, just like an 
object. If you isolate the module, every word in the module's code 
block and all nested blocks, parens and paths are added to the module's 
context. The only words you need to "declare" are the exported words.
Maxim
14-Jun-2009
[15584]
ok that makes sense now.
BrianH
14-Jun-2009
[15585]
The bug#928 should be dismissed, marked as "not a bug", and left 
there for future reference. Thanks for helping document R3 :)
Maxim
14-Jun-2009
[15586x4]
but its revealing something deeper... DO is now totally useless.
cause it can't interact with the context its being called from.
well, in the module's perspective anyways.
(totally is a strong word... hehe)
BrianH
14-Jun-2009
[15590]
Not totally. It is useful in non-module scripts, and useful for scripts 
done for effect rather than for loading functions.
Maxim
14-Jun-2009
[15591]
ok let me do a single little test...
BrianH
14-Jun-2009
[15592]
Also, the IMPORT function is basically a fancy DO.
Maxim
14-Jun-2009
[15593x3]
oops noticed that I mismatched the bug number in the code examples 
of bug#928... I'll edit them.
just like slim's LOAD is a fancy DO   ;-)
that would be slim's 'OPEN... starting to be late... hehe
BrianH
14-Jun-2009
[15596x2]
Of the module bugs you have posted, the one that is still pretty 
nasty is bug#923. Needs tracing :(
Good night, be back tomorrow if I can.
Maxim
14-Jun-2009
[15598x3]
ok... here is a twist on bug 928... :-)

if I add 

myfunc: none 


at the top of the module in the supplied example I get this error 
instead:

Evaluating: /D/dev/project/liquid-r3/debug/mymodule-bug924.r
** Script error: print word is not bound to a context
** Where: catch if either either do begin do
** Near: catch/quit code

>>
this one I can't see how it can be proper, even if you can explain 
it.
note... 'PRINT is not bound to any context  !!! wtf?
BrianH
14-Jun-2009
[15601]
In which of the 3 files do you put the myfunc: none ?
Maxim
14-Jun-2009
[15602x2]
rebol [
	type: 'module
	name: 'mymodule-bug928
]

print "TADAM ... mymodule-bug928"
myfunc: none
do %myscript.r
myfunc 928
print is global it should accessible from any DO.
BrianH
14-Jun-2009
[15604]
Again, I'll be back tomorrow if I can.
Maxim
14-Jun-2009
[15605x3]
sure... better build a convicing argument cause the above is not 
acceptible  ;-)
heheh  good night.
I'm going back to comfortable R2 development now...