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

Source code modules.

 [1/12] from: bga:bug-br at: 31-Mar-2004 10:47


Hello. So, I am working on one project where I will need a way to create modules of Rebol code that will be loaded by a main script. How would I go about loading those modules from disk in a way that would be easy to access that code in the main script? This is what would happen: 1 - Scan a dir for modules. I will probably be looking for files with specific extensions here. 2 - Load a specific module. Here is the trick part. What I was thinking is that each module would have a function that I would call inside it to do whatever is needed. As I intend to download all modules at once when the main script starts, the functions on each module would have to have different names. How to keep track of those names? Also, how to load the modules? "do %modulefile" is the best way? 3 - Access module functions. Any ideas? -Bruno

 [2/12] from: mauro:fontana:speedautomazione:it at: 31-Mar-2004 16:50


On Wed, 31 Mar 2004 10:47:41 -0300 (BRT), Bruno G. Albuquerque <[bga--bug-br--org--br]> wrote:
> Hello. > So, I am working on one project where I will need a way to create
<<quoted lines omitted: 13>>
> 3 - Access module functions. > Any ideas?
Why not a standard API for all the modules? M&F

 [3/12] from: maximo:meteorstudios at: 31-Mar-2004 10:08


slim your code! www.rebol.it/~steel/libraries/ -MAx --- You can either be part of the problem or part of the solution, but in the end, being part of the problem is much more fun.

 [4/12] from: greggirwin:mindspring at: 31-Mar-2004 9:30


Hi Bruno, BGA> So, I am working on one project where I will need a way to create BGA> "modules" of Rebol code that will be loaded by a main script. How would I BGA> go about loading those modules from disk in a way that would be easy to BGA> access that code in the main script? If you have the flexibility to experiment, please do give Max's SLIM library concept a try. I'd like to see more people play with it and post some feedback to the list. It's not hard to write a "loader" that brings all your modules in and binds them to a context (I called mine 'lib), and if each module keeps everything in *its* own context, you end up with an nice hierarchical library structure. I can post mine if you want. Other people (e.g. Ladislav) have nice INCLUDE functions, and of course there's PREBOL from RT. -- Gregg

 [5/12] from: bga:bug-br at: 31-Mar-2004 14:27


Hey Gregg. Please do. Unfortunatelly what I need is a lot simpler than what STELL provides so there is no point in using it (although STEEL looks really cool). I guess the real problem I have is that I don't know how to "include" the code that is in a module file in a way it would be bound to a context. For instance, I would like to create a file that would have the following function defind on it: test: func [ ] [ print "Hello" ] And I would like to load it inside a context so I could do something like: test-context: context [ ; The test function should be here somehow ] And then, be able to do: test-context/test And get the desired results. Thanks. -Bruno Gregg Irwin disse:

 [6/12] from: bga:bug-br at: 31-Mar-2004 14:28


Hello Maxim. It looks amazing ad I will eentually take a deeper look into it. Right now, it appears to provide way more than what I need so I will just try to figure out another way to do it (and I will learn in the process which is good). Thanks. -Bruno Maxim Olivier-Adlhoch disse:

 [7/12] from: maximo::meteorstudios::com at: 31-Mar-2004 12:42


but that is slim's PRIMARY function. ;-) another way to do a simple loaded namespace is like so: mod: load/all mod: context mod and you have yourself a block of code within an object. note this is untested, but should work IIRC. -MAx --- You can either be part of the problem or part of the solution, but in the end, being part of the problem is much more fun.

 [8/12] from: rotenca:telvia:it at: 31-Mar-2004 19:50


Hi,
> I guess the real problem I have is that I don't know how to "include" the > code that is in a module file in a way it would be bound to a context. For
<<quoted lines omitted: 4>>
> ] >> read %test.r
== "test: func [a ] []"
>> probe ob: context load %test.r
make object! [ test: func [a][] ] --- Ciao Romano

 [9/12] from: bga:bug-br at: 31-Mar-2004 14:55


That's *EXACTLY* what I wanted. Thank you! -Bruno Maxim Olivier-Adlhoch disse:

 [10/12] from: ptretter:charter at: 31-Mar-2004 19:16


I actually use RT's #include function which is very handy but I usually have most of my library files containing /library functions based on a particular category of winapi functions. For example, I have a whole bunch of winapi functions for handling windows and handles to windows etc.. Then I have a library called process.r which handles process functions so that I can easy reference the functions within them. Everyone will do what that wish but I do find it easier to include them in separate files and then just reuse then when you need a set of functions. Paul Tretter

 [11/12] from: ptretter:charter at: 31-Mar-2004 19:16


I actually use RT's #include function which is very handy but I usually have most of my library files containing /library functions based on a particular category of winapi functions. For example, I have a whole bunch of winapi functions for handling windows and handles to windows etc.. Then I have a library called process.r which handles process functions so that I can easy reference the functions within them. Everyone will do what that wish but I do find it easier to include them in separate files and then just reuse then when you need a set of functions. Paul Tretter

 [12/12] from: robert:muench:robertmuench at: 1-Apr-2004 9:26


On Wed, 31 Mar 2004 14:27:07 -0300 (BRT), Bruno G. Albuquerque <[bga--bug-br--org--br]> wrote:
> Please do. Unfortunatelly what I need is a lot simpler than what STELL > provides so there is no point in using it (although STEEL looks really > cool).
Hi, it's the slim part of what Max calls STEEL. Believe me it's worth the effort of couple of minutes, because using it is a no-brainer and you never have to spend a second of your live to handle this case. All this name-clashing, binding etc. will make some problems if your project gets bigger. Robert

Notes
  • Quoted lines have been omitted from some messages.
    View the message alone to see the lines that have been omitted