# help understanding a definition in custom class

Can someone help with decoding the code at the bottom? Note that the code is part of a custom class for dissertation that i found.

Specifically: \def\@degreeyear{#1}\if@cyrset\else\def\@copyrightyear{#1}\fi

1. Can someone explain step by step what this line does?
2. What is the purpose of \if@cyrset when this is always be false why not just \def\@degreeyear{#1}\def\@copyrightyear{#1}\fi even though I still have no idea what this is supposed to do?
3. Why is \def\@degreeyear{\number\month} as month?
4. and why is \@degreeyear defined twice? (The author says in a comment that when \degreeyear is not used, current year is used. But even if \def\@degreeyear{\number\year} was used, I still do not see the conditional logic).
5. In general where does \def ends definition (space possibly?)?

The code:

\def\@degreeyear{\number\month}
\def\@degreemonth{\ifcase\month\or
January\or February\or March\or April\or May\or June\or
July\or August\or September\or October\or November\or December\fi}
\newif\if@cyrset
\@cyrsetfalse
\newcommand{\degreeyear}[1]
\newcommand{\degreemonth}[1]{\def\@degreemonth{#1}}


The class defines a default value for \@degreeyear, \@degreemonth and \@copyrightyear. I'm not sure why \@degreeyear has \number\month instead of the expected \number\year, probable oversight.

Then it defines a conditional to distinguish whether the copyright year is being set by the user and proceeds to define user level commands for setting dates.

If the user has

\degreeyear{2020}


then the macro \@degreeyear is defined to expand to 2020. The value of \@copyrightyear is not changed unless \if@cyrset is false.

If the user has

\copyrightyear{2019}


then \@copyrightyear is set to 2019 and \if@cyrset is set to true.

The \def commands inside the replacement text for \newcommand{\degreeyear} are not performed when the definition is absorbed, but only when \degreeyear is executed.

The effect is that issuing the commands in either order will always do the right thing. Not issuing \copyrightyear will set \@copyrightyear to the same value as \@degreeyear.

Let's see why. At the end of class loading, \if@cyrset returns the false branch. I'll assume that at least \degreeyear{2020} appears in the document preamble. There are three cases:

1. just \degreeyear{2020}
2. \degreeyear{2020}\copyrightyear{2019}
3. \copyrightyear{2020}\degreeyear{2020}

In the first case \@degreeyear and \@copyrightyear are both set to 2020.

In the second case, \degreeyear{2020} does as in case 1, but the later \copyrightyear{2019} command overwrites the value previously assigned to \@copyrightyear. The \@cyrsettrue bit does nothing.

In the third case, \@copyrightyear is set to 2019 and \if@cyrset is set to return the true branch. Thus \degreeyear{2020} will only set \@degreeyear and skip the setting to \@copyrightyear.

This is done in order to avoid requiring the user to specify \degreeyear and \copyrightyear in a particular order. The latter command is optional, because if not given the setting of \@copyrightyear will be the same as that of \@degreeyear.

The @-macros will presumably be used by the class to typeset the title pages.

• So the line \@cyrsetfalse is "executed" when the class is loaded, that is before anything else and then if one also has in the preamble \copyrightyear{2019} only then \def\@copyrightyear{#1}\@cyrsettrue is "executed"? Mar 3 '20 at 17:48
• @leosenko Yes, at the end of class loading \if@cyrset is false. But executing \copyrightyear in the preamble sets it to true. I'll add something. Mar 3 '20 at 18:03