[REBOL] Re: ANN: I'm back! - include/export
From: arolls::idatam::com::au at: 26-Nov-2001 15:08
This is a call to you advanced bindologists out there.
I wanted to make an "export" function (like include)
for the following system:
- A user creates a script file with
lots of useful functions. For instance,
my dir-utils.r contains ls, mv, tree, compare etc.
- I would like to wrap up all those functions in a
protective context and only define and expose to
the calling context particular functions, specified
in the "export" call.
- In addition, if those functions depend on other
functions in the script, they should be defined
inside the context (but not exposed).
- The export function itself should reside in its
own script file. Function dependencies should be
specified (or inferred) in the script file to be
exported from.
I know how to use set to define words in the global
context, but does that work from any context?
ie. can I define an object that can export, say, 'ls
from the dir-utils context? Then its internal functions
can use ls, but the global context doesn't know about it.
Some examples of what I would like to write:
1)
export %dir-utils.r [ls mv tree compare]
; now I can use those four functions, eg.
ls/info *.r ; list script files...
2)
o: context [
init: does [export %dir-utils.r [ls mv]]
list: does [ls]
]
o/init
o/list ; and a directory listing should ensue...
Has anyone done something like that?
Anton.