## LATEX-L@LISTSERV.UNI-HEIDELBERG.DE

#### View:

 Message: [ First | Previous | Next | Last ] By Topic: [ First | Previous | Next | Last ] By Author: [ First | Previous | Next | Last ] Font: Proportional Font

Subject:

Re: Passing a dictionary to, for example, the TOC entry formatter

From:

Mailing list for the LaTeX3 project <[log in to unmask]>

Date:

Tue, 24 Nov 2009 13:58:09 +0000

Content-Type:

text/plain

Parts/Attachments:

 text/plain (44 lines)
 Joseph write: > > Frank: I don't understand what you mean by 'the overhead of > processing'.) > > I assume Frank was thinking that we wouldn't want to do everything in a > dictionary manner as some arguments are always needed, and so something > like: > > \def\foo@bar#1#2{% > Title: #1\\% > Name: \DictionaryLookup{#2}{name}\\% > Address: \DictionaryLookup{#2}{address}\\% > } > > will be faster for the explicitly passed #1 than the dictionary items, > independent of how the dictionary is implemented. (I'd assume that a > dictionary would be a single data structure: I'd probably do it as an > expl3 properly list, and then recovering data would certainly add some > processing overhead. However, even a csname expansion as you outline is > an additional overhead compared to an explicitly passed value.) The overhead you point to is slight, and there are worse offenders (such as the LaTeX3 programming language itself). I also suspect that if you do the tests I think you'll find   \expandafter\def\csname aa.bb\endcsname{A longish piece of text}   \def\mymacro #1{\csname #1.bb\endcsname   \mymacro{aa} will be quicker than   \mymacro{A longish piece of text} because of the reduced churning of tokens. But I could be wrong. Your revision of my     #1{name} to     \DictionaryLookup{#2}{name} I strongly disagree with. You've taken something simple that works, and changed it to something that is broken (because it assumes that all maps will be dictionaries). Jonathan The Open University is incorporated by Royal Charter (RC 000391), an exempt charity in England & Wales and a charity registered in Scotland (SC 038302).