I am fond of the TeX macro language. I would like to take from TeX only the macro capabilities, that is, the expansion process, the \catcode, \def, \let, \expandafter etc., but I'm not interested in the typesetting output. In other words, I don't need the \hbox, the output routine, the glues, the pdf output etc. I need only text characters at the end of the process, which would be output in a text file.
To put flesh on bones, let me give an example:
\def\foo{hello world\ }
\let\foob=\foo
\expandafter\def\csname foo3\endcsname {hello everybody}
\foo \foob \csname foo3\endcsname
\end
The above program would output "hello world hello world hello everybody" in a text file.
What is the simplest way to obtain the desired result? I guess one has to cut Knuth's program just after it has totally expanded the tokens, and before it transforms them to typeset output.
\let\foo2=\foo
would assign\foo
to be2
and then typeset=2
is that what you want here, also you define a command with namefoo3
but never call it.\foo3
is the same as\foo 3
! Undefined control sequence \encsname
your test gives this output in plain tex