Method code for $root.add_var()

[Turn on line numbering]
arg name, @args;
var tmp, kid;

(> .perms(sender()) <);
(> $sys.touch() <);
if (!tostr(name).valid_ident())
    throw(~invident, name + " is not a valid ident.");
(> add_var(name) <);
if ('core in .flags())
    $changelog.log("ADD-VAR: " + this() + "," + name + " by " + sender());

// The following code is a kludge as we can't send a default value  
// to the primitive.   
if (args) {
    tmp = tosym("__set_" + tostr(name) + "_" + time());
    catch any {
        add_method([tostr(name) + " = " + toliteral(args[1]) + ";"], tmp);
        .(tmp)();
        if (args.length() > 1 && args[2] == 'inherit) {
            for kid in (.descendants())
                kid.(tmp)();
        }
        del_method(tmp);
    } with {
        del_method(tmp);
        rethrow(error());
    }
}

["// Created as a part of ColdCore, see: @help Credit"]

the Cold Dark