ntg-context - mailing list for ConTeXt users
 help / color / mirror / Atom feed
From: Taco Hoekwater <taco@bittext.nl>
To: mailing list for ConTeXt users <ntg-context@ntg.nl>
Subject: Re: question about vardef variables
Date: Mon, 18 Jan 2021 09:13:10 +0100	[thread overview]
Message-ID: <67CB27E1-9446-4C28-968E-B7C849B248F3@bittext.nl> (raw)
In-Reply-To: <20210117101700.GA30115@valencay.home>



> On 17 Jan 2021, at 11:17, Damien Thiriet <damien@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: taco@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	other threads:[~2021-01-18  8:13 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-01-17 10:17 Damien Thiriet
2021-01-18  8:13 ` Taco Hoekwater [this message]
     [not found] <mailman.1.1610881201.32131.ntg-context@ntg.nl>
2021-01-17 12:53 ` Jeong Dal

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=67CB27E1-9446-4C28-968E-B7C849B248F3@bittext.nl \
    --to=taco@bittext.nl \
    --cc=ntg-context@ntg.nl \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).