mirror of
https://github.com/ChaiScript/ChaiScript.git
synced 2025-12-06 16:57:04 +08:00
Cleaning up namespace documentation
This commit is contained in:
parent
96d2eddce1
commit
9f1ba21c5e
@ -130,16 +130,18 @@ chai.register_namespace(math, "math");
|
|||||||
|
|
||||||
Namespaces are imported to make them available for scripting
|
Namespaces are imported to make them available for scripting
|
||||||
|
|
||||||
|
Importing via C++ (_not generally recommended_)
|
||||||
```
|
```
|
||||||
chai.import("math"); // importing via C++ (_not generally recommended_)
|
chai.import("math");
|
||||||
```
|
```
|
||||||
|
|
||||||
|
Importing via ChaiScript (recommended)
|
||||||
```
|
```
|
||||||
import("math") // importing via ChaiScript (_recommended_)
|
import("math")
|
||||||
print(math.pi) // prints 3.14159
|
print(math.pi) // prints 3.14159
|
||||||
```
|
```
|
||||||
|
|
||||||
### Delayed Namespace Generation
|
#### Delayed Namespace Generation
|
||||||
|
|
||||||
Passing a lambda function that returns a namespace will delay the namespace generation until `import` is called.
|
Passing a lambda function that returns a namespace will delay the namespace generation until `import` is called.
|
||||||
This saves memory and computing costs if a namespace is not imported into every ChaiScript instance.
|
This saves memory and computing costs if a namespace is not imported into every ChaiScript instance.
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user