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 p9D8FKX9005664 for ; Thu, 13 Oct 2011 10:15:21 +0200 Received: (qmail 5356 invoked by alias); 13 Oct 2011 08:15:14 -0000 Delivered-To: GMX delivery to rainer.schoepf@gmx.net Received: (qmail invoked by alias); 13 Oct 2011 08:14:49 -0000 Received: from relay.uni-heidelberg.de (EHLO relay.uni-heidelberg.de) [129.206.100.212] by mx0.gmx.net (mx088) with SMTP; 13 Oct 2011 10:14:49 +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 p9D8CVZH001360 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Thu, 13 Oct 2011 10:12:31 +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 p9D7FjRQ001703; Thu, 13 Oct 2011 10:12:30 +0200 Received: by LISTSERV.UNI-HEIDELBERG.DE (LISTSERV-TCP/IP release 16.0) with spool id 1789623 for LATEX-L@LISTSERV.UNI-HEIDELBERG.DE; Thu, 13 Oct 2011 10:12:30 +0200 Received: from relay2.uni-heidelberg.de (relay2.uni-heidelberg.de [129.206.210.211]) by listserv.uni-heidelberg.de (8.13.1/8.13.1) with ESMTP id p9D8CU9d021819 for ; Thu, 13 Oct 2011 10:12:30 +0200 Received: from mail-ey0-f177.google.com (mail-ey0-f177.google.com [209.85.215.177]) by relay2.uni-heidelberg.de (8.13.8/8.13.8) with ESMTP id p9D8CKYq002359 (version=TLSv1/SSLv3 cipher=RC4-SHA bits=128 verify=FAIL) for ; Thu, 13 Oct 2011 10:12:25 +0200 Received: by eye3 with SMTP id 3so2125392eye.22 for ; Thu, 13 Oct 2011 01:12:20 -0700 (PDT) MIME-Version: 1.0 Received: by 10.223.6.25 with SMTP id 25mr806664fax.14.1318493539985; Thu, 13 Oct 2011 01:12:19 -0700 (PDT) Received: by 10.152.4.193 with HTTP; Thu, 13 Oct 2011 01:12:19 -0700 (PDT) References: <4E95A9C2.6020607@residenset.net> Content-Type: multipart/mixed; boundary=00151747844216eb3404af29b3f8 X-Spam-Whitelist: Message-ID: Date: Thu, 13 Oct 2011 04:12:19 -0400 Reply-To: Mailing list for the LaTeX3 project Sender: Mailing list for the LaTeX3 project From: Bruno Le Floch Subject: Re: Church booleans 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 (eXpurgate); Detail=5D7Q89H36p42lhgaIAOef8vfEUQBIZIw0weNu9fEQWFJwQMTtWo1FbKQzac5hpYqCcwMM YmC5Fn0s9U1TwX+MTKCReE8mNWaBmlD80/eU5iAzQTVyBDNWMFJdpFRqoUTDYMAXEv+0Vp3Bwotm KPnNxwM7cna43c0fI4WxF4QAzVcMsgX1Gbom6RxfjXTsXkjcPUtasK0FBI=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: 6935 --00151747844216eb3404af29b3f8 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable On 10/12/11, Philipp Stephani wrote: > 2011/10/12 Lars Hellstr=F6m : >> True =3D \lambda xy . x >> False =3D \lambda xy . y >> >> These may look strange, but turn out to be two objects that are very >> familiar to us: \use_i:nn and \use_ii:nn respectively (or \@firstoftwo a= nd >> \@secondoftwo, for those who still think in 2e terms (like me)). > > This is in fact used by etoolbox's toggles. Yes. I think most of those who had to decide how to implement booleans have thought about that possibility in the past (together with the obvious \iffalse/\iftrue, Morten's 01/00, the current LaTeX3 \char"0/1, and probably some others). But it is definitely good to raise it from time to time. I just reimplemented (see attached) the boolean expression parser building upon Lars' suggestion, slightly modified: a predicate shall f-expand to " { } " such the is a TF conditional (expandable or not). The difference with Lars is that I require the braces around . In other words, the predicate must grab all its arguments and hide itself between braces, so that we can look ahead to see what operator follows. If all the tests are expandable, the expression will be expandable. If some tests are not expandable, the expansion will stop there, and perhaps bad things will happen in expansion contexts, since tests further down the line will be run... But in a typesetting context, everything should work nicely. It also seems that the reimplementation is somewhat faster (perhaps 30-40%). And the amount of code is the same. Do we want that? Regards, Bruno --00151747844216eb3404af29b3f8 Content-Type: application/x-tex; name="alt-booleans.tex" Content-Disposition: attachment; filename="alt-booleans.tex" Content-Transfer-Encoding: base64 X-Attachment-Id: file0 JSBBIGJvb2xlYW4gZXhwcmVzc2lvbiBpcwolIEJPT0xFWFBSICA8LSBPUEVSQU5EICggT1BFUkFU T1IgT1BFUkFORCApKgolIE9QRVJBVE9SICA8LSAifHwiIHwgIiYmIgolIE9QRVJBTkQgICA8LSAi KCIgQk9PTEVYUFIgIikiIHwgIiEiIE9QRVJBTkQgfCBQUkVESUNBVEUKJSBQUkVESUNBVEUgPT1b Zi1leHBhbmRzIHRvXT09ICJ7IiBSRVRVUk4tVEYgIn0iCiUgUkVUVVJOLVRGID09W3J1biAgYnkg IFRlWF09PSAiXHVzZV9pOm5uIiB8fCAiXHVzZV9paTpubiIKJQolIEluIHBhcnRpY3VsYXIsIGJv b2xlYW5zIGFyZSB0aGUgcHJlZGljYXRlcyAie1x1c2VfaTpubn0iIGFuZCAie1x1c2VfaTpubn0i LgolCiUgPT09PT09PT09PT09PT09PT09PT09PT09PT09CiUgQ29kZSAoc2VlIGJlbG93IHRvIHRl c3QgaXQpCiUgPT09PT09PT09PT09PT09PT09PT09PT09PT09ClxSZXF1aXJlUGFja2FnZXtleHBs M30KXEV4cGxTeW50YXhPbgpcY3Nfc2V0X3Byb3RlY3RlZDpOcG4gXGNfdHJ1ZV9hYm9vbCB7IHsg XHVzZV9pOm5uIH0gfQpcY3Nfc2V0X3Byb3RlY3RlZDpOcG4gXGNfZmFsc2VfYWJvb2wgeyB7I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raXBfbG9vcDpud3dOdwogICAgICB7IzF9CiAgICAgICMyCiAgICAg IFxxX21hcmsgXGFib29sX2V2YWxfc2tpcF9vbmU6bncKICAgICAgKAogICAgICBccV9tYXJrIFxh Ym9vbF9ldmFsX3NraXBfZG9uZTpudwogICAgICBccV9zdG9wCiAgfQpcY3NfbmV3Ok5wbiBcYWJv b2xfZXZhbF9za2lwX2RvbmU6bncgIzEgIzIgKSB7ICMxICkgfQpcY3NfbmV3OmNwbiB7IGFib29s X01fVDp3IH0gIzEjMikjMykKICB7CiAgICAjMQogICAgICBcYWJvb2xfZXZhbF90cnVlX29wZXJh dG9yOncKICAgICAgXGFib29sX2V2YWxfZmFsc2Vfb3BlcmF0b3I6dwogICAgIzMKICAgIFxhYm9v bF9tYXJrZXI6ICMyICkKICB9Clxjc19uZXc6Y3BuIHsgYWJvb2xfTV9GOncgfSAjMSMyKSMzKQog IHsKICAgICMxCiAgICAgIFxhYm9vbF9ldmFsX2ZhbHNlX29wZXJhdG9yOncKICAgICAgXGFib29s X2V2YWxfdHJ1ZV9vcGVyYXRvcjp3CiAgICAjMwogICAgXGFib29sX21hcmtlcjogIzIgKQogIH0K XGNzX25ldzpjcG4geyBhYm9vbF9TX1Q6dyB9ICMxICkKICB7IFxncm91cF9hbGlnbl9zYWZlX2Vu ZDogXHByZ19yZXR1cm5fdHJ1ZTogfQpcY3NfbmV3OmNwbiB7IGFib29sX1NfRjp3IH0gIzEgKQog IHsgXGdyb3VwX2FsaWduX3NhZmVfZW5kOiBccHJnX3JldHVybl9mYWxzZTogfQoKJSA9PT09PT09 PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT0KJSBUZXN0cyAodXNpbmcgdGhl IGwzdGltZSBwYWNrYWdlLCBuZXdseSBvbiB0aGUKJSBzdm4sIGJ1dCB5b3UgY2FuIHRlc3Qgd2l0 aG91dCBpZiB5b3Ugd2FudCkuCiUgPT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09 PT09PT09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jc19zZXRfcHJvdGVjdGVkOk5wbiBcdGxf aWZfaW5fYXA6bm4gIzEjMgogIHsgeyBcdGxfaWZfaW46bm5URiB7IzF9eyMyfSB9IH0KXGFib29s X2lmOm5URgogIHsKICAgIFxjX3RydWVfYWJvb2wKICAgICYmIFx0bF9pZl9pbl9hcDpubiB7YWJj fSB7YWJ9CiAgICAmJiBcY190cnVlX2Fib29sCiAgfQogIHsgfQogIHsgfQoKXHRleF9lbmQ6RAol IE5vdGUgdG8gQkxGOiBzZWUgRXhwZXJpbWVudDI2OC50ZXg= --00151747844216eb3404af29b3f8--