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

[REBOL] Re: object funnies

From: g:santilli:tiscalinet:it at: 20-Oct-2001 15:02

Hello Ingo! On 20-Ott-01, you wrote: IH> (Having said that, I really like default to local, and I've IH> once sent a proposal to feedback about a "reversed-logic" IH> func: IH> f: func[a /global g][ ... ] use [apply] [ ; apply a function recursively apply: func [block [any-block!] code [function!]] [ foreach value :block [ either any-block? :value [ apply :value :code ] [ code :value ] ] ] ; you might find this useful, too... recurse: func ['word [word!] block [block!] code [block!]] [ code: func reduce [word] code apply block :code ] my-func: func [spec [block!] code [block!] /local globals locals] [ either globals: find spec /global [ spec: copy/part spec globals globals: copy next globals ] [ globals: [] ] locals: make block! length? code recurse value code [ if any-word? :value [ append locals to-word :value ] ] foreach value spec [ if any-word? :value [ append globals to-word :value ] ] locals: exclude locals globals insert insert tail spec /local locals func spec code ] ]
>> f: my-func [a b /global + print set] [ [ c: a + b
[ print [a b c] [ set [e f g] [5 6 7] [ print [e f g] [ ]
>> source f
f: func [a b /local c e f g][ c: a + b print [a b c] set [e f g] [5 6 7] print [e f g] ]
>> f 3 4
3 4 7 5 6 7 IH> But AFAIK it is not possible to add words to a context once IH> it's created, so we just _can't_ catch every word in the IH> local context, yet ... Really? :-) Anyway, I don't like it this way. I find it more difficult to remember to enumarate the global words... (I hate PHP for this...) Regards, Gabriele. -- Gabriele Santilli <[giesse--writeme--com]> - Amigan - REBOL programmer Amiga Group Italia sez. L'Aquila -- http://www.amyresource.it/AGI/