From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Rusi Newsgroups: gmane.emacs.help Subject: Re: no empty (zero) string predicate in Elisp Date: Sat, 25 Apr 2015 21:26:26 -0700 (PDT) Message-ID: <3ab93ddc-f437-483f-8b67-79b761f8589b@googlegroups.com> References: <87h9s4rhx5.fsf@debian.uxu> <874mo4jmb7.fsf@kuiper.lan.informatimago.com> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 X-Trace: ger.gmane.org 1430022634 25441 80.91.229.3 (26 Apr 2015 04:30:34 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Sun, 26 Apr 2015 04:30:34 +0000 (UTC) To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Sun Apr 26 06:30:19 2015 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1YmECw-0004ix-2k for geh-help-gnu-emacs@m.gmane.org; Sun, 26 Apr 2015 06:30:18 +0200 Original-Received: from localhost ([::1]:49868 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YmECv-0005s2-7N for geh-help-gnu-emacs@m.gmane.org; Sun, 26 Apr 2015 00:30:17 -0400 X-Received: by 10.66.243.5 with SMTP id wu5mr9409770pac.29.1430022387464; Sat, 25 Apr 2015 21:26:27 -0700 (PDT) X-Received: by 10.50.108.36 with SMTP id hh4mr110945igb.1.1430022387429; Sat, 25 Apr 2015 21:26:27 -0700 (PDT) Original-Path: usenet.stanford.edu!news.glorb.com!l13no10157504iga.0!news-out.google.com!n7ni17288igk.0!nntp.google.com!l13no10157503iga.0!postnews.google.com!glegroupsg2000goo.googlegroups.com!not-for-mail Original-Newsgroups: gnu.emacs.help In-Reply-To: Complaints-To: groups-abuse@google.com Injection-Info: glegroupsg2000goo.googlegroups.com; posting-host=59.88.166.223; posting-account=mBpa7woAAAAGLEWUUKpmbxm-Quu5D8ui Original-NNTP-Posting-Host: 59.88.166.223 User-Agent: G2/1.0 Injection-Date: Sun, 26 Apr 2015 04:26:27 +0000 Original-Xref: usenet.stanford.edu gnu.emacs.help:211718 X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Original-Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.help:104000 Archived-At: On Sunday, April 26, 2015 at 8:22:22 AM UTC+5:30, Stefan Monnier wrote: > > Both for fundamental reasons, cardinals are built from a zero and a > > successor relationship, therefore a predicate for zero is not stupid, > > and a 1+ function neither; > > I know that you can model natural numbers from 0 and successor, but > Elisp integers have very little to do with it and are not encoded in > this way, and there isn't much code around that looks at them this way. > So, as much as I like this way to look at the world, I don't find it > helpful for Elisp. > > > and for optimization reasons on simplistic > > compilers: the hardware usually HAS specific (and optimized) > > instructions to test for zero and another to increment. > > C-h f zerop RET says: > > zerop is a compiled Lisp function in `subr.el'. > [...] > This function has a compiler macro `zerop--anon-cmacro'. > > and if you look at this mysterious zerop--anon-cmacro, you'll see that > it optimizes `zerop' by rewriting it to (= 0 ...), which is implemented > more efficiently. In this case - zero test in elisp - I guess there is not much to argue against Stefan's argument. However in general can be cases where a specialized (curried) test is neat [eg from python] In python 'is' is pointer-equality (eq of lisp) And it is generally recognized that noobs confuse themselves by using 'is' rather than == just as in Lisp equal is usually a safer option than eq. However in some arcane cases 'is' is recommended over == in particular 'x is None' is preferable to 'x == None' [None is like Lisp Nil] With the result that noobs have to use is in that context and confuse themselves. If there were a 'None?' predicate like lisp-null one major source of noob confusion would be avoided.