LATEX-L Archives

Mailing list for the LaTeX3 project


Options: Use Classic View

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

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

Print Reply
"J.Fine" <[log in to unmask]>
Tue, 24 Nov 2009 11:17:41 +0000
text/plain (61 lines)
Was RE: object type / instance arguments

Lars wrote:
The purpose of using a dictionary would be to allow the data being passed around to have more structure. I also think passing a dictionary to the TOC entry formatter would be great, as that will allow *it* to decide whether to include an author name, subtitle, short description, etc. or not.

Frank wrote:
> 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?
> How should the dictionary be specified?
> Should there be some inheritance of dictionaries?

[discussion of questions snipped]

Independently I've come up with a scheme as follows
  \def\my@template #1{%
      My name is #1{name} and my email address is #1{email}.
where #1 can be as simple as
and where \@lookup could be as simple as
  \def\@lookup #1#2{%
     \csname #1.#2\endcname

I've used it in some trial material and it works fine.  (Frank:  I don't understand what you mean by 'the overhead of processing'.)

What I've suggested is very similar to what's done in modern scripting languages.  For example:
  Python 2.5.1 (r251:54863, May 18 2007, 16:56:43)
  >>> mydict = {'name':'Jonathan Fine', 'email':'not for spammers'}
  >>> print 'My name is %(name)s and my email address is %(email)s' % mydict
  My name is Jonathan Fine and my email address is not for spammers


The Open University is incorporated by Royal Charter (RC 000391), an exempt charity in England & Wales and a charity registered in Scotland (SC 038302).