ntg-context - mailing list for ConTeXt users
 help / color / mirror / Atom feed
* scope
@ 2021-02-14 16:56 Hans Hagen
  0 siblings, 0 replies; only message in thread
From: Hans Hagen @ 2021-02-14 16:56 UTC (permalink / raw)
  To: mailing list for ConTeXt users

Hi,

When you allocate a new register (with e.g. \newdimen) that is always a 
global definition (kind of a tex tradition). As a (likely to stay) 
experiment I added

   \newlocaldimen    \foo
   \setnewlocaldimen \foo 123pt

and comparable helpers. Some more can be found in lowlevel-scope.pdf in 
the distribution. The idea is that users who write their own macros that 
need 'variables' can define them locally without the danger for clashing 
with system ones (or each others macros). Actually, global assignments 
only affects that variable, so one can do

\bgroup
\newlocaldimen\foo
\bgroup
\global\foo=456pt
\egroup
... use \foo
\egroup

Best use names like \mydimena etc in order nnot to clash with system 
ones (that can be protected against overload). In spite of redefinitions 
each time a macro using it gets expanded, performance is quite okay.

It falls in the category "interesting hacks but maybe not needed because 
never asked for", but on the other hand, sometimes availability creates 
retrospective demand. (I also did \newlocalread and added some extra 
random access hackery to \read, so who knows what users will abuse that 
feature for.)

Hans


-----------------------------------------------------------------
                                           Hans Hagen | PRAGMA ADE
               Ridderstraat 27 | 8061 GH Hasselt | The Netherlands
        tel: 038 477 53 69 | www.pragma-ade.nl | 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://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki     : http://contextgarden.net
___________________________________________________________________________________

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2021-02-14 16:56 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-02-14 16:56 scope Hans Hagen

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