From: Hans Hagen <j.hagen@xs4all.nl>
To: mailing list for ConTeXt users <ntg-context@ntg.nl>
Subject: [NTG-context] new upload
Date: Tue, 4 Feb 2025 17:59:55 +0100 [thread overview]
Message-ID: <63efa3c9-1fe1-47ea-b076-e61222f4a8fc@xs4all.nl> (raw)
Hi,
NOTA BENE:
The next upload is kind of special so best save the old tex tree if you
update.
For quite a while we have an extended expression scanner on board (in
luametatex) and after recently testing it a bit more I decided to start
using it. A side effect is that we can also use more clever assignments
to dimensions and numbers.
We already had:
\scratchcounter 10
\scratchcounter = 10
\scratchcounter \numexpr 1 + 10\relax
\scratchcounter \numexpression 1 + 10\relax
etc but these expr have a potential lookahead problem, not so much when
used liek this but when we have cases like
\numexpr 1 + 10 - #1\relax
because no one can predict what #1 is, maybe
\numexp 1 - 10/5
which effectively is:
\numexpr 1 + 10 - \numexp 1 - 10/5\relax
which can run wild so in the end that is not suitable for use in key
value situations. As part of our column set experiments we actually want
to pass 'expressions', think
\framed[height=2\lineheight-\strutdp]{...}
or even
\framed[height=2 * \lineheight - \strutdp]{...}
or even
\framed[height=2 * lh - sd]{...}
etc. where the 2 * dimension is something not possibel with \dimexpr.
So, to keep a long explanation short, we now also support
\dimexpr{....}
and also
\scratchdimen{...}
where in the later case we actually use
\dimexpression{....}
There's also \dimexperimental which has proper priority handler and can
mix with integers and floats as well as limited boolean expressions
(comparison) while its \numexperimental sibbling can also do bitwise
operations. (Actually \dimexpression also can do some of that but one
needs to use more ( ) around subexpressions; so \dimexpression
conceptually sits between \dimexpr and \dimexperimental).
Anyway, more about that in manuals and articles, and it's kind of old
news already.
The main impact is that now keys that refer to numbers and dimensions
can also accept expressions without the need to be explicit, so
width=3em + 2em * 4
lines=4 + (5*2 - 1)
eventually will all be seen as {something} which as it is valid in
assignments will trigger the right expression scanner.
The \todimension and \tointeger primitives also accept {} because they
scan for a dimension or number as again as side effect do all primitives
and engine keyword that matter. They are serializers.
Deep down context is now adapted to this: adding many {} in assignments,
wrapping parameters in {} so that they can properly nest, replacing
/removing redundant \dimexpr etc. All this can have introduced temporary
issues but they can be fixed easily, so I think that the benefits
outweight temporary issues. Think 'beta'.
In case one wonders, there is no real impact on performance because
expressions were already quite optimized and the (already kind of old)
new scanners even more so.
In due time more of the now possible features will be revealed.
Hans (and mikael who tested intermediate versions on real documents)
-----------------------------------------------------------------
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 / https://mailman.ntg.nl/mailman3/lists/ntg-context.ntg.nl
webpage : https://www.pragma-ade.nl / https://context.aanhet.net (mirror)
archive : https://github.com/contextgarden/context
wiki : https://wiki.contextgarden.net
___________________________________________________________________________________
next reply other threads:[~2025-02-04 17:05 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-02-04 16:59 Hans Hagen [this message]
2025-02-04 18:12 ` [NTG-context] " Rik Kabel
2025-02-04 20:12 ` Wolfgang Schuster
-- strict thread matches above, loose matches on Subject: below --
2024-06-18 20:15 [NTG-context] " Hans Hagen
2023-09-04 17:22 Hans Hagen
2023-08-15 17:08 Hans Hagen
2023-07-18 20:12 Hans Hagen
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=63efa3c9-1fe1-47ea-b076-e61222f4a8fc@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).