Mailing List Archive: 49091 messages
  • Home
  • Script library
  • AltME Archive
  • Mailing list
  • Articles Index
  • Site search
 

load, contexts and binding

 [1/5] from: robert::muench::robertmuench::de at: 17-Sep-2001 19:29


Hi, I'm just a bit confused, maybe someone can help me: USAGE: LOAD source /header /next /library /markup /all DESCRIPTION: Loads a file, URL, or string. Binds words to global context. LOAD is a native value. ARGUMENTS: source -- (Type: file url string any-block binary) REFINEMENTS: /header -- Includes REBOL header object if present. /next -- Load the next value only. Return block with value and new position. /library -- Force file to be a dynamic library. (Command version) /markup -- Convert HTML and XML to a block of tags and strings. /all -- Load all values. Does not evaluate REBOL header. This says that the words are bind to the global context. I have a variable 'bla with value "bla is ok!" at the global context. The file I load has just one line: bla: "bla is great!" and somewhere in my script (not at the global level) I have: load myfile But after this 'bla is still "bla is ok!" and not "bla is great!". Why this? I expected load to bind 'bla to global context and therefor change the old definition. Robert

 [2/5] from: rotenca:telvia:it at: 17-Sep-2001 20:30


Hi, Robert
> bla: "bla is great!" > > and somewhere in my script (not at the global level) I have: > > load myfile > > But after this 'bla is still "bla is ok!" and not "bla is great!". Why this?
I
> expected load to bind 'bla to global context and therefor change the old > definition.
It is the opposite: after Load, the word "bla" in the loaded code will be bla is great! . If you put a "print bla" at the start of loaded code you'll see it. When you execute the loaded program, the loaded code will change the global "bla". So you must do the loaded code to see what you want.
> Robert
--- Ciao Romano

 [3/5] from: robert:muench:robertmuench at: 18-Sep-2001 11:11


> -----Original Message----- > From: [rebol-bounce--rebol--com] [mailto:[rebol-bounce--rebol--com]]On Behalf Of
<<quoted lines omitted: 4>>
> It is the opposite: after Load, the word "bla" in the loaded code will be > "bla is great!".
Hi, hm... strange. Does this make sense? Why should I than load words from an external file? IMO it would make sense to be able to load words from files and overwrite the ones already defined in the running script.
> When you execute the loaded program, the loaded code will change the global
bla . I tried this too. But with the following: do load ... So 'load already redifined the new words... The problem with do is, that it expects a Rebol header, there is no refinement like do/plain ... Anyway I'm checking it further. Robert

 [4/5] from: ryanc:iesco-dms at: 18-Sep-2001 9:17


Robert M. Muench wrote:
> > -----Original Message----- > > From: [rebol-bounce--rebol--com] [mailto:[rebol-bounce--rebol--com]]On Behalf Of
<<quoted lines omitted: 7>>
> external file? IMO it would make sense to be able to load words from files and > overwrite the ones already defined in the running script.
This is standard operating procedure when loading a dialect, or just code you dont want evaluated yet. If you want the code evaluated, use 'do, if you dont use 'load.
> > > When you execute the loaded program, the loaded code will change the global > "bla". > > I tried this too. But with the following: > > do load ... > > So 'load already redifined the new words... The problem with do is, that it > expects a Rebol header, there is no refinement like do/plain ...
This is because when you 'do a file, your really doing ('do'ing?) a string. REBOL code is normally not evaluated in a string until the REBOL header is found. I suppose /plain refinement would be nice in certain instances, but 'do 'load really isn't so bad. Check out 'save/header. It tackles the problem from the right end by adding a header to code you might want to leave around for later. Have fun, --Ryan

 [5/5] from: ryanc:iesco-dms at: 18-Sep-2001 10:54


Ooops! Correction:
> This is because when you 'do a file, your really doing ('do'ing?) a string. REBOL > code is normally not evaluated in a string until the REBOL header is found. I
My mistake! I just realized strings arent treated the same as files. hmm... gee, and I thought I knew /core. 'Do of all commands too, I am so ashamed! Hehe, anyways now I have something to ask Carl about at Rebstock. So I guess we can say that 'do only requires a header with a file or url argument. Hmm... Seems wierd to me, but this does mean that 'do 'read will work also. --Ryan

Notes
  • Quoted lines have been omitted from some messages.
    View the message alone to see the lines that have been omitted