So far, nested namespaces are the only feature I'm missing in ChaiScript (previously suggested as an improvement here: #113 (comment)).
I wasn't yet able to find any "nice" way to substitute for this.
As an example:
I've been playing around with ChaiScript in some scientific code and one place where nested namespaces would be quite useful was providing certain constants in multiple sets of units, where it seems a bit unclean to define multiple namespaces such as
// Standard international units
script.register_namespace(
[&]( chaiscript::Namespace & ns ) {
ns["mu_B"] = chaiscript::const_var( mu_B ); // Bohr magneton [meV/T]
// ...
},
"constants_si" );
// Micromagnetic units
script.register_namespace(
[&]( chaiscript::Namespace & ns ) {
ns["mu_B"] = chaiscript::const_var( mu_B ); // Bohr magneton [mRy/T]
// ...
},
"constants_mm" );
Not sure what would be the best API for nesting namespaces, but maybe adding a register_namespace to the Namespace class or overloading the corresponding operator= to accept Namespaces would work?
So far, nested namespaces are the only feature I'm missing in ChaiScript (previously suggested as an improvement here: #113 (comment)).
I wasn't yet able to find any "nice" way to substitute for this.
As an example:
I've been playing around with ChaiScript in some scientific code and one place where nested namespaces would be quite useful was providing certain constants in multiple sets of units, where it seems a bit unclean to define multiple namespaces such as
Not sure what would be the best API for nesting namespaces, but maybe adding a
register_namespaceto theNamespaceclass or overloading the correspondingoperator=to acceptNamespaces would work?