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

[REBOL] Re: ANN: I'm back! - include/export

From: lmecir:mbox:vol:cz at: 26-Nov-2001 23:04

Hi Anton, Jeff and I have made some attempts to cover this area (the oldest attempt was in 1999 using Rebol 1.x, which didn't even use Bind, because the function wasn't there back then). Under some circumstances our results were acceptable, but generally, the most satisfactory code should use modules, which aren't present in Rebol yet. Nevertheless, I can have a look at my old code and try to modernize it, if you are interested. <<Anton>> 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.