\documentclass{article}
\usepackage{pstricks-add}
\usepackage{fp}
\def\newconst#1#2{%
\expandafter\FPeval\csname#1\endcsname{#2}%
\pstVerb{/#1 \csname#1\endcsname\space def}%
}
\begin{document}
% I want to define a macro that can only be invoked as below
%\newconst\speed{3*10^8}
% rather than
\newconst{speed}{3*10^8}
\end{document}
If I do as follows, then I have to remove the trailing \ in #1 before appending it to \pstVerb{/. How to do this?
\documentclass{article}
\usepackage{pstricks-add}
\usepackage{fp}
\def\newconst#1#2{%
\FPeval#1{#2}%
\pstVerb{/#1%<==== we must remove the trailing escape character \ in #1.
#1\space def}%
}
\begin{document}
% I want to invoke
%\newconst\speed{3*10^8}
% instead of
\newconst{speed}{3*10^8}
\end{document}
\newconstbshould take 2 arguments. Unfortunately, it does not work even with 2 arguments. I have no idea why. – kiss my armpit Jul 23 '12 at 16:39\newconstb\foo{abd}would be the same as\newconst{foo}{abc}as long as you don't need it in an expansion only context like \erite or \special. There is no need (and it is inefficient) to define a macro with an argument just to pass it on at the end of its expansion. – David Carlisle Jul 23 '12 at 17:43