Answering myself: pth2 is not a valid variable name. Digits are not allowed.

On 14 Mar 2020, at 15:45, Gerben Wierda <gerben.wierda@rna.nl> wrote:

I have this vardef:

vardef Foo(expr w, h) =
   save pth; path pth;
   %save pth2; path pth2;
   save pic; picture pic;
   pth = fullsquare xysized (w, h);
   %pth2 = fullsquare xysized (h/4, h/8)
   pic := image (
       draw pth;
       %draw pth2 shifted (-w/2, -h/4);
       % all kind of stuff here
   );
   setbounds pic to pth;
   pic
enddef ;

As soon as I uncomment the bold line (first comment) a mtxrun fails. Whatever I try, a single save statement, etc., I fail in getting a second local variable. The METAPOST manual is no help.

The error shown is:

metapost log    > ! Extra tokens will be flushed.
metapost log    > <to be read again> 
metapost log    >                    2
metapost log    > Foo->...h;path.pth;save.pth2
metapost log    >                                                   ;path.pth2;save.pic;pictur...
metapost log    > <*> ... ; s := Foo(8cm, 2cm)
metapost log    >                                                   ; draw s; drawdot center l...
metapost log    > 

Why?

G
___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!

maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : http://www.pragma-ade.nl / http://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki     : http://contextgarden.net
___________________________________________________________________________________