Method code for $root.add_method()

[Turn on line numbering]
arg code, name, @evalonly;
var l, m, line, errs;

(> .perms(sender()) <);
if (evalonly && caller() in [$root, $sys, $programmer])
    (> $sys.touch('lockok) <);
else
    (> $sys.touch() <);

// check for a few things only admins can do
if (!sender().is($admin)) {
    for l in [1 .. listlen(code)] {
        line = code[l];
        if ((m = line.match_regexp("[^a-z0-9_.]anticipate_assignment\("))) {
            (> sender().tell($code_lib.point_to_line("ERROR: call to anticipate_assignment()", m[1][1] + 2, m[1][2] - 2, l, line)) <);
            throw(~perm, "anticipate_assignment() may only be used by an administrator.");
        }
    }
}
errs = (> add_method(code, name) <);
if ('core in .flags())
    $changelog.log("ADD-METHOD: " + this() + "." + name + " by " + sender());
for l in [1 .. listlen(errs)] {
    line = errs[l];
    if (match_regexp(line, "Line [0-9]+: Unknown function length.")) {
        line = substr(line, 1, strlen(line) - 1);
        errs = replace(errs, l, line + "(), try listlen(), strlen() or buflen()");
    }
}
return errs;

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

the Cold Dark