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 p9DEfMOe003803 for ; Thu, 13 Oct 2011 16:41:23 +0200 Received: (qmail 16697 invoked by alias); 13 Oct 2011 14:41:17 -0000 Delivered-To: GMX delivery to rainer.schoepf@gmx.net Received: (qmail invoked by alias); 13 Oct 2011 14:41:16 -0000 Received: from relay.uni-heidelberg.de (EHLO relay.uni-heidelberg.de) [129.206.100.212] by mx0.gmx.net (mx009) with SMTP; 13 Oct 2011 16:41:16 +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 p9DEcAb3030421 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Thu, 13 Oct 2011 16:38:10 +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 p9DCYCeY001703; Thu, 13 Oct 2011 16:38:08 +0200 Received: by LISTSERV.UNI-HEIDELBERG.DE (LISTSERV-TCP/IP release 16.0) with spool id 1830660 for LATEX-L@LISTSERV.UNI-HEIDELBERG.DE; Thu, 13 Oct 2011 16:38:08 +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 p9DEc8qu019616 for ; Thu, 13 Oct 2011 16:38:08 +0200 Received: from csep02.cliche.se (csep02.cliche.se [195.249.40.184]) by relay2.uni-heidelberg.de (8.13.8/8.13.8) with ESMTP id p9DEbr1f023075 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO) for ; Thu, 13 Oct 2011 16:37:57 +0200 Received: from nova-2.local (unknown [130.239.119.177]) by csep02.cliche.se (Postfix) with ESMTP id 6419F186658 for ; Thu, 13 Oct 2011 16:37:50 +0200 (CEST) User-Agent: Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10.6; sv-SE; rv:1.9.2.22) Gecko/20110902 Thunderbird/3.1.14 MIME-Version: 1.0 References: <4E95A9C2.6020607@residenset.net> <4E95C086.7060806@morningstar2.co.uk> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 8bit X-MIME-Autoconverted: from quoted-printable to 8bit by listserv.uni-heidelberg.de id p9DEc8qu019617 Message-ID: <4E96F7BF.9070700@residenset.net> Date: Thu, 13 Oct 2011 16:37:51 +0200 Reply-To: Mailing list for the LaTeX3 project Sender: Mailing list for the LaTeX3 project From: =?ISO-8859-1?Q?Lars_Hellstr=F6m?= 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=5D7Q89H36p7zYQev1Bv5lawyulDRL8cttHaMJ1zHPmZxrdFvBIrR4iwoJF3erNCxErdMv xrcFeB/J9hxTn97MgcYzvWq4hwnDkQb4ffPXo90wLdHHbRUL3chPV7wLacK2EsgOXD0/Ziq2+JPz fPctfrjmcmv0YMqEZlhveTNHSf5JDtdbfWqfFMOiqA6OXgG+O0mnrFsLz8=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: 6939 Bruno Le Floch skrev 2011-10-12 18.59: > On 10/12/11, Joseph Wright wrote: >> One obvious question is how easy would it be to support predicate >> decision making in such as scheme: >> >> \bool_if:nTF >> { \l_my_first_bool&& ( \l_my_second_bool&& !\l_my_third_bool ) } >> >> which is one of the reasons for the approach currently taken. My first impulse to a response to that question was "That's a strange expression, maybe there's a typo? But as written, I would code that as \and:nnnTF{\l_my_first_bool}{\l_my_second_bool} {\not:nTF{\l_my_third_bool}} " But I gather from the subsequent discussion that you're asking about the possibilities for using infix notation operations on Church booleans. > I had the same thought as Joseph. As far as I can tell, the infix > notation requires us to have unexpandable predicates/booleans (more > precisely, which stop f-expansion), because those can come in all > sorts of forms, not necessarily as single tokens. One option would be > > \cs_set:Npn \c_true_bool { \exp_stop_f: \use_i:nn } > \cs_set:Npn \c_false_bool { \exp_stop_f: \use_ii:nn } > \cs_set:Npn \bool_if:NTF #1 { \tex_romannumeral:D -`q #1 } > > That can probably be made to work within boolean expressions, with > roughly the same efficiency as the current approach. However, it still > doesn't work for non-expandable tests. Trivial approach to put a Church boolean into \bool_if:nTF would be to use some sort of \cs_new:Npn \bool_pred:n #1 {#1 \c_true_bool \c_false_bool} % \c_true_bool and \c_false_bool being the current \chardefs. as follows: \bool_if:nTF { \bool_pred:n{\l_my_first_bool} && ( \bool_pred:n{\l_my_second_bool} && !\bool_pred:n{\l_my_third_bool} ) } Whether whatever scheme you're currently using to parse these expressions could be taught to insert the \bool_pred:n (or just \c_true_bool \c_false_bool) automatically is of course another matter. > [1] http://article.gmane.org/gmane.comp.tex.latex.latex3/2187 > > I think that Lars has in the past [1] advocated against the infix > syntax as being an attempt to impose upon TeX some foreign and not > very appropriate syntax (please correct me if I misunderstood you). Guilty as charged. However, the foreign syntax thing is more of an analytic criticism that came at second or third thought. First I had been scared by seeing & used for something that had nothing to do with alignments, and annoyed by realising that it did not give different priorities to && and || (thus seeming to promise a feature that it actually didn't deliver). \if_bool:nTF may subsequently have been improved in the latter respect. > In > this perspective, providing \and:nn etc. as Lars proposes would be > much faster than the current approach, and would accomodate trivially > for non-expandable conditionals. Another thing about the Church booleans is that they do not require a framework to be useable; they can be used directly also in code written with \ExplSyntaxOff. I can see that becoming convenient every now and then, for document preamble command definitions (even though there arguably has to be a leaky abstraction somewhere for them to even become exposed, such things will happen). Along that line of though, I've also toyed with the idea of having an xparse o argument return either \NoValue or \YesValue{} where \cs_new:Npn \NoValue {-NoValue-} \cs_new_eq:NN \YesValue \use_i:n \cs_new:Npn \IfNoValueTF #1 { \use_iii:nnn #1 \use_iii:nnn \use_i:nn } It's not quite as elegant as the Church booleans, but strikingly simple. Lars Hellström