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
___________________________________________________________________________________