On 1/21/2013 8:47 PM, PELLOUIN Christophe wrote:
Le 21/01/2013 19:32, Hans Hagen a écrit :
On 1/21/2013 7:26 PM, PELLOUIN Christophe wrote:
Hello,
When writing a macro, I observed that some arguments are not transmitted correctly, particularly when the type is defined as "text". Here is an example with the macro max defined in the file plain.mp With this program:
beginfig(1)
show("first test"); show max (1,2,8,5,15,2,1,4);
numeric u_; v_=15; show("second test"); show max (1,2,8,5,v_,2,1,4);
numeric u_; u_=15 % u_ variable is also defined in the macro max show("third test"); show max (1,2,8,5,u_,2,1,4);
endfig; end
The result is:
This is MetaPost, version 1.504 (kpathsea version 6.0.1) (mpost.mp (c:/texlive/2011/texmf-dist/metapost/base/plain.mp Preloading the plain mem file, version 1.004)) (./bizzare.mp >> "first test" >> 15 >> "second test" >> 15 >> "third test" >> 8 [1] ) 1 output file written: bizzare.1 Transcript written on bizzare.log.
The third result is different because the variable u_ is defined in the macro max of the file plain.mp
I can protect all local plain variables if needed but I'll only do it if someone then tests all the plain macros.
How can I protect a variable? I had the same bug in one of my macros and I'd like to fix it.
my_private_u ----------------------------------------------------------------- Hans Hagen | PRAGMA ADE Ridderstraat 27 | 8061 GH Hasselt | The Netherlands tel: 038 477 53 69 | voip: 087 875 68 74 | www.pragma-ade.com | www.pragma-pod.nl -----------------------------------------------------------------