-
Notifications
You must be signed in to change notification settings - Fork 126
Module (namespace)
Wang Renxin edited this page Nov 25, 2015
·
11 revisions
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 to different modules (refers to "namespace" in some other programming languages).
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"
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. after import "@naming"
, it's able to use foo()
for short.
- Principles
- Coding
- Data types
- Standalone shell
- Integration
- Customization
- More scripting API
- FAQ