The old timers in the LaTeX 3 Team must have been missing their @@ when the l3doc name spacing convention for internal macros was introduced.

But at least now we have a reasonable name spacing scheme by convention that is a step nearer to encapsulation of package code. Personally I think this is one of the greatest ideas implemented in LaTeX 3.

Some languages such as Go namespace based on directories, e.g.,

package main

   import "fmt"
   import "golang-book/chapter11/math"

   func main() {
     xs := []float64{1,2,3,4}
     avg := math.Average(xs)

Two small modifications in l3docstrip and l3doc make it easy to set the module name from the \jobname

        \noexpand\replaceAllIn\noexpand\inLine{@@@@}{\string aa}%
        \noexpand\replaceAllIn\noexpand\inLine{\string aa}{@@}%

Similarly code in l3doc can be changed like:

     \tl_replace_all:Nnn #1 { _ _ @ @ } { _ _ \jobname }

The !@@ construction is a hack to be able to say:


and get:


for functions that one might want to export in a programming API (like for example the l3 \keys_define:nn).

In the actual package there will be no need for a guard <@@=module> but only for guards <@@=> where one might want to skip the name space.

The idea can easily be extended now that we have most of the tools to extend this to \RequirePackage and \usepackage if one wants to adopt a scheme similar to Golang's based on paths. This will also have the advantage that all packages in one directory like for example l3draw to name space all files with the same prefix.

Do you think this is a good idea? What can it break? How can it be improved?

  • This sounds more like a discussion but ... – Joseph Wright Jan 5 at 20:08
  • 1
    ... aren't you assuming that the module name is linked to the file name? Have you seen for example l3basics? – Joseph Wright Jan 5 at 20:08
  • @JosephWright Yes it has to be more like a discussion. I have read through l3basics and understand well how things work at present, but please see the Golang example above as to how the name spacing is using the filename to namespace, but the path for loading, so you can have multiple math.go packages. – Yiannis Lazarides Jan 5 at 20:13
  • Also, the reason that @@ doesn't apply to the public API is so that in the sources it's easy to spot 'internal' usage. – Joseph Wright Jan 5 at 20:14
  • 1
    The file names contain numbers and so don't work in command names. – Ulrike Fischer Jan 5 at 20:18

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.