From: Rusi <rustompmody@gmail.com>
To: help-gnu-emacs@gnu.org
Subject: Re: no empty (zero) string predicate in Elisp
Date: Sat, 25 Apr 2015 21:26:26 -0700 (PDT) [thread overview]
Message-ID: <3ab93ddc-f437-483f-8b67-79b761f8589b@googlegroups.com> (raw)
In-Reply-To: <mailman.1626.1430016741.904.help-gnu-emacs@gnu.org>
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.
next prev parent reply other threads:[~2015-04-26 4:26 UTC|newest]
Thread overview: 28+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-04-25 3:44 no empty (zero) string predicate in Elisp Emanuel Berg
2015-04-25 9:26 ` Nicolas Petton
2015-05-16 9:23 ` Nicolas Petton
2015-05-16 13:22 ` Bozhidar Batsov
2015-05-16 13:28 ` Bozhidar Batsov
2015-05-16 13:36 ` Bozhidar Batsov
2015-05-16 13:46 ` Eli Zaretskii
2015-05-16 16:17 ` Bozhidar Batsov
2015-05-16 13:43 ` Stefan Monnier
2015-05-16 15:27 ` Drew Adams
[not found] ` <mailman.1583.1429954907.904.help-gnu-emacs@gnu.org>
2015-04-25 11:22 ` Emanuel Berg
2015-04-25 13:30 ` Stefan Monnier
[not found] ` <mailman.1591.1429968677.904.help-gnu-emacs@gnu.org>
2015-04-25 14:48 ` Pascal J. Bourguignon
2015-04-26 2:52 ` Stefan Monnier
2015-04-27 10:28 ` zerop: compiler macro vs defsubst (was: no empty (zero) string predicate in Elisp) Nicolas Richard
2015-04-27 12:19 ` zerop: compiler macro vs defsubst Stefan Monnier
[not found] ` <mailman.1626.1430016741.904.help-gnu-emacs@gnu.org>
2015-04-26 4:06 ` no empty (zero) string predicate in Elisp Pascal J. Bourguignon
2015-04-26 21:25 ` Stefan Monnier
2015-04-26 4:26 ` Rusi [this message]
2015-04-26 12:36 ` Emanuel Berg
2015-04-26 15:03 ` Pascal J. Bourguignon
2015-04-26 18:34 ` Emanuel Berg
2015-04-26 18:59 ` Marcin Borkowski
[not found] ` <mailman.1658.1430074770.904.help-gnu-emacs@gnu.org>
2015-04-26 19:06 ` Emanuel Berg
2015-04-26 20:11 ` Marcin Borkowski
[not found] ` <mailman.1662.1430079142.904.help-gnu-emacs@gnu.org>
2015-04-27 1:00 ` Emanuel Berg
2015-04-26 17:28 ` Rusi
2015-04-26 18:39 ` Emanuel Berg
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=3ab93ddc-f437-483f-8b67-79b761f8589b@googlegroups.com \
--to=rustompmody@gmail.com \
--cc=help-gnu-emacs@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.