On 25/08/2009, at 4:23 PM, Frank Mittelbach wrote: > I think some of the problem here lies in the fact that you all think > of xparse > as a bunch of TeX macros providing a single solution. Don't. *click* Aha! > This is why I would think that separating the two is key. There is > (and can > be) a single interface to declare a layer 0 command. And for each > such command > there is an interface declaration for each layer -1 (but how that > interface > decl is done might differ from layer -1 to layer -1). [...] > The big open question for me is to describe what the language at > layer 0 > really looks like. Now I understand you completely. (I hope.) We want to describe every document element in terms of a template instance. (I know you mentioned the other day that "template instance" isn't strictly true but I don't feel that the word "instance" on its own carries enough weight.) Using your example, an arbitrary section header becomes converted into \UseInstance {sectioning} {section} {#1} {#2} Correct me if I'm wrong: (a) The template type defines the mandatory number of arguments required by each instance (b) Each variation on a command (say, the different between \section and \section*) will be handled by a separate instance Isn't layer 0, in these terms, simply a list of template types and instances allowed in the document? ((Late addition: Now that I read over what I've written, I suppose that some sort of hierarchy could be imposed as well. That makes things more complicated.)) A description for layer 0 might then look (very hypothetically) like \begin{DefineClassTypes}{book3} \InheritTypes{ paragraph-shapes, cross-references, breqn-support, % I don't know what I'm writing here, really. % Just trying to imply that you might want to base classes off other classes % or based off simply functionality that belongs only in many classes. } \TemplateTypeWithInstances{sectioning}{ front-matter-division, chapter, appendix, numbered-section, unnumbered-section, % No other instances than these are allowed! % The instances themselves are defined in layer 1. } \TemplateTypeWithInstances{text-lists}{ itemize, enumerate, description, % Ditto. } \end{DefineClassTypes} * * * Any layer -1 interface would then provide tools to convert whatever input there is into instances defined as above. So, xparse2e would contain \DeclareDocumentCommand\section{som}{% \ifBoolean #1 { \UseInstance{sectioning}{numbered-section} {#2} {#3} }{ \UseInstance{sectioning}{unnumbered-section} {#2} {#3} } } I can't really see how this could be abstracted any more, but that might be a lack of imagination on my part. Must run, Will