rename defmacro to defmacrofun because it is not technically lisp macros

This commit is contained in:
2020-11-18 12:53:04 -07:00
parent 165d548128
commit 382d06d8c9
2 changed files with 6 additions and 6 deletions

View File

@@ -48,13 +48,13 @@ class Macros {
// TODO when
// Under the hood, (defmacro ...) defines a runtime function that accepts Quote arguments and a special form that quotes the arguments to macro calls
macros["defmacro"] = (exps:Array<ReaderExp>, k:KissState) -> {
// Under the hood, (defmacrofun ...) defines a runtime function that accepts Quote arguments and a special form that quotes the arguments to macrofun calls
macros["defmacrofun"] = (exps:Array<ReaderExp>, k:KissState) -> {
if (exps.length < 3)
throw '${exps.length} is not enough arguments for (defmacro [name] [args] [body])';
throw '${exps.length} is not enough arguments for (defmacrofun [name] [args] [body])';
var macroName = switch (exps[0]) {
case Symbol(name): name;
default: throw 'first argument ${exps[0]} for defmacro should be a symbol for the macro name';
default: throw 'first argument ${exps[0]} for defmacrofun should be a symbol for the macro name';
};
k.specialForms[macroName] = (callArgs:Array<ReaderExp>, convert) -> {
ECall(Context.parse('${k.className}.${macroName}', Context.currentPos()), [

View File

@@ -63,7 +63,7 @@
(defvar myIf7 (if "string" true false))
(defvar myIf8 (if "" true false))
(defmacro doTwiceInt [intOp]
(defmacrofun doTwiceInt [intOp]
,intOp
,intOp)
@@ -71,6 +71,6 @@
(defun incrementTwice [val]
(doTwiceInt ++val))
(defmacro doTwiceString [stringOp]
(defmacrofun doTwiceString [stringOp]
,stringOp
,stringOp)