ntg-context - mailing list for ConTeXt users
 help / color / mirror / Atom feed
From: PELLOUIN Christophe <christophe.pellouin@wanadoo.fr>
To: Hans Hagen <pragma@wxs.nl>
Cc: mailing list for ConTeXt users <ntg-context@ntg.nl>
Subject: Re: Problem with arguments in macro
Date: Mon, 21 Jan 2013 21:25:31 +0100	[thread overview]
Message-ID: <50FDA43B.4090906@wanadoo.fr> (raw)
In-Reply-To: <50FD9C1D.5030306@wxs.nl>

Le 21/01/2013 20:50, Hans Hagen a écrit :
> On 1/21/2013 8:47 PM, PELLOUIN Christophe wrote:
>> Le 21/01/2013 19:32, Hans Hagen a écrit :
>>> On 1/21/2013 7:26 PM, PELLOUIN Christophe wrote:
>>>> Hello,
>>>>
>>>> When writing a macro, I observed that some arguments are not 
>>>> transmitted
>>>> correctly, particularly when the type is defined as "text".
>>>> Here is an example with the macro max defined in the file plain.mp
>>>> With this program:
>>>>
>>>>      beginfig(1)
>>>>
>>>>          show("first test");
>>>>          show max (1,2,8,5,15,2,1,4);
>>>>
>>>>          numeric u_;
>>>>          v_=15;
>>>>          show("second test");
>>>>          show max (1,2,8,5,v_,2,1,4);
>>>>
>>>>          numeric u_;
>>>>          u_=15    % u_ variable is also defined in the macro max
>>>>          show("third test");
>>>>          show max (1,2,8,5,u_,2,1,4);
>>>>
>>>>      endfig;
>>>>      end
>>>>
>>>> The result is:
>>>>
>>>>      This is MetaPost, version 1.504 (kpathsea version 6.0.1)
>>>>      (mpost.mp (c:/texlive/2011/texmf-dist/metapost/base/plain.mp
>>>>      Preloading the plain mem file, version 1.004)) (./bizzare.mp
>>>>      >> "first test"
>>>>      >> 15
>>>>      >> "second test"
>>>>      >> 15
>>>>      >> "third test"
>>>>      >> 8 [1] )
>>>>      1 output file written: bizzare.1
>>>>      Transcript written on bizzare.log.
>>>>
>>>>
>>>>
>>>> The third result is different because the variable u_ is defined in 
>>>> the
>>>> macro max of the file plain.mp
>>>
>>> I can protect all local plain variables if needed but I'll only do it
>>> if someone then tests all the plain macros.
>>
>> How can I protect a variable? I had the same bug in one of my macros and
>> I'd like to fix it.
>
> my_private_u

Ok. Thank you

>
> -----------------------------------------------------------------
>                                           Hans Hagen | PRAGMA ADE
>               Ridderstraat 27 | 8061 GH Hasselt | The Netherlands
>     tel: 038 477 53 69 | voip: 087 875 68 74 | www.pragma-ade.com
>                                              | www.pragma-pod.nl
> -----------------------------------------------------------------
>

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


      reply	other threads:[~2013-01-21 20:25 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-01-21 18:26 PELLOUIN Christophe
2013-01-21 18:32 ` Hans Hagen
2013-01-21 19:47   ` PELLOUIN Christophe
2013-01-21 19:50     ` Hans Hagen
2013-01-21 20:25       ` PELLOUIN Christophe [this message]

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=50FDA43B.4090906@wanadoo.fr \
    --to=christophe.pellouin@wanadoo.fr \
    --cc=ntg-context@ntg.nl \
    --cc=pragma@wxs.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).