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

RFC: new feature for local word handling

 [1/4] from: robert::muench::robertmuench::de at: 31-Dec-2002 11:39


Hi, playing around with the problem to use a block of code that should be executed in an other context but still uses local words I want to propose a new feature. IMO this problem comes up quite often, especially if want to use the dynamics of Rebol for application architecture. Through the very dynamic of Rebol it's mostly unpossible to handle the requirement with own written code. IMO the only place to handle this with all respects to dynamic execution is the interpreter itself. How about this: myblock: [ myvar: 3 print myvar * 3 myvar2: in system myvar myvar2: myvar * 3 ] do/local myblock This would define 'myvar and 'myvar2 to be bound to a local context. 'myvar2 will refer to the global word 'myvar and alter this. So when using this you have to bring in the global words. But this is a lot easier, because most of the time you know which global words are available. What do you think? Robert

 [2/4] from: ammon:addept:ws at: 31-Dec-2002 5:12


Hi, Have you tried just using 'context? There is no rule that states that you have to pass the value from 'context to a word. ;-) Example:
>> myblock: [
[ myvar: 3 [ print myvar * 3 [ ] == [ myvar: 3 print myvar * 3 ]
>> context myblock
9
>> myvar
** Script Error: myvar has no value ** Where: connect-to-link ** Near: myvar myblock is DOne without poluting the global namespace. Albeit there are a few drawbacks like you would probably have to declare any words you want in the global namespace before the execution of the 'context, but all in all it allows you to have something like 'use, but without first declaring variables. You might consider it a lightweight sandbox. ;-) Enjoy!! Ammon Johnson CIO of Addept ---------- (www.addept.ws) 435.616.2322 ---------- (ammon AT addept.ws)

 [3/4] from: g:santilli:tiscalinet:it at: 31-Dec-2002 12:58


Hi Robert, On Tuesday, December 31, 2002, 11:39:17 AM, you wrote: RMM> myblock: [ RMM> myvar: 3 RMM> print myvar * 3 RMM> myvar2: in system myvar RMM> myvar2: myvar * 3 RMM> ] RMM> do/local myblock What would the difference with: context myblock be? (I'm just asking; if CONTEXT is not enough for you, Ladislav has functions to do what you want probably, or I could write one for you.) Regards, Gabriele. -- Gabriele Santilli <[g--santilli--tiscalinet--it]> -- REBOL Programmer Amigan -- AGI L'Aquila -- REB: http://web.tiscali.it/rebol/index.r

 [4/4] from: robert:muench:robertmuench at: 31-Dec-2002 19:09


> -----Original Message----- > From: [rebol-bounce--rebol--com] [mailto:[rebol-bounce--rebol--com]]
<<quoted lines omitted: 7>>
> Ladislav has functions to do what you want probably, or I > could write one for you.)
Hi, I don't know what the difference would be. I have to play around with this a bit more. But at least there is a solution for all this :-)). Robert

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