* Re: question about vardef variables
[not found] <mailman.1.1610881201.32131.ntg-context@ntg.nl>
@ 2021-01-17 12:53 ` Jeong Dal
0 siblings, 0 replies; 3+ messages in thread
From: Jeong Dal @ 2021-01-17 12:53 UTC (permalink / raw)
To: ntg-context
[-- Attachment #1.1: Type: text/plain, Size: 736 bytes --]
Dear Damien Thiriet,
If you change ‘vardef’ to ‘def’, you will get the figure.
There is a difference between ‘vardef’ and ‘def’.
AFAIK, vardef returns the value of the last statement in the macro.
Please see the examples in Metafun manual from page 32 ~ .
I hope that you find your answer there.
I am sorry that I am not good enough to explain the variables.
Best regards,
Dalyoung
> 2021. 1. 17. 오후 8:00, ntg-context-request@ntg.nl 작성:
>
> \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
[-- Attachment #1.2: Type: text/html, Size: 11050 bytes --]
[-- Attachment #2: Type: text/plain, Size: 493 bytes --]
___________________________________________________________________________________
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
___________________________________________________________________________________
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: question about vardef variables
2021-01-17 10:17 Damien Thiriet
@ 2021-01-18 8:13 ` Taco Hoekwater
0 siblings, 0 replies; 3+ messages in thread
From: Taco Hoekwater @ 2021-01-18 8:13 UTC (permalink / raw)
To: mailing list for ConTeXt users
> 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
___________________________________________________________________________________
^ permalink raw reply [flat|nested] 3+ messages in thread
* question about vardef variables
@ 2021-01-17 10:17 Damien Thiriet
2021-01-18 8:13 ` Taco Hoekwater
0 siblings, 1 reply; 3+ messages in thread
From: Damien Thiriet @ 2021-01-17 10:17 UTC (permalink / raw)
To: ntg-context
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?
- Would it be possible to issue an error message each time this wrong
declaration is made?
Thanks,
Damien Thiriet
___________________________________________________________________________________
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
___________________________________________________________________________________
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2021-01-18 8:13 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
[not found] <mailman.1.1610881201.32131.ntg-context@ntg.nl>
2021-01-17 12:53 ` question about vardef variables Jeong Dal
2021-01-17 10:17 Damien Thiriet
2021-01-18 8:13 ` Taco Hoekwater
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).