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

Object -> Word?

 [1/4] from: kpeters:otaksoft at: 19-Dec-2007 19:08


>> o1: make object! [] >> o2: make object! [] >> >> probe type? o2
object! == object!
>> >> s: [ o1 o2 ]
== [o1 o2]
>> >> probe type? s/1
word! == word! Hmm - why the type change here from object to word? More importantly, how do I overcome this? I need to iterate over all the objects in a block and operate on them as objects - not words... TIA Kai

 [2/4] from: tomc:cs:uoregon at: 19-Dec-2007 19:25


Kai Peters wrote:
>>> o1: make object! [] >>> o2: make object! []
<<quoted lines omitted: 13>>
> TIA > Kai
probe type? do s/1 there may be safer ways ... I will rummage about -- ... nice weather eh tomc-cs.uoregon.edu

 [3/4] from: chris-ross::gill::com at: 19-Dec-2007 23:14


On Dec 19, 2007 9:08 PM, Kai Peters <kpeters-otaksoft.com> wrote:
>> o1: make object! [] >> o2: make object! [] >> >> probe type? o2
object! == object!
>> >> s: [ o1 o2 ]
== [o1 o2]
>> >> probe type? s/1
word! == word!
> Hmm - why the type change here from object to word? > > More importantly, how do I overcome this? > > I need to iterate over all the objects in a block and operate > on them as objects - not words...
No type change here. [o1 o2] is just a block of words. In a block, they are just words, though they are bound to the context they are generated in. The two main options you have are:
>> foreach obj reduce s [probe obj] >> foreach word s [probe get/any :word]
Note: you don't need to use a get-word! in the second example - in some cases, the intent is clearer. - Chris

 [4/4] from: GedB::Rushcoding::co::uk at: 20-Dec-2007 12:17


You have to draw the distinguish between the object o1 and the word 'o1 which is a label identifying the object. You just need to reduce the series to translate the words into the objects they reference. You can think of square brackets ([])as being rather like quotation marks (""). Within quotation marks you get a string of characters. Within square brackets you get a series of words. Both have to be evaluated.
>> o1: make object! [] >> o2: make object! [] >> probe type? o2
object! == object!
>> s: [o1 o2]
== [o1 o2]
>> probe type? s/1
word! == word!
>> probe s/1
o1 == o1
>> probe (s/1 = 'o1)
true == true
>> s: reduce [o1 o2]
== [make object! [ ] make object! [ ]]
>> probe s/1
make object! [ ]
>> probe (s/1 = o1)
true == true DESCRIPTION: Evaluates an expression or block expressions and returns the result. REDUCE is a native value. On Dec 20, 2007 3:08 AM, Kai Peters <kpeters-otaksoft.com> wrote:

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