emacs-devel
[Top][All Lists]
Advanced

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

Re: [PATCH] Add new lisp function length= with bytecode support


From: Gdobbins
Subject: Re: [PATCH] Add new lisp function length= with bytecode support
Date: Sun, 12 Mar 2017 22:51:31 -0400

Attached is a new patch which modifies the byte-interpreter to use C functions for comparing list length to numbers at run-time. It does this by checking if the next bytecode is a comparison op when it encounters a length op. It does not have the problem of incompatibly changing = like the last method. The only remaining incompatible change is forms like (= 0 (length some-long-circular-list)) will now not throw an error, instead they will return nil in byte-compiled code. Similarly for dotted lists. The rare code which does require the error to be thrown can switch to (= 0 (safe-length some-long-circular-list)) to regain the behavior.

This change also makes length= and related then either worse than not having them, or they become trivial:

(defun length= (number list)
  (= number (length list)))

Regardless of if this change is acceptable, I also need to get my copyright assignment done. I'm working on another unrelated patch as well.

-- Graham Dobbins

Attachment: 0001-Optimize-bytecode-interpeter-for-numeric-comparisons.patch
Description: Text Data


reply via email to

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