Q: Is There Any Negation in English Language? A: No!

Started by Kazimir Majorinc, June 12, 2009, 07:36:38 AM

Previous topic - Next topic

Kazimir Majorinc

(exists nil? '(1 2 nil 3)) => nil

(exists nil? '(1 2 3)) => nil




i.e. exists doesn't return sensible result for predicate nil?. I could replace this particular (exists nil? ...) with (find nil ...) but exists also doesn't work for all other predicates satisfied by nil, because returned nil cannot be interpreted. Unfortunately, there are numerous such cases, and some are important.



(exists logical-constant? '(x y z nil true)) => nil




I think that exists should return only true and false (nil), just like its dual for-all. Other part of the functionality, find-the-first-satisfying can be defined independently. (Overloading existing find causes the problems similar to existing ones.) Alternatively, index of the first element satisfying predicate, or even pair (index value) could be returned from exists - instead of value. I guess that one function - one functionality approach has the least chance to cause problems.
http://kazimirmajorinc.com/\">WWW site; http://kazimirmajorinc.blogspot.com\">blog.

Lutz

#1
'exists' always returns the element that meets the condition. In case of 'nil', there is an ambiguity how to interpret the result. BTW R6RS-5.92 defines it the same way, but they don't say anything about this case, and the Schemes I have installed don't have 'exists'.



I think, letting 'exists' only return 'nil' or 'true' instead of the element which mets the condition, would defeat the whole purpose of 'exists'.



It will stay the way its is, but I will mention this ambiguity and how to work around it in the documentation.



In most usage cases of 'exits', we will not look for 'nil' but for something else, if we want to look for 'nil', then 'index' must be used.