[metapost] How to ignore a comma?

Mojca Miklavec mojca.miklavec.lists at gmail.com
Wed Feb 7 19:55:19 CET 2007


I have now managed to implement all the macros exactly in the way I
wanted apart from a few tiny details. I have two problems left:

1. The following syntax

def do_something(expr p)(text t) =

doesn't allow using
but one has to use at least

Is there a solution for it (p will be a path in my case)?

2. A much more serious problem:

I would like to use definitions with multiple parameters:

If set_angle redefines the comma into semicolon, I suspect that the
problem arises for

Is there a way to "let" the let redefine only the first comma it sees?
In "TeX pseudo-code" that would be:

   \def\comma{\semicolon \let\comma\normalcomma}

Thanks a lot,

(I know that there are workarounds and other possible ways to specify
arguments, but I would really like to have a clean interface and I'm
sure that that should be possible in metapost.)

> def do_something(expr xx, yy)(text t) =
>         save c; color c; c = black;
>         save d; numeric d; d = 5pt;
>         let@=,;
>         def set_color(expr col) =
>                 let,=@;
>                 let@=,;
>                 c := col;
>                 let,=;;
>         enddef;
>         def set_size(expr size) =
>                 let,=@;
>                 let@=,;
>                 d := size;
>                 let,=;;
>         enddef;
>         t;
>         let,=@;
>         fill fullcircle scaled d shifted (xx,yy) withcolor c;
> enddef;
> do_something(2.5cm,1.5cm,set_color(blue),set_size(8pt));
> draw unitsquare scaled 3cm;

More information about the metapost mailing list