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

[REBOL] Re: howto_convert?

From: joel:neely:fedex at: 29-Nov-2000 11:03

Hi, Sascha, You've got two problems with this code (maybe three...) [rebol-bounce--rebol--com] wrote:
> Hi, > since i read it' would be all easy in rebol, > i tried obscure: > >> account: make object! [ > [ name: none] > >> a_1: :account > >> a_2: :account > >> a_2/name: "sascha" > == "sascha" > >> a_1/name: "mascha" > == "mascha" > >> foreach obj [acc_1 acc_2][ > [ probe obj/name] > ** Script Error: Cannot use path on word! value. > ** Where: probe obj/name > >>
Problem 1) Your block should have read [a_1 a_2] instead of [acc_1 acc_2] because of what your code defined. Problem 2) Your block needs to be reduced before being used in the loop. The block [a_1 a_2] is just a block containing the two words 'a_1 and 'a_2 until it is reduced (or otherwise evaluated). As you seem to expect to get to the objects referenced by those words, instead of the words themselves, you need to reduce the list. Possible Problem 3) I'm really unclear on why you set both of your words to refer to the same account object. If you really meant to create distinct objects, you need to make new ones for the two words. Taking all the above into account, here's code that behaves the way I infer that you were expecting.
>> account: make object! [name: none] >> a1: make account [] >> a2: make account [] >> a1/name: "sascha"
== "sascha"
>> a2/name: "mascha"
== "mascha"
>> foreach obj reduce [a1 a2] [print obj/name]
sascha mascha Note that you could have initialized the two new(er) objects by a1: make account [name: "sascha"] a2: make account [name: "mascha"] combining object construction and default value replacement into a single phrase for each. Hope this helps! -jn- -- ; Joel Neely [joel--neely--fedex--com] 901-263-4460 38017/HKA/9677 REBOL [] foreach [order string] sort/skip reduce [ true "!" false head reverse "rekcah" none "REBOL " prin "Just " "another " ] 2 [prin string] print ""