undefmacro
This commit is contained in:
@@ -339,8 +339,6 @@ class Macros {
|
||||
macros["defmacro"] = (wholeExp:ReaderExp, exps:Array<ReaderExp>, k:KissState) -> {
|
||||
wholeExp.checkNumArgs(3, null, '(defmacro [name] [[args...]] [body...])');
|
||||
|
||||
var table = k.macros;
|
||||
|
||||
var name = switch (exps[0].def) {
|
||||
case Symbol(name): name;
|
||||
default: throw CompileError.fromExp(exps[0], "macro name should be a symbol");
|
||||
@@ -439,6 +437,18 @@ class Macros {
|
||||
null;
|
||||
};
|
||||
|
||||
macros["undefmacro"] = (wholeExp:ReaderExp, exps:Array<ReaderExp>, k:KissState) -> {
|
||||
wholeExp.checkNumArgs(1, 1, '(undefmacro [name])');
|
||||
|
||||
var name = switch (exps[0].def) {
|
||||
case Symbol(name): name;
|
||||
default: throw CompileError.fromExp(exps[0], "macro name should be a symbol");
|
||||
};
|
||||
|
||||
k.macros.remove(name);
|
||||
null;
|
||||
};
|
||||
|
||||
macros["defreadermacro"] = (wholeExp:ReaderExp, exps:Array<ReaderExp>, k:KissState) -> {
|
||||
wholeExp.checkNumArgs(3, null, '(defreadermacro [optional &start] ["[startingString]" or [startingStrings...]] [[streamArgName]] [body...])');
|
||||
|
||||
|
@@ -28,4 +28,8 @@ class MacroTestCase extends Test {
|
||||
Assert.equals(9, print);
|
||||
Assert.equals(9, aliasValue());
|
||||
}
|
||||
|
||||
function testUndefMacro() {
|
||||
Assert.equals(11, andValue());
|
||||
}
|
||||
}
|
||||
|
@@ -43,4 +43,9 @@
|
||||
(defalias &ident alias 5)
|
||||
(undefalias &ident alias)
|
||||
(defvar alias 9)
|
||||
(defun aliasValue [] alias)
|
||||
(defun aliasValue [] alias)
|
||||
|
||||
// If for whatever reason, you wanted to make a function called and
|
||||
(undefmacro and)
|
||||
(defun and [a b] (+ a b))
|
||||
(defun andValue [] (and 5 6))
|
Reference in New Issue
Block a user