[metapost] accessing variables in nested macros
mailing_list at arcor.de
Fri Feb 9 17:19:46 CET 2007
within two macros that share the same initialization calculations I want
to put those calculations into a new macro called "init". Now, I don't
want to pass a whole bunch of variables to "init" and tried a simple def
declaration in the hope that "init" then shares the context (group and
variables) of the calling macro. That is, I expected
vardef calcA(expr parameters)=
when called, more or less to literally replace "init;" by "calculation;"
and therefore accessing variables from "calcA" in "init" should be ok.
However, in the example below I can't access variables from the calling
macro. What's wrong with my definition?
%%% Variable b should be saved with respect to the
%%% local group of the calling vardef macro.
b := a + 1;
vardef calcA(expr a)=
show "a = " & decimal a;
% show "b = " & decimal b;
More information about the metapost