# HG changeset patch # User naryl # Date 2020-08-25 20:42:03 # Node ID 4e5eb097f323942b2241cf1e4cd470bb5815ab73 # Parent 44143cfd92083785932def03d47d95ef5fba4301 Fix a bug in dynamic return diff --git a/src/api-macros.lisp b/src/api-macros.lisp --- a/src/api-macros.lisp +++ b/src/api-macros.lisp @@ -1,11 +1,12 @@ (in-package txt2web.api) -(defpsmacro with-call-args (args &body body) +(defpsmacro with-call-args (args return &body body) `(progn (init-args ,args) ,@body - (get-result))) + ,@(when return + '((get-result))))) (defpsmacro with-frame (&body body) `(progn diff --git a/src/api.ps b/src/api.ps --- a/src/api.ps +++ b/src/api.ps @@ -134,7 +134,7 @@ (dotimes (i 10) (set-global "ARGS" i 0) (set-global "$ARGS" i "") - (when (< i (length args)) + (when (and args (< i (length args))) (let ((arg (elt args i))) (if (numberp arg) (set-global "ARGS" i arg) @@ -147,9 +147,8 @@ (defun call-loc (name args) (setf name (chain name (to-upper-case))) (with-frame - (with-call-args args - (funcall (getprop *locs name)))) - (void)) + (with-call-args args t + (funcall (getprop *locs name))))) (defun call-act (title) (with-frame diff --git a/src/intrinsic-macros.lisp b/src/intrinsic-macros.lisp --- a/src/intrinsic-macros.lisp +++ b/src/intrinsic-macros.lisp @@ -90,16 +90,15 @@ `(progn (when (stringp ,block) (api:report-error "DYNAMIC can't evaluate arbitrary strings.\\nUse {braces} to create blocks for DYNAMIC.")) - (api:with-call-args ,args - (funcall ,block)) - (void))) + (api:with-call-args ,args nil + (funcall ,block)))) (defpsmacro dyneval (block &rest args) `(progn - (when (stringp block) + (when (stringp ,block) (api:report-error "DYNEVAL can't evaluate arbitrary strings.\\nUse {braces} to create blocks for DYNEVAL.")) - (api:with-call-args args - (funcall block)))) + (api:with-call-args ,args t + (funcall ,block)))) ;;; 11main