Received: from mx0.gmx.net (mx0.gmx.net [213.165.64.100]) by h1439878.stratoserver.net (8.14.2/8.14.2/Debian-2build1) with SMTP id p1GG6eAd013576 for ; Wed, 16 Feb 2011 17:06:41 +0100 Received: (qmail 11470 invoked by alias); 16 Feb 2011 16:06:35 -0000 Delivered-To: GMX delivery to rainer.schoepf@gmx.net Received: (qmail invoked by alias); 16 Feb 2011 16:06:31 -0000 Received: from relay2.uni-heidelberg.de (EHLO relay2.uni-heidelberg.de) [129.206.210.211] by mx0.gmx.net (mx118) with SMTP; 16 Feb 2011 17:06:31 +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 p1GG4KiN020971 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Wed, 16 Feb 2011 17:04:21 +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 p1GFSwun018477; Wed, 16 Feb 2011 17:04:13 +0100 Received: by LISTSERV.UNI-HEIDELBERG.DE (LISTSERV-TCP/IP release 16.0) with spool id 1455481 for LATEX-L@LISTSERV.UNI-HEIDELBERG.DE; Wed, 16 Feb 2011 17:04:13 +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 p1GG4DPZ007536 for ; Wed, 16 Feb 2011 17:04:13 +0100 Received: from mail-yx0-f177.google.com (mail-yx0-f177.google.com [209.85.213.177]) by relay.uni-heidelberg.de (8.14.1/8.14.1) with ESMTP id p1GG46m6020373 (version=TLSv1/SSLv3 cipher=RC4-MD5 bits=128 verify=FAIL) for ; Wed, 16 Feb 2011 17:04:12 +0100 Received: by yxd30 with SMTP id 30so825508yxd.22 for ; Wed, 16 Feb 2011 08:04:06 -0800 (PST) MIME-Version: 1.0 Received: by 10.151.83.7 with SMTP id k7mr961171ybl.68.1297872246378; Wed, 16 Feb 2011 08:04:06 -0800 (PST) Received: by 10.146.86.8 with HTTP; Wed, 16 Feb 2011 08:04:04 -0800 (PST) References: <4028010D-1144-415D-A984-E3684A7E3EDE@gmail.com> <4D5B770A.2000401@morningstar2.co.uk> <20110216105124.GA5579@oberdiek.my-fqdn.de> <4D5BAE81.4020904@morningstar2.co.uk> Content-Type: text/plain; charset=ISO-8859-1 X-Spam-Whitelist: Message-ID: Date: Wed, 16 Feb 2011 11:04:04 -0500 Reply-To: Mailing list for the LaTeX3 project Sender: Mailing list for the LaTeX3 project From: Bruno Le Floch Subject: Re: Expandable versions of \uppercase, \MakeUppercase, \lowercase, \MakeLowercase To: LATEX-L@listserv.uni-heidelberg.de In-Reply-To: Precedence: list List-Help: , List-Unsubscribe: List-Subscribe: List-Owner: List-Archive: X-GMX-Antispam: 0 (Mail was not recognized as spam); Detail=5D7Q89H36p77e5KAPs1l6v/Sb97LojnDtMgfETrECMLUO9erHzOJe7j3G660N4yBY6XHH YPYtmQj6mbYUTZ3LnaFANLWrKE7/wIDhnv+VrW0hxOapLRUwuY9oBqo5h+Dh9B42XlFTMTKlXDju GaV8Q==V1; X-Resent-By: Forwarder X-Resent-For: rainer.schoepf@gmx.net X-Resent-To: rainer@rainer-schoepf.de Status: R X-Status: X-Keywords: X-UID: 6606 >> As I now understand, the key point in all of this is that we can >> detect spaces and braces expandably using delimited arguments, and we >> can then be sure to act on one token at a time. > > Ah, I see: > > \long\gdef\UL_brace_check:nw#1#2#{% > \UL_if_empty:nTF{#2}% > {\UL_brace_yes:nn{#1}}% > {\UL_space_check:nw{#1}#2}% > } > > This is clever. Has anyone seen this done before? Are there any downsides? One problem is that it only detects begin-group characters which are actually braces (e.g. after |\catcode`\[=1|, it won't see "["). Another problem is if there is no brace in a big argument, then #2 will be the whole argument (until the sentinel {}), and the test is rather slow at every step. In contexts where the replacement takes no argument (i.e. a simple \tl_replace_all_in:nn), we could do much quicker by first putting a \q_mark before each brace group, and then just checking for it (same trick for spaces). > If it's as good as it seems then it allows all sorts of expandable things, > such as optional argument parsing and expandable nested mapping. We had a short discussion with Joseph about optional argument parsing. The obvious constraint is that the last argument must be mandatory, so we can just look for its opening delimiter. Then it is in principle possible, but argument specifications like {oom} become quite tricky, since #{ has to be used when grabbing each of these arguments. I haven't looked at the implementation of xparse in detail, though. I've put the code for \fullyexpand online for those interested, as well as a very primitive macro expander. ( http://users.aims.ac.za/~bruno/LaTeX/ULcase/ ) -- Regards, Bruno