Hi, a new upload - some keywords renamed in the engine and therefore more split between mkiv and lmtx (hopefully i included all files) .. if something doesn't work any more it might be because i missed a rename. - i finally decied that it does make sense to have native loops at the primitive level (after all, metapost as macro language also has them) and although much is possible in macros it doesn't mean we have to do it the (often ugly and showing-off-by-abusing-side-effects way). We have just a constructor: \unexpandedloop 1 100 1 {.} and a fully expandable one for e.g. use in \edef: \expandedloop 1 100 1 {.} plus an also fully expandable one for anywhere but with potential side effects (out of order local loops): \localcontrolledloop 1 100 1 {.} complemented by a few status primitives (integers, use \the or \number to serialize them): \currentloopiterator \currentloopnesting and a quitter that aborts at the next iteration: \quitloop as usual it's experimental for a while. Among the rationales are 'less tracing clutter', 'performance' and 'more natural primitive tex coding' (but that one is personal). 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 -----------------------------------------------------------------
Hi, Hans. I've got a question. Negative steps are treated as positive: \starttext \expandedloop 10 0 -2 {\the\currentloopiterator\ } \stoptext gives 0 2 4 6 8 10 Is this expected behavior? If so, it would be fine to have something more alike to MetaPost's "for ... step ... until" loop. Thank you in advance. Regards, Jairo El vie, 3 dic 2021 a la(s) 09:29, Hans Hagen via ntg-context ( ntg-context@ntg.nl) escribió:
Hi,
a new upload
- some keywords renamed in the engine and therefore more split between mkiv and lmtx (hopefully i included all files) .. if something doesn't work any more it might be because i missed a rename.
- i finally decied that it does make sense to have native loops at the primitive level (after all, metapost as macro language also has them) and although much is possible in macros it doesn't mean we have to do it the (often ugly and showing-off-by-abusing-side-effects way).
We have just a constructor:
\unexpandedloop 1 100 1 {.}
and a fully expandable one for e.g. use in \edef:
\expandedloop 1 100 1 {.}
plus an also fully expandable one for anywhere but with potential side effects (out of order local loops):
\localcontrolledloop 1 100 1 {.}
complemented by a few status primitives (integers, use \the or \number to serialize them):
\currentloopiterator \currentloopnesting
and a quitter that aborts at the next iteration:
\quitloop
as usual it's experimental for a while. Among the rationales are 'less tracing clutter', 'performance' and 'more natural primitive tex coding' (but that one is personal).
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
___________________________________________________________________________________
On 12/6/2021 5:41 AM, Jairo A. del Rio via ntg-context wrote:
Hi, Hans. I've got a question. Negative steps are treated as positive:
\starttext \expandedloop 10 0 -2 {\the\currentloopiterator\ } \stoptext
gives
0 2 4 6 8 10
Is this expected behavior? If so, it would be fine to have something more alike to MetaPost's "for ... step ... until" loop. Thank you in advance. already fixed here but no upload for a few days
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 -----------------------------------------------------------------
participants (2)
-
Hans Hagen
-
Jairo A. del Rio