ntg-context - mailing list for ConTeXt users
 help / color / mirror / Atom feed
* "Redundant equation" is a MetaPost bug in MkIV?
@ 2010-12-05  3:14 Li Yanrui (李延瑞)
  2010-12-05  3:53 ` Aditya Mahajan
                   ` (3 more replies)
  0 siblings, 4 replies; 7+ messages in thread
From: Li Yanrui (李延瑞) @ 2010-12-05  3:14 UTC (permalink / raw)
  To: mailing list for ConTeXt users

Hi,

See the following example:

\starttext
\startMPcode
u = 1cm;
xmin = -2.6u;
xmax = 4u;
drawarrow (xmin,0)--(xmax,0);
\stopMPcode
\stoptext

It can be compiled rightly. But when I add the 'label' line into it, see:

\starttext
\startMPcode
u = 1cm;
xmin = -2.6u;
xmax = 4u;
drawarrow (xmin,0)--(xmax,0);
label.lft("hello",(0, 0));
\stopMPcode
\stoptext

Now it can not be compiled and luatex outputs:

mplib           : loading 'metafun.mp' (experimental metapost version two)
mplib           > mp terminal: ! Redundant equation.
<to be read again>
                   ;
<*> u = 1cm;
             xmin = -2.6u; xmax = 4u; drawarrow (xmin,0)--(xmax,0); label.lf...

! Redundant equation.
<to be read again>

Is this a bug or it always need to use 'save' macro to hold these
local variable in metafun?

-- 
Best regards,

Li Yanrui
___________________________________________________________________________________
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://tex.aanhet.net
archive  : http://foundry.supelec.fr/projects/contextrev/
wiki     : http://contextgarden.net
___________________________________________________________________________________


^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: "Redundant equation" is a MetaPost bug in MkIV?
  2010-12-05  3:14 "Redundant equation" is a MetaPost bug in MkIV? Li Yanrui (李延瑞)
@ 2010-12-05  3:53 ` Aditya Mahajan
  2010-12-06  0:21   ` Li Yanrui (李延瑞)
  2010-12-05  7:18 ` Taco Hoekwater
                   ` (2 subsequent siblings)
  3 siblings, 1 reply; 7+ messages in thread
From: Aditya Mahajan @ 2010-12-05  3:53 UTC (permalink / raw)
  To: mailing list for ConTeXt users

