ntg-context - mailing list for ConTeXt users
 help / color / mirror / Atom feed
From: Hans Hagen <j.hagen@xs4all.nl>
To: mailing list for ConTeXt users <ntg-context@ntg.nl>
Subject: scope
Date: Sun, 14 Feb 2021 17:56:44 +0100	[thread overview]
Message-ID: <4c74c9ff-1021-cfc6-aa93-e7ad8b43ba55@xs4all.nl> (raw)

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
___________________________________________________________________________________

                 reply	other threads:[~2021-02-14 16:56 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=4c74c9ff-1021-cfc6-aa93-e7ad8b43ba55@xs4all.nl \
    --to=j.hagen@xs4all.nl \
    --cc=ntg-context@ntg.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).