LATEX-L Archives

Mailing list for the LaTeX3 project

LATEX-L@LISTSERV.UNI-HEIDELBERG.DE

Options: Use Classic View

Use Monospaced Font
Show HTML Part by Default
Condense Mail Headers

Topic: [<< First] [< Prev] [Next >] [Last >>]

Print Reply
Content-Type: text/plain; charset="us-ascii"
Date: Sun, 5 Mar 2006 16:36:22 +0100
Content-Disposition: inline
Reply-To: Mailing list for the LaTeX3 project <[log in to unmask]>
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Sender: Mailing list for the LaTeX3 project <[log in to unmask]>
From: Philipp Lehman <[log in to unmask]>
Parts/Attachments: text/plain (43 lines)
Here's a suggestion for a poor man's "namespace" protection with 
Latex. I figured I'd post it here before filing it as a feature 
suggestion.

When writing a class or a package, it's not feasible to use 
\newcommand all over the place. What most authors do is pick a prefix 
and hope for the best. So the foobar package might use internal 
macros like \fb@foo and \fb@bar while the barfoo package would use 
\bf@foo etc. If there is a conflict, things will likely go wrong in 
ways which are not transparent to the end-user.

How about having something like the following in the kernel:

\def\ReserveNamespace#1#2{%
  \@ifundefined{ltx@resrvd@#1}
    {\@namedef{ltx@resrvd@#1}{#2}}
    {\@latex@error
      {Namespace `#1' already reserved by `\@nameuse{ltx@resrvd@#1}'}
      {The namespace `#1', claimed by `#2', has already
       been reserved by `\@nameuse{ltx@[log in to unmask]
\ReserveNamespace{ltx}{LaTeX}

This will permit class/package authors do do the following:

\ReserveNamespace{FB}{foobar}
\def\FB@foo{...}
\newif\ifFB@bar
\newcount\FB@cnt

...giving them namespace protection comparable to \newcommand, but in 
a much more efficient and general way. It may also be worthwhile to 
integrate that into \ProvidesClass and \ProvidesPackage:

\ProvidesPackage[FB]{foobar}[2006/03/05 v1.0 The foobar package]
\def\FB@foo{...}
\newif\ifFB@bar
\newcount\FB@cnt

That's probably only relevant for Latex 3...

-- 
Philipp Lehman <[log in to unmask]>

ATOM RSS1 RSS2