Received: from mail.proteosys.com ([213.139.130.197]) by nummer-3.proteosys with Microsoft SMTPSVC(6.0.3790.3959); Wed, 12 Aug 2009 04:29:51 +0200 Received: by mail.proteosys.com (8.14.3/8.14.3) with ESMTP id n7C2TlZZ007380 for ; Wed, 12 Aug 2009 04:29:48 +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 n7C2PCng023204 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Wed, 12 Aug 2009 04:25:13 +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 n7BM1sYX017198; Wed, 12 Aug 2009 04:25:07 +0200 Received: by LISTSERV.UNI-HEIDELBERG.DE (LISTSERV-TCP/IP release 15.5) with spool id 285396 for LATEX-L@LISTSERV.UNI-HEIDELBERG.DE; Wed, 12 Aug 2009 04:25:07 +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 n7C2P6rd009311 for ; Wed, 12 Aug 2009 04:25:07 +0200 Received: from mail-pz0-f201.google.com (mail-pz0-f201.google.com [209.85.222.201]) by relay.uni-heidelberg.de (8.14.1/8.14.1) with ESMTP id n7C2P1Fl023102 for ; Wed, 12 Aug 2009 04:25:05 +0200 Received: by pzk39 with SMTP id 39so3746288pzk.25 for ; Tue, 11 Aug 2009 19:25:01 -0700 (PDT) Received: by 10.142.229.6 with SMTP id b6mr472605wfh.31.1250043901246; Tue, 11 Aug 2009 19:25:01 -0700 (PDT) Received: from ?129.127.15.244? ([129.127.15.244]) by mx.google.com with ESMTPS id k37sm32821066rvb.0.2009.08.11.19.24.58 (version=TLSv1/SSLv3 cipher=RC4-MD5); Tue, 11 Aug 2009 19:25:00 -0700 (PDT) Content-Type: multipart/signed; boundary=Apple-Mail-4--993728593; micalg=sha1; protocol="application/pkcs7-signature" Mime-Version: 1.0 (Apple Message framework v935.3) References: <4A7921CF.5020803@morningstar2.co.uk> <4A7A1505.4040604@residenset.net> <4A7AD930.2090106@residenset.net> <8516B615-51AA-4D90-BB7D-A9E122AA0335@gmail.com> <4A804317.6050909@morningstar2.co.uk> <4A80508F.3030904@elzevir.fr> <0C83E480-14E3-4CD8-924E-3B9EA602E004@gmail.com> <4A810D6E.5050207@morningstar2.co.uk> X-Mailer: Apple Mail (2.935.3) X-Spam-Whitelist: Message-ID: <13962923-07A3-4C66-B144-E728DBC10183@gmail.com> Date: Wed, 12 Aug 2009 11:54:54 +0930 Reply-To: Mailing list for the LaTeX3 project Sender: Mailing list for the LaTeX3 project From: Will Robertson Subject: Re: xparse To: LATEX-L@LISTSERV.UNI-HEIDELBERG.DE In-Reply-To: <4A810D6E.5050207@morningstar2.co.uk> 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: 12 Aug 2009 02:29:51.0984 (UTC) FILETIME=[C5695F00:01CA1AF4] Status: R X-Status: X-Keywords: X-UID: 5898 --Apple-Mail-4--993728593 Content-Type: text/plain; charset=US-ASCII; format=flowed; delsp=yes Content-Transfer-Encoding: 7bit Hi, Going back to an earlier message, and taking a little step back. Sorry for the long message. On 11/08/2009, at 3:49 PM, Joseph Wright wrote: > Will Robertson wrote: >> >> \DeclareDocumentCommand \foo { ?{\my_sanitise:n} } { >> % do whatever \foo is supposed to do with #1 >> } >> >> I neglected to include how \my_sanitise:n would actually be >> written. And >> I'm not too sure about that. If it ends up that \my_sanitise:n has to >> write to a scratch variable anyway, then I'm not sure we've saved >> too much. [...] > In any case, I'd imagine any post-processor being a function of one > argument. Internally, they'd do something with a temporary variable, > then put the value of the variable back into the input of the > underlying > function defined by in \DeclareDocumentCommand. So how would \my_sanitise:n above be written? If it's not expandable, then the results of modifying #1 must be written to a standard scratch variable (right?). At which stage I'm not convinced we've saved any confusion over the original way to write this sort of thing. For example: \cs_set:Nn \my_sanitise:n { \tl_set:Nn \l_scratch_tl {#1} \tl_replace_in:Nnn \l_scratch_tl {&} {&} % but what to do now with \l_scratch_tl ?? } If it's easier to hook post-processing steps into the argument stage but *harder* to write the functions that do so, have we gained much? Enough to justify the initial increase in complexity? Maybe to re-write my concern; how could we simplify this example from xdoc2l3: (use as much hypothetical syntactic sugar as you like) \gdef\XD@gp@intrange#1#2#3\XD@endgrab#4{% \count@=#4\relax \ifnum #1>\count@ \PackageError{xdoc2l3}% {Too small! Changed to minimum value #1}\@ehc \count@=#1\relax \else\ifnum #2<\count@ \PackageError{xdoc2l3}% {Too large! Changed to maximum value #2}\@ehc \count@=#2\relax \fi\fi \expandafter\XD@gh@put \expandafter{\expandafter{\the\count@}}{#3}% } \gdef\XD@pgp@intrange#1#2{% \XD@macro@prepend\@tempa{\XD@gp@intrange{#1}{#2}}% \XD@parse@processor } In my opinion, based on this example, it will be easier for users of xparse to write their own argument-parsing functions as nested definitions inside \DeclareDocumentCommand than to write something like the above. Notice the number of necessary but implicit macros that the author must know about: \XD@gp@... \XD@pgp@... \XD@endgrab \XD@gh@put \XD@macro@prepend\@tempa \XD@parse@processor To be clear, I'm not yet opposed to this style of argument processing and I *do* think there are some simplifications that can be made to the code above to make it more palatable for users to write. But before we agree to include such complex ideas into what is now a simple package (for end-users, I mean), I think it would be good to verify that a distillation of xdoc2l3 will "fit" into the philosophy of xparse. * * * After I say that, I suppose it would be remiss of me to go away without actually mentioning how I think the ideas in xdoc2l3 might work in xparse(-alt). First of all, I think we should drop the idea of using more letters for shorthands. As we've discussed, each package will use different letters and clashes will occur very quickly. Secondly, for simplicity let's drop the idea of toks-grabbing as a proxy for argument grabbing. Thirdly, use actual function names rather than character strings to represent argument processors. From xdoc2l3, there seem to be two broad cases for argument processing: \argumentprocess{#1} and \argumentprocess#1 These can be referred to in the argument definitions as something like >\CS and @\CS{DELIMITER} where \CS is the processing function and DELIMITER is what's inserted after the argument, in the second case. Finally, allow these to be chained together if necessary, as in something like this: (\foo takes one argument) \DeclareDocumentCommand \foo { @\foo_split_colons:n{::\q_nil} >\foo_range_check:nnn m }{...} Open questions: 1. Does this cover the functionality that you miss from xparse in xdoc2l3? 2. Is it simple enough for xparse? 3. Assuming that we must deal with both expandable and unexpandable argument processing, is there a straightforward way we can write the argument processors? (E.g., see how boolean expressions are written in expl3; a consistent interface is used for both expandable and unexpandable tests.) 4. Does that end up being any easier than writing things by hand? I've got some sort of niggling concern that this approach mixes "how the arguments are parsed" with "what the structure of the arguments are", which xparse is more careful not to do. * * * Now I really must get back to work :) Will --Apple-Mail-4--993728593 Content-Disposition: attachment; filename=smime.p7s Content-Type: application/pkcs7-signature; name=smime.p7s Content-Transfer-Encoding: base64 MIAGCSqGSIb3DQEHAqCAMIACAQExCzAJBgUrDgMCGgUAMIAGCSqGSIb3DQEHAQAAoIIGITCCAtow ggJDoAMCAQICECN4qE5kBXLk2f/jVDfSZPwwDQYJKoZIhvcNAQEFBQAwYjELMAkGA1UEBhMCWkEx JTAjBgNVBAoTHFRoYXd0ZSBDb25zdWx0aW5nIChQdHkpIEx0ZC4xLDAqBgNVBAMTI1RoYXd0ZSBQ ZXJzb25hbCBGcmVlbWFpbCBJc3N1aW5nIENBMB4XDTA5MDEyOTA1NDkxNVoXDTEwMDEyOTA1NDkx NVowQjEfMB0GA1UEAxMWVGhhd3RlIEZyZWVtYWlsIE1lbWJlcjEfMB0GCSqGSIb3DQEJARYQd3Nw cjgxQGdtYWlsLmNvbTCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBAL0BeSiAbKuqxeRN p2qn/m8ZL+xawr/WXyPgEF0FipWgRe9l3sMXcFHokcUu0xOc97R7xkUsGcQ8EyybGHuWey6x7X1Y xJZ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