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

[REBOL] Re: Hack

From: sunandadh:aol at: 28-Dec-2001 17:11

Hi Romano,
> I've read the Sunanda msg on escribe: you are right, hackf doesn't work in > your example. > > But the reason is not that it is defined in a object, but that it is called > with a path. Seems that where uses exactly the word of the path refinement > which is normally a global word. > > Look at these examples (which use the old version of hack): <snip> > do in hacko 'hackf > hacko/hackf > do bind [hacko/hackf] in hacko 'self > > Only the third time the hack fails.
I think you mean the 2nd fails, the first and last work. Unfortunately the 2nd is (in my work at least) just about the only way I ever write function calls to functions in objects. --- On a related subject, I'd like a way to get the name of an object. Example: MyObject: make object! [a: 0 b: 0 c: 0] MyFunc MyObject ... MyFunc: func [obj [Object!]][ if error? [obj/a] [ Print [?? "is missing its 'a' variable"] ] ; if ] ;func where we replace the "??" with the magic hack to dereference obj into MyObject . Now I know I could sort of do it like this: MyObject: make object! [a: 0 b: 0 c: 0] MyFunc "MyObject" ... MyFunc: func [obj-String [String!] /local obj][ obj: get to-word obj-string if error? try [obj/a] [ Print [Obj-string "is missing its 'a' variable"] ] ; if ] ;func But that feels like a workaround to me, and for precise functional equivalence, I need to add in the check that Obj is an object. Any ideas? Sunanda.