Received: from mail.proteosys.com ([213.139.130.197]) by nummer-3.proteosys with Microsoft SMTPSVC(6.0.3790.3959); Tue, 24 Nov 2009 12:23:11 +0100 Received: by mail.proteosys.com (8.14.3/8.14.3) with ESMTP id nAOBN8d6024229 for ; Tue, 24 Nov 2009 12:23:09 +0100 Received: from listserv.uni-heidelberg.de (listserv.uni-heidelberg.de [129.206.100.94]) by relay2.uni-heidelberg.de (8.13.8/8.13.8) with ESMTP id nAOBI4kW017219 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Tue, 24 Nov 2009 12:18:05 +0100 Received: from listserv.uni-heidelberg.de (localhost.localdomain [127.0.0.1]) by listserv.uni-heidelberg.de (8.13.1/8.13.1) with ESMTP id nAOAVwWN020225; Tue, 24 Nov 2009 12:17:57 +0100 Received: by LISTSERV.UNI-HEIDELBERG.DE (LISTSERV-TCP/IP release 15.5) with spool id 364706 for LATEX-L@LISTSERV.UNI-HEIDELBERG.DE; Tue, 24 Nov 2009 12:17:57 +0100 Received: from relay.uni-heidelberg.de (relay.uni-heidelberg.de [129.206.100.212]) by listserv.uni-heidelberg.de (8.13.1/8.13.1) with ESMTP id nAOBHv6d011508 for ; Tue, 24 Nov 2009 12:17:57 +0100 Received: from pluto.open.ac.uk (pluto.open.ac.uk [137.108.145.32]) by relay.uni-heidelberg.de (8.14.1/8.14.1) with ESMTP id nAOBHg7A005717 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO) for ; Tue, 24 Nov 2009 12:17:46 +0100 Received: from laurel.open.ac.uk ([137.108.170.71]) by pluto.open.ac.uk with esmtp (Exim 4.69) (envelope-from ) id 1NCtOw-0000Xz-6b for LATEX-L@LISTSERV.UNI-HEIDELBERG.DE; Tue, 24 Nov 2009 11:17:42 +0000 Received: from KIELDERCMS1.open.ac.uk ([137.108.140.185]) by LAUREL.open.ac.uk ([137.108.170.71]) with mapi; Tue, 24 Nov 2009 11:17:42 +0000 Thread-Topic: Passing a dictionary to, for example, the TOC entry formatter Thread-Index: AcpraK0K6Vn5ekcRSReW6yxU6Lq2owBjBEHg References: <19209.8773.325233.396932@morse.mittelbach-online.de> Accept-Language: en-US, en-GB Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: acceptlanguage: en-US, en-GB Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-MIME-Autoconverted: from quoted-printable to 8bit by listserv.uni-heidelberg.de id nAOBHv6d011509 Message-ID: Date: Tue, 24 Nov 2009 11:17:41 +0000 Reply-To: Mailing list for the LaTeX3 project Sender: Mailing list for the LaTeX3 project From: "J.Fine" Subject: Passing a dictionary to, for example, the TOC entry formatter To: LATEX-L@LISTSERV.UNI-HEIDELBERG.DE In-Reply-To: <19209.8773.325233.396932@morse.mittelbach-online.de> Precedence: list List-Help: , List-Unsubscribe: List-Subscribe: List-Owner: List-Archive: X-ProteoSys-SPAM-Score: -6.599 () BAYES_00,RCVD_IN_DNSWL_MED X-Scanned-By: MIMEDefang 2.65 on 213.139.130.197 Return-Path: owner-latex-l@LISTSERV.UNI-HEIDELBERG.DE X-OriginalArrivalTime: 24 Nov 2009 11:23:11.0826 (UTC) FILETIME=[81C3C320:01CA6CF8] Status: R X-Status: X-Keywords: X-UID: 6180 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 \@lookup{mydict} 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 --- 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).