[-- Attachment #1: Type: TEXT/PLAIN, Size: 1178 bytes --]

On Sun, 5 Dec 2010, Li Yanrui (李延瑞) wrote:

> Hi,
>
> See the following example:
>
> \starttext
> \startMPcode
> u = 1cm;
> xmin = -2.6u;
> xmax = 4u;
> drawarrow (xmin,0)--(xmax,0);
> \stopMPcode
> \stoptext
>
> It can be compiled rightly. But when I add the 'label' line into it, see:
>
> \starttext
> \startMPcode
> u = 1cm;
> xmin = -2.6u;
> xmax = 4u;
> drawarrow (xmin,0)--(xmax,0);
> label.lft("hello",(0, 0));
> \stopMPcode
> \stoptext
>
> Now it can not be compiled and luatex outputs:
>
> mplib           : loading 'metafun.mp' (experimental metapost version two)
> mplib           > mp terminal: ! Redundant equation.
> <to be read again>
>                   ;
> <*> u = 1cm;
>             xmin = -2.6u; xmax = 4u; drawarrow (xmin,0)--(xmax,0); label.lf...
>
> ! Redundant equation.
> <to be read again>
>
> Is this a bug or it always need to use 'save' macro to hold these
> local variable in metafun?

When a label (or btex ... etex) is present, ConTeXt processes the MP code 
twice: once to typeset the labels and then to place to labels. You get a 
redundant equation in the second pass.

The easiest way to prevent this is to use := instead of =

Aditya

[-- Attachment #2: Type: text/plain, Size: 486 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://tex.aanhet.net
archive  : http://foundry.supelec.fr/projects/contextrev/
wiki     : http://contextgarden.net
___________________________________________________________________________________

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: "Redundant equation" is a MetaPost bug in MkIV?
  2010-12-05  3:14 "Redundant equation" is a MetaPost bug in MkIV? Li Yanrui (李延瑞)
  2010-12-05  3:53 ` Aditya Mahajan
@ 2010-12-05  7:18 ` Taco Hoekwater
  2010-12-05  8:06 ` Yury G. Kudryashov
  2010-12-05  8:25 ` Alan BRASLAU
  3 siblings, 0 replies; 7+ messages in thread
From: Taco Hoekwater @ 2010-12-05  7:18 UTC (permalink / raw)
  To: mailing list for ConTeXt users

On 12/05/2010 04:14 AM, Li Yanrui (李延瑞) wrote:
>
> Is this a bug or it always need to use 'save' macro to hold these
> local variable in metafun?

It is a side-effect of MkIV running your code through metapost
multiple times. But why it does that, I am not sure.

Best wishes,
Taco
___________________________________________________________________________________
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://tex.aanhet.net
archive  : http://foundry.supelec.fr/projects/contextrev/
wiki     : http://contextgarden.net
___________________________________________________________________________________

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: "Redundant equation" is a MetaPost bug in MkIV?
  2010-12-05  3:14 "Redundant equation" is a MetaPost bug in MkIV? Li Yanrui (李延瑞)
  2010-12-05  3:53 ` Aditya Mahajan
  2010-12-05  7:18 ` Taco Hoekwater
@ 2010-12-05  8:06 ` Yury G. Kudryashov
  2010-12-05  8:25 ` Alan BRASLAU
  3 siblings, 0 replies; 7+ messages in thread
From: Yury G. Kudryashov @ 2010-12-05  8:06 UTC (permalink / raw)
  To: ntg-context

Li Yanrui (李延瑞) wrote:

> Hi,
> 
> Now it can not be compiled and luatex outputs:
> 
> mplib           : loading 'metafun.mp' (experimental metapost version two)
> mplib           > mp terminal: ! Redundant equation.
> <to be read again>
>                    ;
> <*> u = 1cm;
>              xmin = -2.6u; xmax = 4u; drawarrow (xmin,0)--(xmax,0);
>              label.lf...
> 
> ! Redundant equation.
> <to be read again>
> 
> Is this a bug or it always need to use 'save' macro to hold these
> local variable in metafun?
ConTeXt compiles all metapost code in one long run, so you have to re-
declare 'u' to avoid this error (e.g. 'save' or 'numeric u;').


___________________________________________________________________________________
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://tex.aanhet.net
archive  : http://foundry.supelec.fr/projects/contextrev/
wiki     : http://contextgarden.net
___________________________________________________________________________________

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: "Redundant equation" is a MetaPost bug in MkIV?
  2010-12-05  3:14 "Redundant equation" is a MetaPost bug in MkIV? Li Yanrui (李延瑞)
                   ` (2 preceding siblings ...)
  2010-12-05  8:06 ` Yury G. Kudryashov
@ 2010-12-05  8:25 ` Alan BRASLAU
  2010-12-05  9:26   ` Li Yanrui (李延瑞)
  3 siblings, 1 reply; 7+ messages in thread
From: Alan BRASLAU @ 2010-12-05  8:25 UTC (permalink / raw)
  To: Li Yanrui (李延瑞); +Cc: ntg-context

Hello,

You should change all of the "=" to ":=", as in
u := 1cm;

This instructs metapost to assign a value to the variable;
the standard form "u = 1cm" is a formula for metapost to solve.
It tries then to resolve u = 1cm; xmin = -2.6u; and xmax = 4u;
as a coupled set of equations. Sometimes you can get away with
this but in general one should use the := (assignment) form.

Consider, for example:
u = u + 1;
(a standard programming statement but nonsense for a mathematician).

Alan



On Sunday 05 December 2010 04:14:01 Li Yanrui (李延瑞) wrote:
> Hi,
> 
> See the following example:
> 
> \starttext
> \startMPcode
> u = 1cm;
> xmin = -2.6u;
> xmax = 4u;
> drawarrow (xmin,0)--(xmax,0);
> \stopMPcode
> \stoptext
> 
> It can be compiled rightly. But when I add the 'label' line into it, see:
> 
> \starttext
> \startMPcode
> u = 1cm;
> xmin = -2.6u;
> xmax = 4u;
> drawarrow (xmin,0)--(xmax,0);
> label.lft("hello",(0, 0));
> \stopMPcode
> \stoptext
> 
> Now it can not be compiled and luatex outputs:
> 
> mplib           : loading 'metafun.mp' (experimental metapost version two)
> mplib           > mp terminal: ! Redundant equation.
> <to be read again>
>                    ;
> <*> u = 1cm;
>              xmin = -2.6u; xmax = 4u; drawarrow (xmin,0)--(xmax,0);
> label.lf...
> 
> ! Redundant equation.
> <to be read again>
> 
> Is this a bug or it always need to use 'save' macro to hold these
> local variable in metafun?
___________________________________________________________________________________
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://tex.aanhet.net
archive  : http://foundry.supelec.fr/projects/contextrev/
wiki     : http://contextgarden.net
___________________________________________________________________________________

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: "Redundant equation" is a MetaPost bug in MkIV?
  2010-12-05  8:25 ` Alan BRASLAU
@ 2010-12-05  9:26   ` Li Yanrui (李延瑞)
  0 siblings, 0 replies; 7+ messages in thread
From: Li Yanrui (李延瑞) @ 2010-12-05  9:26 UTC (permalink / raw)
  To: mailing list for ConTeXt users

2010/12/5 Alan BRASLAU <alan.braslau@cea.fr>:
> Hello,
>
> You should change all of the "=" to ":=", as in
> u := 1cm;
>
> This instructs metapost to assign a value to the variable;
> the standard form "u = 1cm" is a formula for metapost to solve.
> It tries then to resolve u = 1cm; xmin = -2.6u; and xmax = 4u;
> as a coupled set of equations. Sometimes you can get away with
> this but in general one should use the := (assignment) form.
>
> Consider, for example:
> u = u + 1;
> (a standard programming statement but nonsense for a mathematician).
>

I know the difference between "=" and ":=". But that example shows the
metafun in MkIV is abnormal since it can be compiled rightly in MkII,
which should not have any syntax error.

In fact, the following example can be compiled rightly in MkIV.

\starttext
\startMPcode
save u, xmin, xmax;
u = 1cm;
xmin = -2.6u;
xmax = 4u;
drawarrow (xmin,0)--(xmax,0);
label.lft("hello",(0, 0));
\stopMPcode
\stoptext

-- 
Best regards,

Li Yanrui (李延瑞)
___________________________________________________________________________________
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://tex.aanhet.net
archive  : http://foundry.supelec.fr/projects/contextrev/
wiki     : http://contextgarden.net
___________________________________________________________________________________

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: "Redundant equation" is a MetaPost bug in MkIV?
  2010-12-05  3:53 ` Aditya Mahajan
@ 2010-12-06  0:21   ` Li Yanrui (李延瑞)
  0 siblings, 0 replies; 7+ messages in thread
From: Li Yanrui (李延瑞) @ 2010-12-06  0:21 UTC (permalink / raw)
  To: mailing list for ConTeXt users

2010/12/5 Aditya Mahajan <adityam@umich.edu>:
> On Sun, 5 Dec 2010, Li Yanrui (李延瑞) wrote:
>
> When a label (or btex ... etex) is present, ConTeXt processes the MP code
> twice: once to typeset the labels and then to place to labels. You get a
> redundant equation in the second pass.
>
> The easiest way to prevent this is to use := instead of =
>

I see now. Thank you Aditya and others !

-- 
Best regards,

Li Yanrui
___________________________________________________________________________________
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://tex.aanhet.net
archive  : http://foundry.supelec.fr/projects/contextrev/
wiki     : http://contextgarden.net
___________________________________________________________________________________

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2010-12-06  0:21 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-12-05  3:14 "Redundant equation" is a MetaPost bug in MkIV? Li Yanrui (李延瑞)
2010-12-05  3:53 ` Aditya Mahajan
2010-12-06  0:21   ` Li Yanrui (李延瑞)
2010-12-05  7:18 ` Taco Hoekwater
2010-12-05  8:06 ` Yury G. Kudryashov
2010-12-05  8:25 ` Alan BRASLAU
2010-12-05  9:26   ` Li Yanrui (李延瑞)

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).