[metapost] variable parameter list

Jens-Uwe Morawski s5d5 at gmx.net
Wed Feb 15 00:13:52 CET 2006


Dan Luecking wrote:
> The fact that its return value is never used
> suggests that it needn't actually have a return value. A for-loop
> doesn't care if the expressions are empty, it just skips to the
> next. I didn't test this, however.

without return value:

numeric b ; color c ;

def processKeyvals (text _kvps_)=
  begingroup;
    save _equals, _assign ;
    let _equals= = ;
    
    primarydef _ll_ _assign _rr_ =
      hide(_ll_ _equals _rr_ )
    enddef;

    save = ;
    let = _equals _assign ;
    for _xx_ _equals _kvps_ : endfor ;% NOP
  endgroup;
enddef;

processKeyvals(b=5,c=red) ;
end

gives:

This is MetaPost, Version 0.641 (Web2C 7.5.3)
(t.mp
! A secondary expression can't begin with `,'.
<inserted text> 
                0
<to be read again> 
                   ,
<argument> b=5,
               c=red
processKeyvals->..._assign;for._xx_._equals(TEXT0)
                                                  :endfor;endgroup;
l.17 processKeyvals(b=5,c=red)
                               ;



More information about the metapost mailing list