From 91d3d7366521c11a99aa9584c3bda0e9c9eba9cb Mon Sep 17 00:00:00 2001 From: Nat Quayle Nelson Date: Sun, 21 Aug 2022 17:20:24 +0000 Subject: [PATCH] defAndX for local form versions --- projects/kiss-tools/src/kiss_tools/RefactorUtil.kiss | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/projects/kiss-tools/src/kiss_tools/RefactorUtil.kiss b/projects/kiss-tools/src/kiss_tools/RefactorUtil.kiss index 364a5990..815bc603 100644 --- a/projects/kiss-tools/src/kiss_tools/RefactorUtil.kiss +++ b/projects/kiss-tools/src/kiss_tools/RefactorUtil.kiss @@ -1,15 +1,14 @@ // Quick and dirty way to make a block reusable without restructuring code -// TODO won't work if locals are used in the body +// TODO won't work for function/method if locals are used in the body (defMacro defAndCall [type name &builder b &body body] (assert (exprCase type - (function true) - (method true) - (_ false)) "the first argument to defAndCall must be a symbol: function or method") + ((exprOr function method localFunction) true) + (_ false)) "the first argument to defAndCall must be a symbol: function, method, or localFunction") `{(,type ,name [] ,@body) (,(b.symbol (symbolNameValue name true true)))}) // Quick and dirty way to define constants without restructuring code (defMacro defAndReturn [type name value &builder b] (assert (exprCase type - ((exprOr var prop) true) - (_ false)) "the first argument to defAndReturn must be a symbol: var or prop") + ((exprOr var prop localVar) true) + (_ false)) "the first argument to defAndReturn must be a symbol: var, prop, or localVar") `{(,type ,name ,value) ,(b.symbol (symbolNameValue name true true))})