In the question it is written:
This behavior of \csname defined control sequence (that is expanding to \relax when undefined) is really handy but sometimes I'd like to deactivate it and maybe issue an Undefined control sequence error. Is it possible?
\csname is used for obtaining a control sequence token from a sequence of tokens that at some stage of expansion yield a sequence of character tokens representing the name of the control sequence token in question. In case the control sequence token in question was undefined when applying
\csname, it will get assigned the meaning of the
\relax-primitive. (That assignment is restricted to the current scope even if the
\globaldefs-parameter has a positive value.)
Thus in this case, the
\csname-defined control sequence does not get expanded to
\relax. It does not get expanded at all as it is not expandable as it has the same meaning as the
\relax-primitive which is not an expandable token.
"Hitting" unexpandable tokens with
\expandafter does not affect these tokens.
\expandafter itself is expandable. All expansion takes place in TeX' mouth. Therefore processing
\expandafter will take place in TeX' mouth. Unexpandable tokens are not affected by that. They reach the stomach of TeX.
\mymacro@i is expected to be delimited by the control word token
\foo while the first
\expandafter-chain from the expansion of
\csname which in turn delivers the unexpandable control word token
\/test/ whose meaning equals the meaning of the unexpandable
\relax-primitive. That unexpandable control word token is not affected when being "hit" by the second
By the way 1: With delimited arguments usually the argument delimiting tokens get removed when TeX is gathering the arguments. Therefore in relation to gathering arguments, the meanings of argument delimiting tokens don't matter. You can even happily use tokens that are undefined as argument delimiters.
By the way 2: Don't use the minimal class for minimal examples. Use the article class instead.
The minimal class was written by the developers of the LaTeX2e-package for testing the class loading mechanism of the LaTeX2e-package.