From 178de9556e3cb519672f9b54db7b5b29eec43c69 Mon Sep 17 00:00:00 2001 From: Hans Hagen Date: Fri, 5 Aug 2022 17:44:39 +0200 Subject: 2022-08-05 17:17:00 --- doc/context/documents/general/manuals/onandon.pdf | Bin 6602776 -> 2757973 bytes .../general/manuals/onandon/onandon-expansion.tex | 72 +++++++++++++++++++-- .../general/manuals/onandon/onandon-fences.tex | 5 ++ .../sources/general/manuals/onandon/onandon.tex | 2 +- 4 files changed, 71 insertions(+), 8 deletions(-) (limited to 'doc/context') diff --git a/doc/context/documents/general/manuals/onandon.pdf b/doc/context/documents/general/manuals/onandon.pdf index 029f83609..e9c6930b5 100644 Binary files a/doc/context/documents/general/manuals/onandon.pdf and b/doc/context/documents/general/manuals/onandon.pdf differ diff --git a/doc/context/sources/general/manuals/onandon/onandon-expansion.tex b/doc/context/sources/general/manuals/onandon/onandon-expansion.tex index e20d7e192..a25b75246 100644 --- a/doc/context/sources/general/manuals/onandon/onandon-expansion.tex +++ b/doc/context/sources/general/manuals/onandon/onandon-expansion.tex @@ -75,6 +75,11 @@ the other with user defined conditions. The first one relates directly to expansion, the second one concerns conditions and relates more to parsing branches which on purpose avoids expansion. +{\em In the meantime \LUAMETATEX\ has a slightly different implementation which +goes under the umbrella \quote {local control}. We show both ways here. The +example where two token lists are compared can be done easier with \type +{\iftok}.} + For the first one I use some silly examples. I must admit that although I can envision useful application, I really need to go over the large amount of \CONTEXT\ source code to really find a place where it is making things better. @@ -106,8 +111,14 @@ preventing look ahead interference by using a space or \tex {relax} (often an expression works better as it doesn't leave an \tex {relax}). \startbuffer +% luatex + \def\TestMe{\immediateassignment\advance\NumberOfCalls1 } +% luametatex + +\def\TestMe{\localcontrolled{\advance\NumberOfCalls1 }} + \edef\Tested{\TestMe bar:\the\NumberOfCalls} \edef\Tested{\TestMe bar:\the\NumberOfCalls} \edef\Tested{\TestMe bar:\the\NumberOfCalls} @@ -126,7 +137,9 @@ Here is a somewhat silly example of an expanded comparison of two \quote {strings}: \startbuffer -\def\expandeddoifelse#1#2#3#4% +% luatex + +\def\ExpandedDoifElse#1#2#3#4% {\immediateassignment\edef\tempa{#1}% \immediateassignment\edef\tempb{#2}% \ifx\tempa\tempb @@ -136,9 +149,21 @@ Here is a somewhat silly example of an expanded comparison of two \quote \fi \next} +% luametatex + +\def\ExpandedDoifElse#1#2#3#4% + {\localcontrolled{\edef\tempa{#1}}% + \localcontrolled{\edef\tempb{#2}}% + \ifx\tempa\tempb + \localcontrolled{\def\next{#3}}% + \else + \localcontrolled{\def\next{#4}}% + \fi + \next} + \edef\Tested - {(\expandeddoifelse{abc}{def}{yes}{nop}/% - \expandeddoifelse{abc}{abc}{yes}{nop})} + {(\ExpandedDoifElse{abc}{def}{yes}{nop}/% + \ExpandedDoifElse{abc}{abc}{yes}{nop})} \meaning\Tested \stopbuffer @@ -162,7 +187,9 @@ In addition to this one|-|time immediate assignment a pseudo token list variant is provided, so the above could be rewritten to: \starttyping -\def\expandeddoifelse#1#2#3#4% +% luatex + +\def\ExpandedDoifElse#1#2#3#4% {\immediateassigned { \edef\tempa{#1} \edef\tempb{#2} @@ -173,6 +200,20 @@ is provided, so the above could be rewritten to: \immediateassignment\def\next{#4}% \fi \next} + +% luametatex + +\def\ExpandedDoifElse#1#2#3#4% + {\beginlocalcontrol + \edef\tempa{#1} + \edef\tempb{#2} + \endlocalcontrol + \ifx\tempa\tempb + \localcontrolled{\def\next{#3}}% + \else + \localcontrolled{\def\next{#4}}% + \fi + \next} \stoptyping While \tex {expanded} first builds a token lists that then gets used, the \tex @@ -261,18 +302,35 @@ previously mentioned immediate assignment. Here is another example: The previously defined comparison macro can now be rewritten as: \starttyping -\def\equaltokens#1#2% +% luatex + +\def\EqualTokens#1#2% {\immediateassignment\edef\tempa{#1}% \immediateassignment\edef\tempb{#2}% \ifx\tempa\tempb} -\def\expandeddoifelse#1#2#3#4% - {\ifcondition\equaltokens{#1}{#2}% +\def\ExpandedDoifElse#1#2#3#4% + {\ifcondition\EqualTokens{#1}{#2}% \immediateassignment\def\next{#3}% \else \immediateassignment\def\next{#4}% \fi \next} + +% luametatex + +\def\EqualTokens#1#2% + {\localcontrolled{\edef\tempa{#1}}% + \localcontrolled{\edef\tempb{#2}}% + \ifx\tempa\tempb} + +\def\ExpandedDoifElse#1#2#3#4% + {\ifcondition\EqualTokens{#1}{#2}% + \localcontrolled{\def\next{#3}}% + \else + \localcontrolled{\def\next{#4}}% + \fi + \next} \stoptyping When used this way it will of course also work without the \tex {ifcondition} but diff --git a/doc/context/sources/general/manuals/onandon/onandon-fences.tex b/doc/context/sources/general/manuals/onandon/onandon-fences.tex index ff50ebe5e..76ade938e 100644 --- a/doc/context/sources/general/manuals/onandon/onandon-fences.tex +++ b/doc/context/sources/general/manuals/onandon/onandon-fences.tex @@ -1,5 +1,10 @@ % language=us +% This feature has been removed because we have different control now in the +% reworked engine so this chapter cnanot be processed any longer. + +\endinput + \startcomponent onandon-fences \environment onandon-environment diff --git a/doc/context/sources/general/manuals/onandon/onandon.tex b/doc/context/sources/general/manuals/onandon/onandon.tex index 3b6f22cf9..7ea81205d 100644 --- a/doc/context/sources/general/manuals/onandon/onandon.tex +++ b/doc/context/sources/general/manuals/onandon/onandon.tex @@ -39,7 +39,7 @@ \component onandon-emoji \component onandon-performance \component onandon-editing - \component onandon-fences % first published in user group magazines + % \component onandon-fences % first published in user group magazines / obsolete \component onandon-media \component onandon-53 % first published in user group magazines \component onandon-execute % first published in user group magazines -- cgit v1.2.3