[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: no empty (zero) string predicate in Elisp

From: Pascal J. Bourguignon
Subject: Re: no empty (zero) string predicate in Elisp
Date: Sun, 26 Apr 2015 06:06:48 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3 (gnu/linux)

Stefan Monnier <address@hidden> writes:

>> 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.

This is exactly what I'm pointing to!  If you want to consider how elisp
intgers are encoded on the native machine, then you definitely want a
zerop function, because there are BEQ and SEQ instructions.

>> 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.

Not in emacs-version "24.3.1"  where I produced the disassembly
provided.  But I'm happy to see it being optimized, this is one more
reason to keep it and use it.

__Pascal Bourguignon__       
“The factory of the future will have only two employees, a man and a
dog. The man will be there to feed the dog. The dog will be there to
keep the man from touching the equipment.” -- Carl Bass CEO Autodesk

reply via email to

[Prev in Thread] Current Thread [Next in Thread]