LATEX-L Archives

Mailing list for the LaTeX3 project


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
Frank Mittelbach <[log in to unmask]>
Reply To:
Mailing list for the LaTeX3 project <[log in to unmask]>
Sun, 22 Nov 2009 12:36:37 +0100
text/plain (145 lines)
I thought a bit more about the arguments brought forward by Lars about
supporting a kind of dictionary to pass arguments to instances.

With more complex object types I clearly can see the advantages of this
method, with more simpler types I'm not so sure though, partly because of the
overhead in processing. That makes me leaning towards a dual approach (also
suggested by Lars at one point if I remember correctly), ie have the most
important arguments mandatory but allow for an additional dictionary to be
passed along and queried as needed.

Thinking along those lines brings up a couple of questions:

What is the signature of an object type?

To recap, the idea of an object type is to describe the implementation level
interface an semantics of a certain set/type/class of objects with the idea
that if you have two different realizations/implementations for an object type
you can (ideally) exchange them with each other without compromising the
document content. E.g., more explicitly, if you have two different templates
for A-headings you can use either or in a document class design and with the
resulting document classes you can format the same set of documents

Now, above I said "ideally" because a description like the above leaves a
certain gray area, where one can have different opinions on whether the
document content is changed or not or whether the result can be called
successful formatting. Examples: if you have written class which is like
"article.cls except that all headings are unnumbered, does that still fulfill
the criteria of not modifying the document content? - perhaps not, but it
certainly fulfills the criteria of being a class that successfully formats any
document written for the article class - well more or less, at least if your
class does something about resolving references. Or take a document that
specifies a "quote" to go with each A-head via such a dictionary. Is it okay
to use it in one design but ignore it in another and still claim both designs
implement the same object type?

Coming back to the question: which if the following should be the defined

a) the object type defines the semantic of an object (of that type) including
   the semantics of its mandatory arguments. The optional dictionary is not
   considered and can be used in different ways by objects belonging to the
   same object type.

b) the dictionary is part of the definition of an object type, ie the keys it
   can contain and their semantics are defined by it, i.e., two objects only
   belong to the same object type if their semantics are the same on all levels

c) kind of in between: the object type can define the semantics of certain keys
   in which case all objects of this type have to support exactly that
   interpretation, however an object is free to accept/interpret additional

Note that with b) and c) we do not rule out that a key is not being used in
the end, eg if there is a key "quote" to pass a quotation to an A-head
template that template could completely ignore and it would still be within
the bounds of interpreting the "quote" key as being a quotation for the
A-head. It would be out of bounds when it would instead require the key to be
named "quotation" or if it would use the value of the key for something else,
eg the running header (not very likely with that name, but ...)

How should the dictionary be specified?

Basically I see two ways:

a) passing the dictionary in a mandatory argument, e.g., the first or the last
one, for example like

  \foo {...} {...}

b) setting up the dictionary prior to calling the instance, e.g.

  \foo {...} {...}

I wouldn't want to directly use property lists from the expl3 language at that
point for two reasons:

 - on the level the instances are used (ie the designer level and above I
   don't like to mix in expl3 syntax

 - setting up a property list using expl is fairly inefficient as the commands
   need to deal with updating keys if the already exist and that takes a lot
   of unnecessary time as we are starting from scratch here

last question for now (as this email is already too long):

Should there be some inheritance of dictionaries?

If the dictionary is not fully tied to the object type (ie case a) or c) in
the first question) we have two different possibilities to specify the
dictionary behavior:

a) the dictionary is build directly before or when an instance is called and
   it is cleared when one gets to \AssignKeys in the template code

b) the dictionary definitions obey grouping and this way can be passed from
   one  instance to the next, e.g., the dictionary coming with a heading can
   be made available to the instance implementing the toc entry (thus author,
   abstract, what-have-you that came in the dictionary to the heading is also
   available in the toc for inspection

of course, instead of automatic inheritance one might be better off if it is a
conscious decision in the template whether or not its dictionary is being made
available for later.

For example if a) gets implemented that could be done as follows:

  \ToDictionary fills \l_template_dict_prop

  \AssignKeys copies \l_template_dict_prop to \l_template_current_dict_prop
  and clears \l_template_dict_prop

  The template code could then query \l_template_current_dict_prop for keys it
  cares about and it could also prefill \l_template_dict_prop with key/val
  pairs or (with all of \l_template_current_dict_prop) prior to calling some
  other instance code.

What can't be done this way is something like a template for a list makes its
dictionary available to all objects in its body, for that one would need an
implementation that is using a single \l_template_dict_prop variable to
hold the dictionary for all objects (which obeys grouping and \ToDictionary
only adds to it and no clearing happens (other by grouping levels))

thoughts anyone?