LATEX-L Archives

Mailing list for the LaTeX3 project

LATEX-L@LISTSERV.UNI-HEIDELBERG.DE

Options: Use Classic View

Use Monospaced Font
Show Text Part by Default
Condense Mail Headers

Topic: [<< First] [< Prev] [Next >] [Last >>]

Print Reply
Sender: Mailing list for the LaTeX3 project <[log in to unmask]>
Date: Thu, 14 Apr 2011 17:22:15 +0200
Reply-To: Mailing list for the LaTeX3 project <[log in to unmask]>
Message-ID: <[log in to unmask]>
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
In-Reply-To: <[log in to unmask]>
Content-Type: text/plain; charset=us-ascii
From: Frank Mittelbach <[log in to unmask]>
Parts/Attachments: text/plain (62 lines)
Will Robertson writes:
 > On 14/04/2011, at 1:14 AM, Joseph Wright wrote:
 > 
 > > Currently, if you do
 > > 
 > >  \prop_get:NnN \<prop-list> { <key> } \<tl var>
 > > 
 > > and the <key> is not in the \<prop-list> then the \<tl var> 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 { <recovery code> }
 > 
 > 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

ATOM RSS1 RSS2