Re: [pro] Style issue about predicates

2011-01-14 Thread Bob Kerns
Dan, my firm-but-not-rabid opinion on this has been formed from decades of tracking down portability bugs, irreproducible bugs, etc. Return 't'. Try to get the contract tightened up to specify t. But so long as the contract is loose, in testing it can be useful to try to inject defects by returni

Re: [pro] Style issue about predicates

2011-01-14 Thread Luke Crook
Daniel Weinreb writes: > > If you have a function that is a predicate, in the sense that > the function's contract says that its value should be interpreted > as being either false or true, do you think it's better to code > it so that it always returns "t" for the true case? > I use '-p' and

Re: [pro] Style issue about predicates

2011-01-14 Thread Scott L. Burson
On Fri, Jan 14, 2011 at 8:42 AM, Daniel Weinreb wrote: > If you have a function that is a predicate, in the sense that > the function's contract says that its value should be interpreted > as being either false or true, do you think it's better to code > it so that it always returns "t" for the tr

Re: [pro] Style issue about predicates

2011-01-14 Thread Mark H. David
No, it should just return "true" (non-nil). It shouldn't guarantee T as a value, nor any particular "true" value. It's wrong for the programmer using a predicate to rely on the "true" value being any particular value, including T. Therefore, doing the (when ... t) thing just makes it return on

Re: [pro] Style issue about predicates

2011-01-14 Thread Ben Hyde
On Jan 14, 2011, at 11:42 AM, Daniel Weinreb wrote: > If you have a function that is a predicate, in the sense that > the function's contract says that its value should be interpreted > as being either false or true, do you think it's better to code > it so that it always returns "t" for the true c

Re: [pro] Style issue about predicates

2011-01-14 Thread Nick Levine
From: Edi Weitz Date: Fri, 14 Jan 2011 17:59:52 +0100 Cc: Sergey Vasilyev , Common Lisp Professionals There are lots of functions in the standard which are predicates in that they return generalized booleans but on the other hand return something "useful" if the resu

Re: [pro] Style issue about predicates

2011-01-14 Thread Edi Weitz
There are lots of functions in the standard which are predicates in that they return generalized booleans but on the other hand return something "useful" if the result is not NIL, e.g. MEMBER or STRING<. I think this is good practice, i.e. return something other than T in case this might make more

[pro] Style issue about predicates

2011-01-14 Thread Daniel Weinreb
If you have a function that is a predicate, in the sense that the function's contract says that its value should be interpreted as being either false or true, do you think it's better to code it so that it always returns "t" for the true case? Since Common Lisp is quite clear that when a value is