5

Given a function that calls not:

(defun my-not (x)
  (not x))

M-x disassemble gives:

byte code for my-not:
  doc:   ...
  args: (arg1)
0       dup       
1       not       
2       return    

I was surprised that this didn't do:

constant not
stack-ref 1
call 1

because otherwise I cannot redefine not and affect the original function.

I imagine this is done for performance. Which functions does apply to, and where it is it documented?

6

If you look at (symbol-plist 'not) you will see that it has a byte-opcode property with value byte-not. So the elisp compiler will use this rather than a general function call.

I have not looked for documentation.

If you look at the lisp/emacs-lisp/bytecomp.el file in the source you will find a whole series of byte-XXXX values which are used in this way, so for example (point-min) is also compiled to a single byte rather than a generic function call.

Your Answer

By clicking "Post Your Answer", you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.