-
Notifications
You must be signed in to change notification settings - Fork 118
Module (namespace)
Users may add more and more BASIC functions to MY-BASIC, it will soon cause a naming pollution issue. It's possible to separate BASIC functions into different modules (aka. "namespace" in some other programming languages). Consider using it if you plan to expose a number of functions.
Use mb_begin_module
to begin a module with a module name, all functions registered after a module began will be put under that module; use mb_end_module
to end the current module. For example:
mb_begin_module(s, "NAMING");
mb_register_func(s, "FOO", _foo); /* Register "foo" in module "naming" */
/* Register other functions */
mb_end_module(s);
After that it's possible to write naming.foo()
to call the function.
Use IMPORT @xxx
to import a module, and all symbols in that module could be used without the module prefix. For example using foo()
for short after import "@naming"
.
Note this feature is only available with registered C functions for the moment.
Read the Importing another file page to get information about how to import another source code file.
Read the Customizing an importer page to get information about how to customize an importer.
- Principles
- Coding
- Data types
- Standalone shell
- Integration
- Customization
- More scripting API
- FAQ