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

[REBOL] Re: Destroy no more useful functions

From: sunandadh:aol at: 16-Apr-2002 17:38

> In a program, i then write > do %funcsrc.r > .... calling funcs > When my program ends, i want to destroy all the funcs included by
> But writing unset 'func1, unset 'func2 ... is a bit boring and much unsure. > Has anybody an idea ?
I put all the functions in a source module into an object: funcsrc.r contains: funcsrc: make object! [ func1: func [] [] func2: func [] [] ] ; object This has three main advantages: 3. You are less likely to create a name clash with a Rebol function, or another module you have included, because your names have two parts. So you could have the functions: funcsrc/print funcscr/return etc without clashing with the "global" 'print or 'return functions 2. Similarly, you can have "module-local" variables: accessible to any function in the object, but not clashing in name with any variable declared elsewhere: funcsrc: make object! [ var1: 666 func1: func [] [print var1] ;; prints funcsrc/var1 func2: func [] [print var1] ;; ditto ] ; object 1. Finally, you can trash the object, and all its functions and variables in one go: unset 'funcsrc You decide if that's funky or boring, Sunanda.