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 p3EFOkum016196 for ; Thu, 14 Apr 2011 17:24:47 +0200 Received: (qmail 6974 invoked by alias); 14 Apr 2011 15:24:41 -0000 Delivered-To: GMX delivery to rainer.schoepf@gmx.net Received: (qmail invoked by alias); 14 Apr 2011 15:24:40 -0000 Received: from relay2.uni-heidelberg.de (EHLO relay2.uni-heidelberg.de) [129.206.210.211] by mx0.gmx.net (mx085) with SMTP; 14 Apr 2011 17:24:40 +0200 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 p3EFMTi2015101 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Thu, 14 Apr 2011 17:22:29 +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 p3EE8PZ4020770; Thu, 14 Apr 2011 17:22:28 +0200 Received: by LISTSERV.UNI-HEIDELBERG.DE (LISTSERV-TCP/IP release 16.0) with spool id 1251476 for LATEX-L@LISTSERV.UNI-HEIDELBERG.DE; Thu, 14 Apr 2011 17:22:28 +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 p3EFMSfi011503 for ; Thu, 14 Apr 2011 17:22:28 +0200 Received: from moutng.kundenserver.de (moutng.kundenserver.de [212.227.126.186]) by relay.uni-heidelberg.de (8.14.1/8.14.1) with ESMTP id p3EFMJvw026959 for ; Thu, 14 Apr 2011 17:22:23 +0200 Received: from morse.mittelbach-online.de (p54A83B39.dip.t-dialin.net [84.168.59.57]) by mrelayeu.kundenserver.de (node=mrbap0) with ESMTP (Nemesis) id 0M5a7E-1Pzaip04S0-00xyUH; Thu, 14 Apr 2011 17:22:19 +0200 Received: by morse.mittelbach-online.de (Postfix, from userid 501) id E149C74EBC; Thu, 14 Apr 2011 17:22:15 +0200 (CEST) MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit References: <4DA5C4E2.8090005@morningstar2.co.uk> <58AFBC3A-4209-4BC0-BB3A-5B14D6B5EFD8@gmail.com> X-Mailer: VM 7.19 under Emacs 21.3.1 X-Provags-ID: V02:K0:gpLo6Wnr6D5WyX/HkYDO8kiGZrVjRMVte9Ao+ySa+h4 Rbo4EVQHXS5co9rbYSnxLqeMNpzYXxAEdQkdGA6EuMbxvVd+UU mZsgVbzvaq0UE0U4FSZIOlImeS2UOvp34zT3L+LUOIe5nw6R5M b/N5ayRMwN5RZk+Sw8K4Wn0FU7AevvSLxWEZX/RIzgTlg9dPXj 4EkGrwMRHx+Rz6tNhOIgQ== X-Spam-Whitelist-Provider: Message-ID: <19879.4391.812139.563636@morse.mittelbach-online.de> Date: Thu, 14 Apr 2011 17:22:15 +0200 Reply-To: Mailing list for the LaTeX3 project Sender: Mailing list for the LaTeX3 project From: Frank Mittelbach Subject: Re: The nature of popping from an empty sequence To: LATEX-L@listserv.uni-heidelberg.de In-Reply-To: <58AFBC3A-4209-4BC0-BB3A-5B14D6B5EFD8@gmail.com> Precedence: list List-Help: , List-Unsubscribe: List-Subscribe: List-Owner: List-Archive: X-GMX-Antispam: 0 (eXpurgate); Detail=5D7Q89H36p6myV/soHys3aIHfn03H1tORw8chlvH7+CLIVDVLJdC3A7HWmxiNCl99tPZj vLkfsDHSaWwEejyK0uImY56FD+y2zj01mvEhVHWeNu4HOW4y/EomXMh+nBk03r95FwBNwK7JWVhX 3oCYSrED5yLl6IETCMux9VhvVSJuIxEhWvQtNsczbX1YfYY3CElNC3ZPP75NJf3/W+xIw==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: 6703 Will Robertson writes: > On 14/04/2011, at 1:14 AM, Joseph Wright wrote: > > > Currently, if you do > > > > \prop_get:NnN \ { } \ > > > > and the is not in the \ then the \ ends up as > > \q_no_value. On the other hand, for sequences trying to 'pop' or 'get' > > from an empty sequence leads to a (deliberate) error. > > > My personal thoughts: > > * These should probably be consistent. yes. if we change the interface then we should do that consistently on all similar functions. > * I think returning a quark is dangerous in case of sloppy package authors. this is a danger, and given that you need to always do a test to ensure that you do not run into this trap we may actually provide the test (ie change the interface). > * I favour a deliberate error message for all in such cases, with a variant > * function for the "error" case; e.g., > > \seq_clear:N \l_tmp_seq > \seq_pop:NN \l_tmp_seq \x > > should yield "Error: The sequence \l_tmp_seq is empty." with the possibility of also writing But I'm not sure that the above function is actually of much use. When could you actually use it? Only if you always know (or think you know) that your sequence is non-empty at the time of the call. Otherwise you would need to use the other function (or in the current system you would need to test after the get). > \seq_clear:N \l_tmp_seq > \seq_pop:NNF \l_tmp_seq \x { } > > in which the recovery code is executed in this case. All in all I think the core functions to switch to are in fact those that get an addition "F" argument? Then the test is being done for you always but you can control its actions. In addition we could provide a predefined error command that you could stick into the F argument \seq_empty_err:N ok ok, that effectively means \cs_new:Npn \seq_pop:NN #1#2 { \seq_pop:NNF #1 #2 {\seq_empty_err:N #2} } in which case we might as well provide that ... :-) frank