On 1/31/2018 4:40 PM, Rik Kabel wrote:
On 2018-01-31 09:54, Wolfgang Schuster wrote:
Rik Kabel schrieb:
\starttexdefinition doTableRowExpB #SET \define\A{\getvariable{#SET}{a}} \define\B{\getvariable{#SET}{b}} \define\C{\getvariable{#SET}{c}} \bTR \expanded{\bTC\A\eTC} \expanded{\bTC\B\eTC} \expanded{\bTC\C\eTC} \eTR \stoptexdefinition
You can’t use \define but it creates non expandable commands (which can be solved when you use \defineexpandable instead) and there is no need for this extra step.
\starttexdefinition doTableRowExpB #SET \bTR \expanded{\bTC\getvariable{#SET}{a}\eTC} \expanded{\bTC\getvariable{#SET}{b}\eTC} \expanded{\bTC\getvariable{#SET}{c}\eTC} \eTR \stoptexdefinition
Wolfgang ___________________________________________________________________________________
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 ___________________________________________________________________________________
Great. This does the job, and allows assigning more semantically-meaningful names to the elements.
\starttexdefinition doTableRowExpB #SET \defineexpandable\A{\getvariable{#SET}{a}} \defineexpandable\B{\getvariable{#SET}{b}} \defineexpandable\C{\getvariable{#SET}{c}} \bTR \expanded{\bTC\A\eTC} \expanded{\bTC\B\eTC} \expanded{\bTC\C\eTC} \eTR \stoptexdefinition
I see no performance difference on a much larger test, and I think that the readability is improved (and thus the opportunity for simple mistakes) when the hundreds of \getvariable macros are refactored into a few macro definitions.
maybe the next can convince you then \starttexdefinition doTableRowExpB #SET \expanded {\bTR \bTC\getvariable{#SET}{a}\eTC \bTC\getvariable{#SET}{b}\eTC \bTC\getvariable{#SET}{c}\eTC \eTR} \stoptexdefinition with \starttexdefinition doTableRowExpB #SET \normalexpanded {\bTR \bTC\getvariable{#SET}{a}\eTC \bTC\getvariable{#SET}{b}\eTC \bTC\getvariable{#SET}{c}\eTC \eTR} \stoptexdefinition being a bit faster 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 -----------------------------------------------------------------