
\newcommand{\cvar}[1]{\textrm{\textit{#1}}}

%%%%%%%%%%%%%%%% Latex prototypes
\texonly

\newcommand{\evalsto}{$\rightarrow$}

\newenvironment{protos}{\list{$\bullet$}
{\leftmargin1.2em\rightmargin0pt\itemsep0pt\parsep0pt\partopsep-2pt}}
{\endlist}

% The following is for prototypes that have return types.
%    (foo int int) -> int

\newcommand{\proto}[3]{%
\protonoindex{#1}{#2}{#3}%
\mainschindex{#1}}%

\newcommand{\protonoindex}[3]{\item\noindent\unskip%
\hbox{\spaceskip=0.5em\code{({#1}{\it#2\/})} {$\rightarrow$} {\it#3}}}

\newcommand{\cproto}[1]{\item\noindent\unskip%
\hbox{\spaceskip=0.5em\code{{#1}}}}

\newcommand{\cgcproto}[1]{\item\noindent\unskip%
\hbox{\spaceskip=0.5em\code{{#1}}}\hfill\penalty 0%
\hbox{ }\nobreak\hfill\hbox{\rm (may GC)}}

\newcommand{\protonoresultnoindex}[2]{\item\noindent\unskip%
\hbox{\spaceskip=0.5em\code{(\hbox{#1}{\it#2\/})}}}

\newcommand{\protonoresult}[2]{%
\protonoresultnoindex{#1}{#2}%
\mainschindex{#1}}%

\newcommand{\protoresult}[1]{\newline\unskip%
{\hspace*{2em}\code{{$\rightarrow$} {\it#1}}\hfill}}

% Syntax prototypes

\newcommand{\syntaxprotonoresultnoindex}[2]{\item\noindent\unskip%
\hbox{\spaceskip=0.5em\code{(\hbox{#1}{#2})}}\hfill\penalty 0%
\hbox{ }\nobreak\hfill\hbox{\rm syntax}}

\newcommand{\syntaxprotonoresult}[2]{%
\syntaxprotonoresultnoindex{#1}{#2}\mainschindex{#1}}

\newcommand{\syntaxproto}[3]{\item\noindent\unskip%
\hbox{\spaceskip=0.5em\code{(\hbox{#1}{#2})}} {$\rightarrow$} {\it#3}%
\hfill\penalty 0%
\hbox{ }\nobreak\hfill\hbox{\rm syntax}}

% This can be reduced

\newcommand{\pconstproto}[2]{\item\noindent\unskip%
\hbox{\spaceskip=0.5em\code{#1}}\hfill\penalty 0%
\hbox{ }\nobreak\hfill\hbox{\rm #2}}

% Variable prototype
\newcommand{\constproto}[2]{\pconstproto{#1}{#2}\mainschindex{#1}}

\newcommand{\constprotonoindex}[2]{\pconstproto{#1}{#2}}

\endtexonly

%%%%%%%%%%%%%%%% end of Latex proto definitions

%%%%%%%%%%%%%%%% HTML prototypes
\htmlonly

\newcommand{\evalsto}{\verb| => |}

\newenvironment{protos}{\begin{itemize}}{\end{itemize}}

% The following is for prototypes that have return types.
%    (foo int int) -> int

\newcommand{\protonoindex}[3]{%
%\cindex{\code{#1}}%
\item\noindent\code{({#1}{\var{#2}\/})~-->~{\var{#3}}}}

\newcommand{\proto}[3]{%
\protonoindex{#1}{#2}{#3}%
\mainschindex{#1}}%

\newcommand{\protonoresultnoindex}[2]{%
%\cindex{\code{#1}}%
\item\noindent\code{({#1}{\var{#2}\/})}}

\newcommand{\protonoresult}[2]{%
\protonoresultnoindex{#1}{#2}%
\mainschindex{#1}}%

\newcommand{\pconstproto}[2]{%
\item\noindent\code{{#1}}\prototag{#2}}

% Variable prototype
\newcommand{\constproto}[2]{\pconstproto{#1}{#2}\mainschindex{#1}}

\newcommand{\constprotonoindex}[2]{\pconstproto{#1}{#2}}

\newcommand{\cproto}[1]{%
\item\noindent\code{{#1}}}

\newcommand{\cgcproto}[1]{%
\item\noindent\code{{#1}}\prototag{may GC}}

\newcommand{\syntaxprotonoresult}[2]{%
\syntaxprotonoresultnoindex{#1}{#2}\mainschindex{#1}}

\newcommand{\syntaxprotonoresultnoindex}[2]{%
\item\noindent\code{({#1}{#2})}\prototag{syntax}}

\newcommand{\protoresult}[1]{%
\\{}\noindent\code{\ \ \ \ -->~{\it{#1}}}}

\newcommand{\syntaxproto}[3]{%
\item\noindent\code{({#1}{#2})~-->~{\var{#3}}}\prototag{syntax}}

\newcommand{\prototag}[1]{\hfill\hbox{(#1)}}

\endhtmlonly
%%%%%%%%%%%%%%%% end of HTML proto definitions
