define method

bool define(
  1. String varName,
  2. dynamic value, {
  3. bool isMutable = false,
  4. bool override = false,
  5. bool throws = true,
  6. String? moduleName,
})

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);
  }
}