clone method
return a deep copy of this struct.
Implementation
HTStruct clone({bool withInternals = false}) {
final cloned =
HTStruct(interpreter, prototype: prototype, closure: closure);
for (final key in _fields.keys) {
if (!withInternals &&
key.startsWith(interpreter.lexicon.internalPrefix)) {
continue;
}
final value = _fields[key];
final copiedValue = interpreter.toStructValue(value);
cloned.define(key, copiedValue);
}
return cloned;
}