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 o8L2OJ4I009595 for ; Tue, 21 Sep 2010 04:24:21 +0200 Received: (qmail 23552 invoked by alias); 21 Sep 2010 02:24:14 -0000 Delivered-To: GMX delivery to rainer.schoepf@gmx.net Received: (qmail invoked by alias); 21 Sep 2010 02:24:14 -0000 Received: from relay.uni-heidelberg.de (EHLO relay.uni-heidelberg.de) [129.206.100.212] by mx0.gmx.net (mx002) with SMTP; 21 Sep 2010 04:24:14 +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 o8L2LsbJ032418 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Tue, 21 Sep 2010 04:21:54 +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 o8KM14K5018044; Tue, 21 Sep 2010 04:22:16 +0200 Received: by LISTSERV.UNI-HEIDELBERG.DE (LISTSERV-TCP/IP release 16.0) with spool id 434921 for LATEX-L@LISTSERV.UNI-HEIDELBERG.DE; Tue, 21 Sep 2010 04:22:16 +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 o8L2MG4X005182 for ; Tue, 21 Sep 2010 04:22:16 +0200 Received: from mail-pw0-f49.google.com (mail-pw0-f49.google.com [209.85.160.49]) by relay.uni-heidelberg.de (8.14.1/8.14.1) with ESMTP id o8L2Lep0032290 for ; Tue, 21 Sep 2010 04:21:44 +0200 Received: by pwj3 with SMTP id 3so2168623pwj.22 for ; Mon, 20 Sep 2010 19:22:10 -0700 (PDT) Received: by 10.114.92.16 with SMTP id p16mr10834466wab.210.1285035730759; Mon, 20 Sep 2010 19:22:10 -0700 (PDT) Received: from staff-248-149.wireless.adelaide.edu.au (staff-248-149.wireless.adelaide.edu.au [129.127.248.149]) by mx.google.com with ESMTPS id d39sm14582391wam.4.2010.09.20.19.22.07 (version=TLSv1/SSLv3 cipher=RC4-MD5); Mon, 20 Sep 2010 19:22:09 -0700 (PDT) Content-Type: text/plain; charset=windows-1252 Mime-Version: 1.0 (Apple Message framework v1081) References: <4C967C9B.5010706@gmx.de> <71ED7A5B-DE11-45D9-9785-95A1DC795080@gmail.com> <4C9724B4.3010301@residenset.net> <19607.26705.947540.499705@morse.mittelbach-online.de> X-Mailer: Apple Mail (2.1081) X-Spam-Whitelist: Content-Transfer-Encoding: 8bit X-MIME-Autoconverted: from quoted-printable to 8bit by listserv.uni-heidelberg.de id o8L2MG4X005183 Message-ID: Date: Tue, 21 Sep 2010 11:52:03 +0930 Reply-To: Mailing list for the LaTeX3 project Sender: Mailing list for the LaTeX3 project From: Will Robertson Subject: Re: boolean expressions in ExplSyntaxNames To: LATEX-L@listserv.uni-heidelberg.de In-Reply-To: <19607.26705.947540.499705@morse.mittelbach-online.de> Precedence: list List-Help: , List-Unsubscribe: List-Subscribe: List-Owner: List-Archive: X-GMX-Antispam: 0 (Mail was not recognized as spam); Detail=5D7Q89H36p6i75npGen84eVAEFK/syJmiNoEBJhgjYKpglu1TZLLw7xMZnJMXwBFy+Sxe D/AUQGQOurK3ezVJqUBFH0uN5pjmWoMfpyHp50EZ60/Y6hM43eiKLTaE/W0dI7nIn8+pr4SzneyH Jeytg==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: 6425 On 20/09/2010, at 11:27 PM, Frank Mittelbach wrote: > is there actually any need for the :nnn etc versions? Not sure, is there? They seem natural to me; better than nesting multiple :nn commands for more than two ‘and’ branches, say. > I tend to prefer the lisp like versions too ...not because I find them much > more readable :-) but because I still have a suspicion that the inline coding > has a performance hit (which is most likely not the case as they are coded by > Morten, but there you are). Well, my initial implementation was just going to be \cs_new:Npn \bool_and_p:nn #1#2 { \bool_if_p:n { #1 && #2 } } \cs_new:Npn \bool_and_p:nnn #1#2#3 { \bool_if_p:n { #1 && #2 && #3 } } \cs_new:Npn \bool_and_p:nnnn #1#2#3#4 { \bool_if_p:n { #1 && #2 && #3 && #4 } } to be filled in with more efficient hand-coded versions when time permits. So perhaps not the speed gains you were hoping for, at least straight away :) In fact, I'm not sure you're going to do that much better unless you want more restricted \bool_and_p:NN versions instead. But how fast do these need to be? In the attached benchmark, I can run \bool_if:nTF { \intexpr_compare_p:n {1=1} && ( \intexpr_compare_p:n {2=3} || \intexpr_compare_p:n {4=4} || \intexpr_compare_p:n {1=\error} % is skipped ) && !(\intexpr_compare_p:n {2=4}) } {T}{F} about 13000 times per second on my machine. I don't really have a metric for knowing when how fast is fast enough, though -- perhaps this is too slow. (What's that saying about premature optimisation? :) ) -- Will \documentclass{minimal} \usepackage{expl3} \begin{document} \ExplSyntaxOn \batchmode \def\N{10000} replicate~ only:~ \pdfresettimer \prg_replicate:nn {\N} { \typeout{x} } \newcount\1 \1=\pdfelapsedtime \number\1 \par replicate~ with~ boolean~ calculation:~ \pdfresettimer \prg_replicate:nn {\N} { \typeout{ \bool_if:nTF { \intexpr_compare_p:n {1=1} && ( \intexpr_compare_p:n {2=3} || \intexpr_compare_p:n {4=4} || \intexpr_compare_p:n {1=\error} % is skipped ) && !(\intexpr_compare_p:n {2=4}) } {T}{F} } } \newcount\2 \2=\pdfelapsedtime \number\2 \par time~per~loop:~\the\numexpr(1000000*(\2-\1)/\N)/65536\relax\space microseconds \ExplSyntaxOff \end{document}