LATEX-L Archives

Mailing list for the LaTeX3 project

LATEX-L@LISTSERV.UNI-HEIDELBERG.DE

Options: Use Forum View

Use Monospaced Font
Show Text Part by Default
Show All Mail Headers

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

Print Reply
Subject:
From:
"Mittelbach, Frank" <[log in to unmask]>
Reply To:
Mailing list for the LaTeX3 project <[log in to unmask]>
Date:
Wed, 3 Sep 2014 09:39:56 +0200
Content-Type:
text/plain
Parts/Attachments:
text/plain (168 lines)
sorry Sean for getting back so late into this (which is actually a topic 
very dear to me). I decided to comment to several of the posts in
chronological order even though it would probably more appropriate to
do a summary reply ... but ...

On 16.08.2014 07:14, Sean Allred wrote:
> Hello everyone,
>
> Disclaimer: I'm a huge fan of the template idea. It is a good system
> and I don't want it to see unnecessary change.

we I think it was a good prototype with a number of good ideas but it is
essentially flawed and I think you put the finger into one of its wounds

> Disclaimer to the disclaimer: it's the only design management paradigm
> that I've come into contact with in regards to TeX. :)

I beg to disagree, I think there is a second one which is the ldb (see
my talk from India and there is some crude implementation of it too)

both template and ldb should get married and at least in parts remodeled
to provide a coherent concept.


> I'd like to raise attention to a possible issue with xtemplate's
> design. Currently, an 'object' can receive no more than nine arguments
> per TeX's syntax limitations: you cannot refer to a tenth argument in a
> macro definition. That is,
>
> \DeclareObject { foo } { 10 }
>
> will fail. In TeX terms, this makes total sense. You cannot have more
> than nine mandatory arguments for any single macro---that's just the way
> it is. But speaking in terms of design, there are instances where such
> an object can have more than nine arguments. In reality, this is the
> decision of the document designer. There should be no such limitation
> on the design.

There is a certain history to that interface. Initially we thought that
the template concept should not just be deployed at the boundary between
presentation layer and designer layer but also internally (where these
days I believe every thing should be handled by expl3 paradigms where we
only have positional arguments). Given that and the time when that
xtemplate concept was designed speed was a very important factor (still
is to some extent) and if you do key/value repeatedly rather than only
in the transition from one layer to the next that would have slowed
things down enormously --- thus the mandatory arguments which are so
much faster to scan.

> I'll refer you to the original post for Joseph's full answer, but his
> suggestion is, in my opinion, a very appropriate one: going for a
> completely key--value interface on the design layer (note: not the
> author layer). It would certainly remove the limitation on the number
> of mandatory qualities an object may have. It would also seem to be
> more befitting of the verbose clarity of the design layer to do this.

that is probably true and I do lean towards that direction too these
days (especially as I'm now looking at template concept as something
that forms the designer layer only and thus its parsing happens once per
document element only.

However, regards of mandatory (positional) or named arguments there is
an area that I feel is even more important and that hasn't been
resolved: what exactly are the arguments that make up the signature of
an object declared by \DeclareObjectType?

The background idea of \DeclareObjectType was that I wanted to have a
specification for document elements and the "document data" that they
receive that is implemented by different templates so that you could
separate the document class specification.

Reason for having that was to enable a document written for a certain
document class to receive different formatting simply by replacing the
layout spec for the class with a new one.

In LaTeX2e we don't have any such separation: article.cls does define a
document object spec implicitly but it is mixed in by defining its
formatting. As a result if you go to a different class you can't be sure
that it codes against that same spec (and in fact often enough it
doesn't, eg amsart is close but not the same - and I'm not speaking of
the fact that it internally loads amsmath for you)

So the idea was that \DeclareObjectType would formally say how many
arguments each template for this object type would implement (checked)
but also informally would state what kind of document data these
arguments should receive (not checked). The templates would not need to
actually do something with all the data received but they should be able
to absorb them.

The problem that then showed up (and isn't resolved) is

  - what are those "required" arguments?
  - how do you handle variation without introducing multiple
incompatible document classes

Example:

  Giving a heading (section) object type. It is fairly clear that this
"requires" a title but beyond that it gets hazy. One could argue that
something like (an alternative) TOC title or running heading title is
advisable and could be made required (after all the interface from
document level to designer layer could duplicate arguments like it does
with current 2e and one could also argue that something like number
suppression as implemented by 2e is also generally a good idea but
beyond that ... is there anything else that should be forced down into
the interface?

probably not, but then anything in addition, say a "chapter motto" would
either mean that you end up with templates implementing different
document types and are incompatible with each other or you would need to
support something like defined optional data that will be parsed by the
interfaces and then used or not used by the templates.

So my current thoughts are in the following direction:

  \DeclareObjectType

    (1) should declare a set of data arguments that are required to be
implemented by every template of that type

    (2) it should also declare a set of data argument are optional,
i.e., a template could choose to not use them without violating the
statement that this template implements the particular data type

    (3) finally for special situations there could be other data
arguments (also optional) that a template might use that are not
declared at all.

==============

Now (1) could be kept positional as I really doubt that you find any
type that requires more than 9 of those despite the fact that is an
artifical restriction. However for sake of clarity on reading a designer
spec key/values are probably the better choice.

(2) definitely has to be of type key/value

(3) also need to be key/value and offering this is really there to
account for the fact that there might be special situations or things
that haven't been thought of initially. If it turns out that several
templates implement the same key meaning of type (3) then over time one
could promote that from (3) to (2) in the object type declaration, just
to formalize the meaning -- that would be upward compatible.

Offering an exit of (3) also means that one would need to parse any set
of key/values store them somewhere and offer that to the template for
use and they could decide to ignore any or all of them.

The downside is that you can't restrict yourself against a definite list
of required and optional key names and thus for the keys of type (2) one
can't identify typos in the name, say.

If (1) is key value then then parsing of arguments could compare the
list of received values against the list of required values for the
template type and at that point already complain if something is missing.

so much for my thoughts on these matters.

frank

ps some links on ideas around the architecture and ldb etc:

http://tex.stackexchange.com/questions/45838/what-can-i-do-to-help-the-latex3-project/46427#46427

http://latex-project.org/papers/LaTeX3-architecture-2011-slides.pdf

(and/or the video of the talk - link also on the website)

ATOM RSS1 RSS2