defnew allow empty binding list
This commit is contained in:
@@ -408,9 +408,9 @@ class Helpers {
|
||||
};
|
||||
}
|
||||
|
||||
public static function bindingList(exp:ReaderExp, forThis:String):Array<ReaderExp> {
|
||||
public static function bindingList(exp:ReaderExp, forThis:String, allowEmpty = false):Array<ReaderExp> {
|
||||
return switch (exp.def) {
|
||||
case ListExp(bindingExps) if (bindingExps.length > 0 && bindingExps.length % 2 == 0):
|
||||
case ListExp(bindingExps) if ((allowEmpty || bindingExps.length > 0) && bindingExps.length % 2 == 0):
|
||||
bindingExps;
|
||||
default:
|
||||
throw CompileError.fromExp(exp, '$forThis bindings should be a list expression with an even number of sub expressions (at least 2)');
|
||||
|
@@ -531,7 +531,7 @@ class Macros {
|
||||
wholeExp.checkNumArgs(2, null, "(defnew [[args...]] [[property bindings...]] [body...]");
|
||||
|
||||
var args = exps[0];
|
||||
var bindingList = exps[1].bindingList("defnew");
|
||||
var bindingList = exps[1].bindingList("defnew", true);
|
||||
var bindingPairs = Prelude.groups(bindingList, 2);
|
||||
|
||||
var propertyDefs = [for (bindingPair in bindingPairs) {
|
||||
|
Reference in New Issue
Block a user