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

[REBOL] Re: REBOL Enhancement Proposals (REPs)

From: rotenca:telvia:it at: 26-Sep-2001 18:32

Hi, Ammon, Joel (and so on),
> The quick reason that I can see is this: > > z: [1 2] > y: [a/b/c d/e] > > set y z
At the end you will find my func 'set-all to make this kind of things. Waiting for bug/enhancement report... Writing it, I have found a little strange behaviour of standard set:
>> set [a:] 2
** Script Error: Invalid argument: a ** Where: do-boot ** Near: set [a:] 2 But:
>> set first [a:] 2
== 2 Here it is my function which should replace set in many (not all, /any is not present) situations: --- Ciao Romano ----------------- code ---------- Rebol[ Title: "set-all" Date: 26/09/01 Author: "Romano Paolo Tenca" Note: {not /any refinement} ] set-all: func [[catch] word [any-word! any-block!] value /local ret val] [ if any-word? :word [return set :word :value] if any[set-path? :word path? :word] [word: head insert/only copy [] first reduce [:word]] ret: make block! lenght? :word sin: func [x v][ reduce [either any-word? :x [to-set-word :x] [to-set-path :x] 'first reduce [:v]] ] throw-on-error [ while [not tail? word] [ x: first word either any-block? :value [ either tail? value [sin :x none][ val: first value value: next value ] append ret sin :x :val ][ either all [tail? next word] [ return do sin :x :value ][ do sin :x :value ] ] word: next :word ] reduce ret ] ] ;test aface: context[ font: context [color: 0 size: 150]] probe set-all [aface/font/color: aface/font/size a] [200.0.0 12 "string"] ?? aface probe set-all [b: 'c :d] [200.0.0 12 "string1"] probe set-all ['aface/font/color 'c :d] "string2" x: [aface/font/color: 'aface/font/size a] y: [100.0.0 5 "string3"] probe set-all x y ?? aface a: 1 set-all [a:] 2 ?? a set-all first [a:] 3 ?? a set-all first [a:] :do ?? a set-all first [a:] [:do] ?? a halt