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 p049T6eo011891 for ; Tue, 4 Jan 2011 10:29:07 +0100 Received: (qmail 21250 invoked by alias); 4 Jan 2011 09:29:01 -0000 Delivered-To: GMX delivery to rainer.schoepf@gmx.net Received: (qmail invoked by alias); 04 Jan 2011 09:29:00 -0000 Received: from relay.uni-heidelberg.de (EHLO relay.uni-heidelberg.de) [129.206.100.212] by mx0.gmx.net (mx118) with SMTP; 04 Jan 2011 10:29:00 +0100 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 p049RCfH007883 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Tue, 4 Jan 2011 10:27:13 +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 p049N6Ed001020; Tue, 4 Jan 2011 10:27:11 +0100 Received: by LISTSERV.UNI-HEIDELBERG.DE (LISTSERV-TCP/IP release 16.0) with spool id 777117 for LATEX-L@LISTSERV.UNI-HEIDELBERG.DE; Tue, 4 Jan 2011 10:27:11 +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 p049RBZc026765 for ; Tue, 4 Jan 2011 10:27:11 +0100 Received: from ueamailgate01.uea.ac.uk (ueamailgate01.uea.ac.uk [139.222.131.184]) by relay.uni-heidelberg.de (8.14.1/8.14.1) with ESMTP id p049QuFF007178 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO) for ; Tue, 4 Jan 2011 10:27:00 +0100 Received: from ueams01.uea.ac.uk (ueams01.uea.ac.uk [139.222.131.78]) by ueamailgate01.uea.ac.uk (8.13.8/8.13.8) with ESMTP id p049Qtg1032605 for ; Tue, 4 Jan 2011 09:26:56 GMT Received: from [139.222.113.126] by ueams01.uea.ac.uk with esmtp (Exim 4.69) (envelope-from ) id 1Pa3AN-0006DP-6l for LATEX-L@LISTSERV.UNI-HEIDELBERG.DE; Tue, 04 Jan 2011 09:26:55 +0000 User-Agent: Mozilla/5.0 (Windows; U; Windows NT 6.1; en-GB; rv:1.9.2.13) Gecko/20101207 Thunderbird/3.1.7 MIME-Version: 1.0 References: <4D22486F.5000506@morningstar2.co.uk> <7C89B4BA-13CE-4976-ADB9-1C08CE25475E@gmail.com> <20110104084343.GA7767@oberdiek.my-fqdn.de> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Bayes-Prob: 0.0001 (Score 0, tokens from: @@RPTN, outgoing) X-CanIt-Geo: ip=139.222.131.78; country=GB; region=I9; city=Norwich; latitude=52.6333; longitude=1.3000; http://maps.google.com/maps?q=52.6333,1.3000&z=6 X-CanItPRO-Stream: UEA:outgoing (inherits from UEA:default,base:default) X-Canit-Stats-ID: 66390159 - 66cda7017650 - 20110104 X-Scanned-By: CanIt (www . roaringpenguin . com) on 139.222.131.184 Message-ID: <4D22E7E0.9030700@morningstar2.co.uk> Date: Tue, 4 Jan 2011 09:26:56 +0000 Reply-To: Mailing list for the LaTeX3 project Sender: Mailing list for the LaTeX3 project From: Joseph Wright Subject: Re: \box_if_empty:N(TF) To: LATEX-L@listserv.uni-heidelberg.de In-Reply-To: <20110104084343.GA7767@oberdiek.my-fqdn.de> Precedence: list List-Help: , List-Unsubscribe: List-Subscribe: List-Owner: List-Archive: X-GMX-Antispam: 0 (Mail was not recognized as spam); Detail=5D7Q89H36p4WX0t+AtsdWzrXATe7U7iyEYsVEub6UEScnitTuLsF1TdlrkUKNRhypl1WP P4z9N2hLfJzsGszrlv+ygay/ivx19oyBwO3NEg0raNb/3tCvONPdaWhG3fyrhob4EvcA0r7m4G7q eqN5w==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: 6519 On 04/01/2011 08:43, Heiko Oberdiek wrote: > On Tue, Jan 04, 2011 at 05:11:34PM +1030, Will Robertson wrote: > >> On 04/01/2011, at 8:36 AM, Joseph Wright wrote: >> >>> Working on the galley (see the latest SVN checkin), I find that \box_if_empty:NTF is misleading. The test is for a void box, not an empty one: >>> >>> \box_new:N \l_my_box >>> \hbox_set:Nn \l_my_box {} >>> \box_if_empty:NTF \l_my_box { NOPE } { OOPS } >>> >>> I think it should be \box_if_void:NTF - any objections? >> >> Not at all. >> Is there a need to have an actual empty test? >> Oh wait, this isn't possible, right? > > A non-expandable test is possible: > > \NeedsTeXFormat{LaTeX2e} > \makeatletter > \newbox\test@box > \def\ifboxempty#1{% > \global\let\g@next\@secondoftwo > \ifhbox#1% > \setbox\test@box=\hbox{% > \unhcopy#1\relax > \ifnum\lastnodetype<\z@ > \global\let\g@next\@firstoftwo > \fi > }% > \else > \ifvbox#1% > \setbox\test@box=\vbox{% > \unvcopy#1\relax > \ifnum\lastnodetype<\z@ > \global\let\g@next\@firstoftwo > \fi > }% > \fi > \fi > \g@next > } > \makeatother > > \def\wrong#1{\typeout{WRONG: #1}} > \def\ok#1{\typeout{OK: #1}} > \begingroup > \setbox0=\box0 > \endgroup > \ifboxempty0{\wrong{void is empty}}{\ok{void is not empty}} > \setbox0=\null > \ifboxempty0{\ok{null is empty}}{\wrong{null is not empty}} > \setbox0=\vbox{} > \ifboxempty0{\ok{vbox{} is empty}}{\wrong{vbox{} is not empty}} > \setbox0=\hbox{\write16{}} > \ifboxempty0{\wrong{hbox with write is empty}}% > {\ok{hbox with write is not empty}} > \csname @@end\endcsname\end Thanks for that Heiko: quite a nice idea. One obvious conceptual question is how to treat void boxes. You've gone for 'void boxes are not empty', but this might not be how everyone expects it to be. -- Joseph Wright