Received: from mail.proteosys.com ([213.139.130.197]) by nummer-3.proteosys with Microsoft SMTPSVC(6.0.3790.3959); Mon, 10 Aug 2009 18:00:32 +0200 Received: by mail.proteosys.com (8.14.3/8.14.3) with ESMTP id n7AG0XMU021043 for ; Mon, 10 Aug 2009 18:00:34 +0200 Received: from listserv.uni-heidelberg.de (listserv.uni-heidelberg.de [129.206.100.94]) by relay.uni-heidelberg.de (8.14.1/8.14.1) with ESMTP id n7AFuHaI006848 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Mon, 10 Aug 2009 17:56:17 +0200 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 n7AABWXb014993; Mon, 10 Aug 2009 17:56:13 +0200 Received: by LISTSERV.UNI-HEIDELBERG.DE (LISTSERV-TCP/IP release 15.5) with spool id 298168 for LATEX-L@LISTSERV.UNI-HEIDELBERG.DE; Mon, 10 Aug 2009 17:56:13 +0200 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 n7AFuD4S012381 for ; Mon, 10 Aug 2009 17:56:13 +0200 Received: from ueamailgate01.uea.ac.uk (ueamailgate01.uea.ac.uk [139.222.131.184]) by relay.uni-heidelberg.de (8.14.1/8.14.1) with ESMTP id n7AFu3TJ006492 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO) for ; Mon, 10 Aug 2009 17:56:07 +0200 Received: from ueams02.uea.ac.uk (ueams02.uea.ac.uk [139.222.131.131]) by ueamailgate01.uea.ac.uk (8.13.1/8.13.1) with ESMTP id n7AFu3jK007086 for ; Mon, 10 Aug 2009 16:56:03 +0100 Received: from [139.222.202.22] by ueams02.uea.ac.uk with esmtp (Exim 4.69) (envelope-from ) id 1MaXE8-0004Z7-NT for LATEX-L@LISTSERV.UNI-HEIDELBERG.DE; Mon, 10 Aug 2009 16:56:00 +0100 User-Agent: Thunderbird 2.0.0.22 (Windows/20090605) MIME-Version: 1.0 References: <4A7921CF.5020803@morningstar2.co.uk> <4A7A1505.4040604@residenset.net> <4A7AD930.2090106@residenset.net> <8516B615-51AA-4D90-BB7D-A9E122AA0335@gmail.com> Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit X-Canit-CHI2: 0.00 X-Bayes-Prob: 0.0001 (Score 0, tokens from: @@RPTN, outgoing) X-CanItPRO-Stream: UEA:outgoing (inherits from UEA:default,base:default) X-Canit-Stats-ID: 27904081 - 83394cf4e7c3 X-Scanned-By: MIMEDefang 2.65 on 213.139.130.197 X-Scanned-By: CanIt (www . roaringpenguin . com) on 139.222.131.184 Message-ID: <4A804317.6050909@morningstar2.co.uk> Date: Mon, 10 Aug 2009 16:56:07 +0100 Reply-To: Mailing list for the LaTeX3 project Sender: Mailing list for the LaTeX3 project From: Joseph Wright Subject: Re: xparse To: LATEX-L@LISTSERV.UNI-HEIDELBERG.DE In-Reply-To: <8516B615-51AA-4D90-BB7D-A9E122AA0335@gmail.com> Precedence: list List-Help: , List-Unsubscribe: List-Subscribe: List-Owner: List-Archive: X-ProteoSys-SPAM-Score: -6.599 () BAYES_00,RCVD_IN_DNSWL_MED Return-Path: owner-latex-l@LISTSERV.UNI-HEIDELBERG.DE X-OriginalArrivalTime: 10 Aug 2009 16:00:32.0623 (UTC) FILETIME=[B0AA5FF0:01CA19D3] Status: R X-Status: X-Keywords: X-UID: 5860 Will Robertson wrote: > So let's say we want to define \foo that takes an argument but has to > sanitise it in some way before processing it: > > \DeclareDocumentCommand \foo {m} { > \my_sanitise:Nn \l_sanitised_tl {#1} > \foo_internal:V \l_sanitised_tl > } > \cs_new:Nn \my_sanitise:Nn { > % do something with #1 and save it in \l_sanitised_tl > } > \cs_new:Nn \foo_internal:n { > % do whatever \foo is supposed to do with #1 > } > \cs_generate_variant:Nn \foo_internal:n {V} > > From my not in-depth understanding of xdoc2l3, this can be dramatically > simplified (I imagine) with something like > > \DeclareDocumentCommand \foo { ?{\my_sanitise:n} } { > % do whatever \foo is supposed to do with #1 > } > > Just to confirm -- have I got this thing sort of right? :) > > With this sort of example, it seems pretty clear that this can save a > lot of code that's just shuffling arguments around. (In the same way > that manual optional argument processing consists of lots of > intermediate functions that simply pass their arguments around.) Hello Will, That was my understanding also. The question is then whether we want/need to support this for all argument types or just one (or more) specific ones (or of course at all). In the first case, the interface currently used by xparse doesn't really work (I think). You need to go with something like xdoc2l3, where each specifier has a "processing" argument. My worry with that is, as I've said before, that it may be overly complex as a replacement for \newcommand. On the other hand, if you only want post-processing for a limited number of argument types then it should work. For example, you can imagine having an argument type p ( = processed) to handle mandatory arguments with post-processing: \DeclareDocumentCommand \foo { o p{} } { % Code using processed #2 } or \DeclareDocumentCommand \foo { o p\ProcessingFunction } { % Code using processed #2 } (This depends on whether you envisage using a single token for post-processing or allowing more than one processing function.) The question is then how many types of argument need post-processing. If it is only m => p, then this looks okay. Duplicating all of the specifiers, one for post-processed and one not, takes us back to needing to fundamentally re-think the plan. -- Joseph Wright