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

[REBOL] Adding functions to an object.

From: arolls:idatam:au at: 27-Feb-2002 0:20

This is a question only for people who have finished their bindology degrees. I have made an include function, for the purpose of "including" functions from other scripts in another script. It works great, except I want it to determine which context it is in and insert the new functions there. eg. ---------------------- ; library.r context [ func-one: func [... definition... func-two: func [... definition... ] ----------------------- ; Main Code ; this sets func-one and func-two in the global context ; to the same-named functions in the context returned ; by DOing %library.r include [%library.r [func-one func-two]] ; (this works) ; now, same again except I want the functions to be ; added to the object. o: make object! [ blah: none include [%library.r [func-one func-two]] ] ; so I should now be able to access the functions in o, o/func-one o/func-two ---------------------- I am trying to pass in the dummy word 'blah to the include function, so bind can use it as the known word. But.... <drum roll...> I am having trouble. :) I have been referring to Ladislav's "Words... Contexts" document but I am making slow progress. I am using Ladislav's in-object? function to determine the object from 'blah, but how to add the functions to it? Can anyone show an example of how to do this? I thought of using make, with the object as a template, but that makes a new object. I want to modify the existing object in place. Is that possible? Also, is it necessary to pass a known-word in to my include function? Perhaps there is a way to determine if include was called from within a context by checking if 'self is defined somehow? (I tried this but that's certainly not proof it can't be done.) Anyone have any ideas? If I can get it to work like this I'll be real happy! Regards to all, Anton.