[REBOL] Re: Namespaces for functions/some tips
From: tim::johnsons-web::com at: 28-Aug-2001 11:36
Hi Gregg:
DISCLAIMER: I am not an advanced rebol programmer.
If any "real" rebol find errors or omissions in the
following, then it's to my benefit :>)
Having said that: I'll share some of my approaches and
caveats:
1)Build a block of system words
NOTE: some will come from your user.r
>>all-rebol-words: first system/words
; now you have them in a block and you can print them,
; store them, whatever
2)Any time that you compose a word, check to see that it
isn't a system word. I also highly recommend using the
rebol function dictionary.
3)"Overloading": Let's say you're setting up an object
with a method called "print". If you use 'print with
the "print" method, the result will likely be a stack
overflow resulting from recusion. You can "overload"
this by using 'system/words/print.
4)Refinements: See above. And. If using refinements within
an object. You can compose a block of the words in the object
with something like this: Interpreter session follows:
>> do %cgilib.r ; load the object into memory
>> cgi-words: first cgio ;build a block of object words
; now you've got a list of words that you can refer to
by something like this: >> find cgi-words 'path-parts
or just >> find first cgio 'path-parts
Example: I've got object function member call 'hidden.
In another function of the same object, I have a refinement
called 'hidden. I use self/hidden to avoid the collision.
OR I might want to chose a different strategy. We're getting
a bit dicey here.
5)System words can be redefined like: sys-print: :print
SCRIPT LIBRARY:
http://www.rebol.org/script/index.html; System Object Browser
http://www.reboltech.com/library/html/nonlocal.html
HTH
Tim
On Tue, Aug 28, 2001 at 10:36:02AM -0600, Gregg Irwin wrote:
> Hi All,
>
> What is the recommended approach for avoiding naming clashes in REBOL? I
> haven't gotten to the point of understanding contexts and binding to know if
> this is the mechanism I would need to use, or how best to organize a larger
> project with multiple scripts that may have function name collisions.
>
> Thanks in advance,
>
> --Gregg
>
> --
> To unsubscribe from this list, please send an email to
> [rebol-request--rebol--com] with "unsubscribe" in the
> subject, without the quotes.
--
Tim Johnson <[tim--johnsons-web--com]>
http://www.johnsons-web.com