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

Stupid question: Locals ??

 [1/4] from: robert:muench:robertmuench at: 17-Dec-2002 17:41


Hi, I somehow seem to be a bit blind in one eye. I have the following code: paragraph: has [name pvalue toemit][ toemit: make block! ['textbox ""] ; value now has a name/value structure itself foreach tmp value [ name: tmp/1 pvalue: tmp/2 switch/default name [ parapart [append last toemit pvalue] ][print ["Unknown INLINE-TAG found:" name]] ] emit toemit ] The strange thing is that 'toemit keeps its value between calls to paragraph. Why this? It's declared as local and I create a new block each time. Robert

 [2/4] from: lmecir::mbox::vol::cz at: 17-Dec-2002 18:33


Hi Robert, ----- Original Message ----- From: "Robert M. Muench"
> I have the following > code: > > paragraph: has [name pvalue toemit][ > toemit: make block! ['textbox ""]
don't you want to have: toemit: compose ['textbox (copy "")] instead? -L

 [3/4] from: greggirwin:mindspring at: 17-Dec-2002 11:26


Hi Robert, RMM> paragraph: has [name pvalue toemit][ RMM> toemit: make block! ['textbox ""] RMM> ; value now has a name/value structure itself RMM> foreach tmp value [ RMM> name: tmp/1 RMM> pvalue: tmp/2 RMM> switch/default name [ RMM> parapart [append last toemit pvalue] RMM> ][print ["Unknown INLINE-TAG found:" name]] RMM> ] RMM> emit toemit RMM> ] RMM> The strange thing is that 'toemit keeps its value between calls to RMM> paragraph. Why this? It's declared as local and I create a new block RMM> each time. Robert Are you sure toemit is keeping its value? Using make block! should work, but you're doing an APPEND LAST, so you're adding to the last element of toemit, which is "" initially, not copied, so I think that's what is keeping its value. -- Gregg

 [4/4] from: robert:muench:robertmuench at: 18-Dec-2002 10:06


> -----Original Message----- > From: [rebol-bounce--rebol--com] [mailto:[rebol-bounce--rebol--com]]
<<quoted lines omitted: 7>>
> toemit: compose ['textbox (copy "")] > instead?
Hi, yep I think that's it. Looks like I never will get this into my head ;-)). IMO it's very strange to have a copy/make that only works on the outer level. I would make this default and add a refinement for just-copy-outer-level ... But maybe I'm the only one thinking different. Robert

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