Referencing the lib and sys
Ok, here's a quick tutorial on how to directly reference the runtime lib and sys from programs. (From R3 A108 and later.) Of course, normally you don't need to do this because your scripts bind to these functions as part of the load process. However, there are times when when a lib word is overriden by a local or refinement. For instance, that happens with any and all from time to time. To reference the function all directly, you would write: lib/all [thing1 thing2 thing3] Pretty easy. (That's why the default name is lib - it's short.) Of course, if you've got that in a loop that's going to repeat a million times, the optimal method to avoid the lib lookup time is: all': :lib/all loop 1'000'000 [... all' [thing1 thing2] ...] The use of ' is just a convention, and you can use whatever you want instead. Think of it as "all prime." To reference the special functions of the sys context, first think about whether you really should be doing it at all. The sys context is "private" (non-exported) for a reason. The system object is the official place for accessible system values, not the sys context. Ok, if you've decided it's worth the condemnation, then you would simply write something like: print sys/boot-banner This line is referring to the initial REBOL banner that prints on boot. PS: Note that some sys functions are purged after boot, like load-boot-extensions and start. Keeps "really nasty" problems from happening.
|
Updated 12-Mar-2024 - Copyright Carl Sassenrath - WWW.REBOL.COM - Edit - Blogger Source Code |