define method
Add a declaration to certain namespace.
if the value is not a declaration, will create one with isMutable
value.
if not, the isMutable
will be ignored.
Implementation
bool define(
String varName,
dynamic value, {
bool isMutable = false,
bool override = false,
bool throws = true,
String? moduleName,
}) {
final nsp = getNamespace(moduleName: moduleName);
if (value is HTDeclaration) {
return nsp.define(varName, value, override: override, throws: throws);
} else {
final decl = HTVariable(id: varName, value: value, isMutable: isMutable);
return nsp.define(varName, decl, override: override, throws: throws);
}
}