On Thu, 5 Mar 2009, Aditya Mahajan wrote:

On Thu, 5 Mar 2009, luigi scarso wrote:

On Thu, Mar 5, 2009 at 12:09 PM, Wolfgang Schuster
<schuster.wolfg...@googlemail.com> wrote:

Am 05.03.2009 um 01:17 schrieb luigi scarso:

\starttext
%%% TeX version
\bTABLE
\dorecurse{5}
{\bTR\expandafter \bTD \recurselevel. \eTD\expandafter
       \bTD \recurselevel  \eTD\eTR}
\eTABLE

\dorecurse{2}
{\recurselevel. \recurselevel\crlf}

And you think it's a good idea to use \expandafter in your document?
TeX  version, not context ... :)
btw
\expandafer is not so bad, if used moderatly .


\expanded is the tool for users to get this result without knowledge
about TeX internals and expansion, this is from core-ntb:

% permits \expanded{\bTD ... \eTD}

\unexpanded\def\eTR{}
\unexpanded\def\eTD{}
\unexpanded\def\eTH{}
\unexpanded\def\eTN{}
yes, of course one need to know about \expandafter... so is not so different .
But it's context style.


%%% luatex version
\startluacode
  tprint = function(s) tex.sprint(tex.ctxcatcodes,s) end
  tprint('\\bTABLE')
  for j = 1,5 do
      tprint('\\bTR')
      tprint('\\bTD' .. j .. '.' .. '\\eTD' .. '\\bTD' .. j .. '\\eTD')
      tprint('\\eTR')
  end
  tprint('\\eTABLE')
\stopluacode
\stoptext

Nice solution and real alternative for package writers to avoid \expandafter and \expanded but nothing for a normal user, I should keep this in my mind.
Are you sure ?
What is a normal user ?
As soon as you use \dorecurse , you become a programmer .

And sooner or later, everyone become a programmer, because it's
impossible to write a format that satisfied
all your needs .

My summary of this thread:
http://randomdeterminism.wordpress.com/2009/03/05/tex-programming-the-past-the-present-and-the-future/

For fun: Using metapost

\setupcolors[state=start]
\setupTABLE[each][each][width=2em,height=2em,align={middle,middle}]
\setupTABLE[r][1][background=color,backgroundcolor=gray]
\setupTABLE[c][1][background=color,backgroundcolor=gray]

\let\normalbTABLE\bTABLE
\let\normaleTABLE\eTABLE

\unexpanded\def\bTABLE{\normalbTABLE}
\unexpanded\def\eTABLE{\normaleTABLE}

\unexpanded\def\dobTR{\dodoubleempty\parseTR}
\unexpanded\def\dobTD{\dodoubleempty\parseTD}
\unexpanded\def\dobTH{\dodoubleempty\parseTH}
\unexpanded\def\dobTN{\dodoubleempty\parseTN}

\let\bTR\dobTR
\let\bTD\dobTD
\let\bTH\dobTH
\let\bTN\dobTN

\starttext

\startMPcode
  string table ;
  table = "\bTABLE \bTR \bTD $(+)$ \eTD" &
    for y = 1 upto 6 :
      "\bTD " & decimal y & "\eTD " &
    endfor
    "\eTR " &
    for x = 1 upto 6 :
      "\bTR \bTD " & decimal x & "\eTD " &
      for y = 1 upto 6 :
       "\bTD " & decimal (x+y) & "\eTD " &
      endfor
      "\eTR" &
    endfor
    "\eTABLE" ;
  label(textext(table), origin) ;
\stopMPcode

\stoptext

Aditya
___________________________________________________________________________________
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://tex.aanhet.net
archive  : https://foundry.supelec.fr/projects/contextrev/
wiki     : http://contextgarden.net
___________________________________________________________________________________

Reply via email to