# [luatex] tex.enableprimitives producing non-primitives?

Heiko Oberdiek oberdiek at uni-freiburg.de
Wed Sep 23 12:34:32 CEST 2009

On Wed, Sep 23, 2009 at 12:30:40PM +0300, Élie Roux wrote:

> 2009/9/23 Heiko Oberdiek <oberdiek at uni-freiburg.de>:
> >
> >> it says "Missing primitive name on l7". Is it normal ?
> >
> > Afaik yes.
>
> Ok, so it should not be a primitive...

The error message says "primitive *name*". How does \pdfprimitive know,
which primitive meaning you want from the following control sequence?

> >> This behaviour
> >> looks strange to me, as testprefixattribute should be a primitive...
> >
> > Yes, but that doesn't matter.
>
> Hmmm now you say that it should be one... I don't really understand...

The control sequence after \pdfprimitive is a control sequence with
the name of a primitive, regardless of the current meaning of
this control sequence.

\def\hbox{I am not an \string\hbox}
\pdfprimitive\hbox{This is an \string\hbox again}
\footnote{BTW, what is correct English: "a hbox" or "an hbox"?}

> > it needs the original primitive name.
> > The purpose is, to get the primitive meaning, even if the command
> > is redefined later as macro or whatever, e.g. after
> >
> >  \let\attribute\hbox
> >  \pdfprimitive\attribute
> >
> > you get the original meaning of \attribute, not a \hbox.
>
> I know, but in TeXLive 2009, attribute does not exist for LaTeX (like
> other luatex-specific promitives), so you cannot say
> \pdfprimitive\attribute.

It is irrelevant, which format you use. The question is, whether the
TeX engine knows the *primitive* \attribute. For example, pdfTeX
does not know the primitive \attribute, thus you get an error.
However, luaTeX knows it, thus it will work there.

> What I wanted is to do the same with
> luatexattribute, which is the only "primitive" (I still don't know if
> it's one or not) available in TeXLive 2009 for LaTeX...

Thus your real question is, that you want to know, whether the
TeX engine does provide the primitive in question, even if the
control sequence is redefined?

AFAIK, there is no easy way:
* \pdfprimitive throws an error, if the control sequence is not
primitive name.
* Even without an error \pdfprimitive does not allow you to save
the primitive meaning to another control sequence. Thus you could not
check, whether \pdfprimitve was successful without looking at the
side effects of executing the primitive in question.
* \ifpdfprimitive is just a shortcut for testing a control sequence,
whether it has its primitive meaning. \ifpdfprimitive can be replaced
at macro level via \meaning and a expandable string comparison.

Therefore I think, you need some kind of heuristic to find the
primitive:
* Check for LuaTeX and its tex.enableprimitives and check the
result, whether the control sequence has the meaning of the
wanted primitive.
* Check for engines and versions.
* Try out various names of probable candidates.

Yours sincerely
Heiko <oberdiek at uni-freiburg.de>