> On 17 Jan 2021, at 11:17, Damien Thiriet <dam...@thiriet.web4me.fr> wrote:
> 
> Hi,
> 
> 
> I have some troubles with understanding metafun's macro mechanism.
> 
> Given this MWE:
> 
> \starttext
> \startMPpage
> 
> vardef Test (expr ab,cd)=
>   %numeric ab;
>   %numeric cd;
>   draw unitsquare scaled 10 xshifted ab;
>   draw unitsquare scaled 10 yshifted cd;
> enddef;
> 
> Test (50,100);
> \stopMPpage
> \stoptext
> 
> Uncommenting the two declarations makes me run intro a silent error. I was 
> lucky enough yesterday to get an explicit error message with a more 
> complex macro.  It made me figure out where my problems came from.
> 
> So here are my two questions:
> - Why shouldn't we tell metafun if expr is a path, a pair or so on?

You were (attempting to) redefine the macro’s arguments, but they are read-only.

A somewhat longer answer: the type of macro arguments in this case is “expr”. 
Metapost argument types are based solely on what the internal language parser 
needs to interpret the code; the language is not strongly typed.

Also, during macro expansion, your code is replaced by:

  %numeric (READONLY TEMP VALUE 1);
  %numeric (READONLY TEMP VALUE 2);
  draw unitsquare scaled 10 xshifted (READONLY TEMP VALUE 1);
  draw unitsquare scaled 10 yshifted (READONLY TEMP VALUE 2);

Best wishes,
Taco

— 
Taco Hoekwater              E: t...@bittext.nl
genderfluid (all pronouns)







___________________________________________________________________________________
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
___________________________________________________________________________________

Reply via email to