Tue, 1 Aug 2017 16:37:29 +0200
text/plain; charset=utf-8; format=flowed
> [Not sure whether this is a generic LaTeX 3 problem or specific to
> `fontspec' – however, I guess this question is of greater importance,
> thus writing to this list.]
I think it is neither but rather a general issue with TeX code, but as
you say it is important
the issue is that you can't execute code twice that is not meant to be
executed twice. So if you clone some code that contains such material
and you execute both the original and the new code (clone) you get
errors, either subtle ones or simple ones like "not allowed"
examples are from plain TeX things like \newwif from 2e stuff like
\newcommand and in l3 anything _new:... typically checks like
\newcommand if that is actually defining a free name
so running any such code twice gives you error messages and if it is
because of a newcommand then it will look like a 2e error and if it is
necause if \newif like a plain TeX error and if it happens to be due to
an expl3 construct like
then surprise :-) an L3 style error
but effectively they all say the same:
you asked me to generate something new but I see this is already there
The way packages guard against this problem is simply by making sure
that \usepackage or \RequirePackage will execute the external code only
once. This means you can't load a package with different option sets
(and we know that causes sometimes grief too) but on the whole that
works fairly well.
Of course it doesn't work if two different packages define the same
constructs and both use \newcommand or something similar
then the second package will bomb and if you change the order of loading
the other one will.
And normally this is a Good Thing (TM) as it signals that something
incompatible is happening
Now with the cloned code under a new name the situation is like that
only here package A is supposed to be replaced by package A-clone
So one way to achieve that is as Will pointed out to tell the world that
once package A-clone was loaded package A was loaded too.
And the mechanism for this is fairly simple: the loader looks in
and if that is \relax the it loads the file.
Otherwise it expects that this holds the "version" or rather the date of
the file (there are some macros dealing with different actions depending
on package dates).
\def\[log in to unmask]
you would claim that that package from that date was now loaded. Thus
libertine would not try to load it again.
It is in fact enough to make it anything other than \relax the date is
only useful if downstream there is any code that goes "do something
special if fontspec is older than X"
Maybe we should have a declaration
for the above but we don't (yet)
Note that all this is only necessary if it is likely that package A is
used inside other packages; with most packages that isn't really the
case so that variants may coexist nicely even if they can never be
loaded both (guess caption caption2/3/whathaveyou would be examples of this)
what else could you do?
depending on how much change/extension there is you could simply write a
and have the latter do
- require fontspec % now it is definitely loaded
- check if we are on xetex
- if so update the xetex related code as needed
- if not do nothing or complain that this is really for xetex and
otherwise not needed
I don't really see the need to clone fontspec and fontspec-xetex
especially given that fontspec does so little and you aren't really