# Reserved names in “declare function”?

This must be my week for stepping on reserved words... please look at this MWE:

\documentclass{article}
\usepackage{tikz}

\newcommand{\formula}[1]{%
\pgfmathsetmacro{\rpval}{#1}%
\pgfmathprintnumberto[assume math mode=true, fixed, precision=3]{\rpval}{\frpval}%
\frpval
}
\begin{document}
\tikzset{declare function={%
R0 = 2.0;
X = 0.5*R0;
ON = 3;
OFF(\x) = \x + 1;
AFF(\x) = \x + 1;
}}

%  works
X is \formula{X}

% fails
ON is \formula{ON}

% works
AFF is \formula{AFF(1)}

% fails
OFF is \formula{OFF(1)}
\end{document}


The second and fourth line fail with

! Package PGF Math Error: Unknown operator O' or ON' (in 'ON').

! Package PGF Math Error: Unknown operator O' or OF' (in 'OFF(1)').



...and it seems it is doing the same for every constant starting with O are creating problems.

I think I am doing something very silly...

• It doesn't have to start with O. All of ONN, NON and NNO fail... – Phelype Oleinik Dec 2 at 19:47
• ...lowercase o works... – Rmano Dec 2 at 19:54

Update: This has been fixed and your document should work fine after the next TikZ/PGF release.

In pgfmathparser.code.tex you see:

\pgfmath@tokens@make{functional}{_abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNPQRSTUVWXYZ}


without an O.

O doesn't seem to be a reserved keyword (after all, you get an “Unknown operator” error), thus I believe this is a bug.

Providing the missing definition:

\makeatletter
\def\pgfmath@token@functional@O{O}
\makeatother


seems to solve the problem.

I just find it curious that you are the first person to try to use an O there :-)