rename defmacro to defmacrofun because it is not technically lisp macros
This commit is contained in:
@@ -48,13 +48,13 @@ class Macros {
|
|||||||
|
|
||||||
// TODO when
|
// 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
|
// Under the hood, (defmacrofun ...) defines a runtime function that accepts Quote arguments and a special form that quotes the arguments to macrofun calls
|
||||||
macros["defmacro"] = (exps:Array<ReaderExp>, k:KissState) -> {
|
macros["defmacrofun"] = (exps:Array<ReaderExp>, k:KissState) -> {
|
||||||
if (exps.length < 3)
|
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]) {
|
var macroName = switch (exps[0]) {
|
||||||
case Symbol(name): name;
|
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) -> {
|
k.specialForms[macroName] = (callArgs:Array<ReaderExp>, convert) -> {
|
||||||
ECall(Context.parse('${k.className}.${macroName}', Context.currentPos()), [
|
ECall(Context.parse('${k.className}.${macroName}', Context.currentPos()), [
|
||||||
|
|||||||
@@ -63,7 +63,7 @@
|
|||||||
(defvar myIf7 (if "string" true false))
|
(defvar myIf7 (if "string" true false))
|
||||||
(defvar myIf8 (if "" true false))
|
(defvar myIf8 (if "" true false))
|
||||||
|
|
||||||
(defmacro doTwiceInt [intOp]
|
(defmacrofun doTwiceInt [intOp]
|
||||||
,intOp
|
,intOp
|
||||||
,intOp)
|
,intOp)
|
||||||
|
|
||||||
@@ -71,6 +71,6 @@
|
|||||||
(defun incrementTwice [val]
|
(defun incrementTwice [val]
|
||||||
(doTwiceInt ++val))
|
(doTwiceInt ++val))
|
||||||
|
|
||||||
(defmacro doTwiceString [stringOp]
|
(defmacrofun doTwiceString [stringOp]
|
||||||
,stringOp
|
,stringOp
|
||||||
,stringOp)
|
,stringOp)
|
||||||
Reference in New Issue
Block a user