- make sure one can write the program from TeX

  Victor Eijkhout
  TeX by Topic
  http://www.cs.utk.edu/~eijkhout/texbytopic-letter.pdf
  Chapter 30

  \openout 0 \jobname.c
  \write 0 {int hello();}
  \closeout 0
  \end

- Now consider LaTeX, can we do the same?

  Yes. 

  1 \documentclass{article}
  2 \openout 0 \jobname.c
  3 \begin{document}
  4 ...
  5 \write 0 {int hello();}
  6 \closeout 0
  7 \end{document} 

- Annotating a paper into Latex form

- Now define some LaTeX macros to generate a colored annoated paper
  
\newcommand{\define}[1]{{\color{red} #1}}
\newcommand{\export}[1]{{\color{cyan} #1}}
\newcommand{\import}[1]{{\color{yellow} #1}}
\newcommand{\use}[1]{{\color{green} #1}}
\newcommand{\meta}[1]{\footnote{\color{red} #1}}

- Now refine these macros to generate a C program  
\newcommand{\printf}[1]{\write 0 {#1}}
\newcommand{\use}[2]{{\color{green} #1}\printf{#2}}
 - create method calls
\newcommand{\printf}[1]{\write 0 {    #1();}}
 -  using counters to create a unique name for the variables
\count1=0
\newcommand{\printf}[1]{\immediate\write 0 {struct #1 a\number\count1 ;}}
\newcommand{\use}[2]{\printf{#1}{\color{green} #2}\advance\count1 by 1 }
 - avoid having duplicate count when the \use macros are nested
\count1=0
\newcommand{\printf}[1]{ \advance\count1 by 1 
	\immediate\write 0 {struct #1 a\number\count1 ;}}
\newcommand{\use}[2]{\printf{#1}\color{green} #2}

- Naming conventions

\use{FooBar}{ foo bar, foo-bar, foo bars, ...}
FooBar must be a singular noun phrase.

When multiple concepts are used in one usage sentence, then
they should be declared in nested use clauses

\use{Foo}{\use{Bar}{ foo bar, foo-bar, foo bars, ...}}

- Do we need to make sure the file handle is closed only when \end 
  is encountered?
%\renewcommand{\end}{\closeout 0}

- Add switches \iflp and \iflpexplicit
iflp is true, then generate the colored typeset and generate code
otherwise do nothing
iflpexplicit is true, then generate footnotes of the markuped concepts
