I have this code on my hard disk and now I would like to understand it. Firstly I would like to know if this code is correct and logic or if there is another way to do the same thing.
\documentclass{article}
\usepackage{fp}
\newcommand*\macro[2][]{%
Option : #1\par % print the option in #1
\let\y #2 % to keep
\begingroup
\catcode`\(=1
\catcode`\)=2
\macrobis
}
\newcommand*\macrobis[1]{%
\endgroup
\scantokens{\def\temp{#1}}}
\begin{document}
\def\fct{x*x}
\macro[op]{\fct}(exp(1))
\FPeval\x{\temp}%
\FPeval\img{\y}%
x = \x\ donne y = \img
\end{document}
\begingroup and \endgroup are here, I suppose, because the code changes the catcodes but tha call of macrobis is very strange. Where is the argument ?
Can someone explain this code?
(but why it's the last)that is used like a brace ? – Alain Matthes Dec 29 '11 at 17:54\macrobisis called, this is equivalent to write{exp{1}}so everything is balanced and the argument isexp(1)(TeX considers those as delimiters, but after\scantokensthey return to be as normal). – egreg Dec 29 '11 at 17:58