MPinclusions, MPextensions, MPinitializations and MPinstances
Hi, I know that MPinclusions are included only once and MPinitializations are included once for each graphic. But how do MPextensions fit in? How can I define variables or definitions that are local to a particular MP instance? Marco
On 2/13/2013 6:59 PM, Marco Patzer wrote:
Hi,
I know that MPinclusions are included only once and MPinitializations are included once for each graphic. But how do MPextensions fit in?
How can I define variables or definitions that are local to a particular MP instance?
by defining a new instance Hans ----------------------------------------------------------------- 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 -----------------------------------------------------------------
On 2013–02–14 Hans Hagen wrote:
I know that MPinclusions are included only once and MPinitializations are included once for each graphic. But how do MPextensions fit in?
How can I define variables or definitions that are local to a particular MP instance?
by defining a new instance
I guess I didn't make myself clear. \startMPinitializations numeric n; n=4cm; \stopMPinitializations Now I can use “n” in all MP instances (unless switched off for the particular instance). I'd like to define some variables only visible in instance “foo”. Something like \startMPinitializations [foo] numeric n; n=4cm; \stopMPinitializations I tried \startMPcode{foo} numeric n; n=4cm; \stopMPcode but this adds some vertical space and doesn't seem to be the right solution given the face that there are already three other environments to include MetaPost code. Maybe I'm missing the obvious here. Marco
On 2013–02–14 Marco Patzer wrote:
Now I can use “n” in all MP instances (unless switched off for the particular instance). I'd like to define some variables only visible in instance “foo”. Something like
\startMPinitializations [foo] numeric n; n=4cm; \stopMPinitializations
What I was looking for was (it's even mentioned in the manual): \startMPdefinitions{foo} … \stopMPdefinitions That means we have: - MPdefinitions (for instance-local definitions) - MPinclusions (global definitions) - MPinitializations (global definitions, can be disabled for an MP instance) - MPextensions (???, seems to be the same as MPinitializations) And all four include code for use within MP graphics. That really is confusing!
Maybe I'm missing the obvious here.
Yes, I did :) Marco
I am glad to see that I am not alone being confused...
We have:
\defineMPinstance
[name]
[\s!format=metafun,
\s!extensions=\v!yes,
\s!initializations=\v!yes,
\c!method=\s!default,
\c!textstyle=,
\c!textcolor=]
also, \setupMPinstance
So that extensions=yes|no and initializations=yes|no controls the use
of MPextensions and MPinitializations. It seems that extensions is
intended for all instances ("when enabled").
From what I can see, extensions are read "once", initializations "each",
and inclusions are intended for the "user". It appears that
initializations is used to pass dynamic things from ConTeXt to MP.
I still have not figured out how to specify MPinclusions for a
particular instance.
It would be nice for someone who understands this all to explain it.
Alan
On Thu, 14 Feb 2013 14:01:44 +0100
Marco Patzer
On 2013–02–14 Marco Patzer wrote:
Now I can use “n” in all MP instances (unless switched off for the particular instance). I'd like to define some variables only visible in instance “foo”. Something like
\startMPinitializations [foo] numeric n; n=4cm; \stopMPinitializations
What I was looking for was (it's even mentioned in the manual):
\startMPdefinitions{foo} … \stopMPdefinitions
That means we have:
- MPdefinitions (for instance-local definitions) - MPinclusions (global definitions) - MPinitializations (global definitions, can be disabled for an MP instance) - MPextensions (???, seems to be the same as MPinitializations)
And all four include code for use within MP graphics. That really is confusing!
Maybe I'm missing the obvious here.
Yes, I did :)
On 2013–02–14 Alan BRASLAU wrote:
So that extensions=yes|no and initializations=yes|no controls the use of MPextensions and MPinitializations. It seems that extensions is intended for all instances ("when enabled").
From what I can see, extensions are read "once", initializations "each", and inclusions are intended for the "user". It appears that initializations is used to pass dynamic things from ConTeXt to MP.
This means we have two cases: - read one single time (once) - read one time per graphic (each) And another two cases: - global to all instances (global) - local to a particular instance (local) And we have four inclusion environments. I don't know how to map them to the cases listed above. - MPdefinitions (local, ???) - MPinclusions (global, ???) - MPinitializations (global, each) - MPextensions (global, once) I don't understand the need of so many different environments. E.g. MPinclusions could be global unless an argument specifying the instance is provided.
It would be nice for someone who understands this all to explain it.
+1
I still have not figured out how to specify MPinclusions for a particular instance.
Try \startMPdefinitions{myinstance} Marco
On Thu, 14 Feb 2013 19:14:46 +0100
Marco Patzer
I still have not figured out how to specify MPinclusions for a particular instance.
Try \startMPdefinitions{myinstance}
This is *not* the same as MPinclusions! We may have an instance with its own MPdefinitions, already, to which the user may wish to add his own MPinclusions (eventually several times using the [+] argument). \startMPinclusions{myinstance} does not work. Alan
On 2/14/2013 7:14 PM, Marco Patzer wrote:
On 2013–02–14 Alan BRASLAU wrote:
So that extensions=yes|no and initializations=yes|no controls the use of MPextensions and MPinitializations. It seems that extensions is intended for all instances ("when enabled").
From what I can see, extensions are read "once", initializations "each", and inclusions are intended for the "user". It appears that initializations is used to pass dynamic things from ConTeXt to MP.
This means we have two cases:
- read one single time (once) - read one time per graphic (each)
And another two cases:
- global to all instances (global) - local to a particular instance (local)
And we have four inclusion environments. I don't know how to map them to the cases listed above.
- MPdefinitions (local, ???) - MPinclusions (global, ???) - MPinitializations (global, each) - MPextensions (global, once)
I don't understand the need of so many different environments. E.g. MPinclusions could be global unless an argument specifying the instance is provided.
It would be nice for someone who understands this all to explain it.
+1
I still have not figured out how to specify MPinclusions for a particular instance.
% initializations % to be used by context / modules % cummulative % things like page states, use by context itself % each instance (unless disabled, as not all instances need them) % each graphic % definitions % can be used to add helpers and such % cummulative % per instance % just after a format is loaded % extensions % cummulative % used for all instances % blocked per instance after first graphic % was: reset after first use % fix for 'all' instances instead of first used instance: % % \def\meta_reset_current_preamble % {\ifconditional\c_meta_include_extensions % \global\letMPinstanceparameter\s!extensions\v!no % %global\t_meta_extensions\emptytoks % \fi} % inclusions % user stuff % cummulative % used next instance/graphic % reset afterwards (always) % can be blocked per instance ----------------------------------------------------------------- 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 -----------------------------------------------------------------
participants (4)
-
Alan BRASLAU
-
Hans Hagen
-
Marco Patzer
-
Wolfgang Schuster