-
Notifications
You must be signed in to change notification settings - Fork 126
Module (namespace)
Users may add more and more scripting interfaces to MY-BASIC, it will soon cause a naming pollution issue. It's able to separate scripting interfaces into different modules (refers to "namespace" in some other programming languages). Please consider using it in your mind 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 in that module; use mb_end_module
to end the current module. See the sample below:
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 able to write naming.foo()
to call the interface.
Use IMPORT @xxx
to import a module, and all symbols in that module could be used without the module prefix. Eg. using foo()
for short after import "@naming"
.
Note this feature is only available with plain registered functions for the moment.
Read the Importing another file page to get information about how import another plain 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