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

[REBOL] Re: How do I get name of current object?

From: joel::neely::fedex::com at: 22-Feb-2003 11:37

Hi, Ed, Ed Dana wrote:
> If I create an object called "Conscious", how do I get it to > know its name? >
Objects don't have names. Words do. One could define an object which attempts to find any global words that reference itself, as in: narcissus: make object! [ whoami: func [/local result] [ result: copy [] foreach item first system/words [ error? try [ if self = get to-word item [ insert tail result to-word item ] ] ] result ] ] after which
>> narcissus/whoami
== [narcissus] Of course, the answer isn't necessarily unique!
>> glorp: blodge: spadge: narcissus >> spadge/whoami
== [blodge glorp narcissus spadge] And there doesn't even necessarily exist an answer to that particular question!
>> geefle: make object! [
[ gubbidge: make narcissus [] [ speak: func [] [gubbidge/whoami] [ ]
>> geefle/speak
== []
>> geefle/gubbidge/whoami
== []
>> wugga: reduce [
[ make narcissus [] [ make narcissus [] [ make narcissus [] [ ] == [ make object! [ whoami: func [/local result][ result: copy [] foreach item first system/wo...
>> wugga/1/whoami
== [] However, this isn't answering your original question, but changing it into another question that may have zero, one, or more answers. AFAICT, REBOL objects don't have names, any more than strings or integers do. -jn-