force evaluation of the first argument of the function with_stdout
Subject: force evaluation of the first argument of the function with_stdout
From: Robert Dodier
Date: Wed, 30 Nov 2005 09:52:20 -0700
hello jose,
> How can I do force evaluation of the first argument of the function
> with_stdout.
rewrite your function as a macro (i.e. using ::= instead of :=
and buildq instead of block). NB you have to mention the
function arguments in the buildq variable list (unlike block),
otherwise they'll be assumed to be literals. e.g.
g(x,s) ::= buildq ([x, s, y: x^2], with_stdout (s, print (x, "-->", y)));
g(a - b,"./tmp.2"); => (a - b)^2 (not important in this context)
and the file "./tmp.2" contains
a - b --> (a - b)^2
(the important bit here.)
buildq ([a, b, L], a + b + f (splice (L))) is not too different
from `(+ ,a ,b (f ,@L)) if you're familiar w/ lisp macros.
apply (with_stdout, [file_name, ...]) isn't quite right because
although file_name is evaluated by apply,
so are the other arguments (i.e., they're evaluated too soon).
with_stdout (ev (file_name), ...) writes to a file named "ev (file_name)".
f(file_name) := with_stdout (''file_name, ...) doesn't
have the hoped-for effect either.
::= / buildq isn't explained very well in the manual.
i've been meaning to do something about that, oh well.
hth,
robert dodier