4

The doc for expl3 says: enter image description here

In the code below, pkgA and pkgB both define \@@_foo:, and pkgB relies on pkgA. I would have thought %<@@=module> would prevent this error:

ERROR: LaTeX3 Error: Control sequence \@@_foo: already defined.

Why isn't it the case?

pkgA:

% \iffalse meta-comment
% !TEX program  = pdfLaTeX
%<*internal> 
\iffalse
%</internal> 
%<*internal> 
\fi
\def\nameofplainTeX{plain}
\ifx\fmtname\nameofplainTeX\else
\expandafter\begingroup
\fi
%</internal> 
%<*install> 
\input docstrip.tex
\keepsilent
\askforoverwritefalse
\generate{
  \file{\jobname.sty}{\from{\jobname.dtx}{package}}
}
%</install> 
%<install> \endbatchfile
%<*internal> 
\generate{
  \file{\jobname.ins}{\from{\jobname.dtx}{install}}
}
\nopreamble\nopostamble
\ifx\fmtname\nameofplainTeX
\expandafter\endbatchfile
\else
\expandafter\endgroup
\fi
%</internal> 
%<package> \NeedsTeXFormat{LaTeX2e}[2020/02/02]
%<package> \RequirePackage{expl3}
%<package> \ProvidesExplPackage
%<package> {pkgA}                                                                                 % Package name
%<package> {2020/04/17}                                                                           % Release date
%<package> {1.0}                                                                                  % Release version
%<package> {pkgA --- template for dtx}                                                            % Description
% 
%<*driver> 
\documentclass[full]{l3doc}
\usepackage{pkgA}
\usepackage[T1]{fontenc}% \char`[
\EnableCrossrefs
\CodelineIndex
\RecordChanges
\begin{document}
\DocInput{\jobname.dtx}
\end{document}
%</driver> 
% \fi
% \GetFileInfo{\jobname.sty}
% \begin{documentation}
% \end{documentation}
% \begin{implementation}
%   \iffalse
%<*package>   
%   \fi
%<@@=pkgA>
%    \begin{macrocode}
\ExplSyntaxOn
\cs_new:Nn \@@_foo:{Hello, world!}
\ExplSyntaxOff
%    \end{macrocode}
% \end{implementation}
% 
% \iffalse
%</package> 
% \fi
% \Finale
\endinput

pkgB:

% \iffalse meta-comment
% !TEX program  = pdfLaTeX
%<*internal> 
\iffalse
%</internal> 
%<*internal> 
\fi
\def\nameofplainTeX{plain}
\ifx\fmtname\nameofplainTeX\else
\expandafter\begingroup
\fi
%</internal> 
%<*install> 
\input docstrip.tex
\keepsilent
\askforoverwritefalse
\generate{
  \file{\jobname.sty}{\from{\jobname.dtx}{package}}
}
%</install> 
%<install> \endbatchfile
%<*internal> 
\generate{
  \file{\jobname.ins}{\from{\jobname.dtx}{install}}
}
\nopreamble\nopostamble
\ifx\fmtname\nameofplainTeX
\expandafter\endbatchfile
\else
\expandafter\endgroup
\fi
%</internal> 
%<package> \NeedsTeXFormat{LaTeX2e}[2020/02/02]
%<package> \RequirePackage{pkgA}
%<package> \ProvidesExplPackage
%<package> {pkgB}                                                                                 % Package name
%<package> {2020/04/17}                                                                           % Release date
%<package> {1.0}                                                                                  % Release version
%<package> {pkgB --- template for dtx}                                                            % Description
% 
%<*driver> 
\documentclass[full]{l3doc}
\usepackage{pkgB}
\EnableCrossrefs
\CodelineIndex
\RecordChanges
\begin{document}
\DocInput{\jobname.dtx}
\end{document}
%</driver> 
% \fi
% \GetFileInfo{\jobname.sty}
% \begin{documentation}
% \end{documentation}
% \begin{implementation}
%   \iffalse
%<*package>   
%   \fi
%<@@=pkgB>
%    \begin{macrocode}
\ExplSyntaxOn
\cs_new:Nn \@@_foo:{Jello, world!}
\ExplSyntaxOff
%    \end{macrocode}
% \end{implementation}
% 
% \iffalse
%</package> 
% \fi
% \Finale
\endinput

1 Answer 1

8

The @@ syntax is a convention for setting up sources to make internal functions/variables both obvious and short. However, TeX itself doesn't 'know' about that, so if you do nothing else, you are actually calling your control sequence \@@_foo:. What you need to do is extract your .dtx file using l3docstrip, rather than 'vanilla' DocStrip. l3docstrip will replace @@ by the <module> and the appropriate internal prefix as it extracts code lines. So it would generate \__pkgA_foo: and \__pkgB_foo: in the .sty files here.

5
  • 1
    OK, so replace \input docstrip.tex by \input l3docstrip.tex? Yeah, it worked, thx.
    – Erwann
    May 20, 2020 at 8:59
  • @Erwann Yes, exactly: basically this ability is the difference between the two versions of DocStrip
    – Joseph Wright
    May 20, 2020 at 9:01
  • @JosephWright We could add an explicit sentence to the documentation that one can't use docstrip in the .ins file. (it is implicitly there but the "l3" is easily overlooked May 20, 2020 at 14:59
  • @FrankMittelbach Sure: I thought the fact it says 'l3docstrip' was enough, but perhaps not
    – Joseph Wright
    May 20, 2020 at 15:02
  • @JosephWright it wasn't this time :-) but I think it is easy to overlook, especially if you convert an existing setup that already as an .ins file -- it would hurt to add a sentence, I'll do it. May 20, 2020 at 19:42

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .