[Top][All Lists]

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

Removing non `loop' features from cl.el - `cl-map-overlays', `cl-map-int

Subject: Removing non `loop' features from cl.el - `cl-map-overlays', `cl-map-intervals', `cl-map-extents'
Date: Sat, 11 Dec 2010 17:48:47 -0500

cl.el defines `cl-map-extents' as:

(defun cl-map-extents (&rest cl-args)
  (apply 'cl-map-overlays cl-args))

AFAICT its only caller is the `loop' macro.

Is there any reason why `cl-map-extents' shouldn't be defaliased to
Changelog circa 1999-12-18 says:
 (cl-map-extents): Remove compatibility code.

Also, byte-compiling functions which use the `loop' macro to map overlays or
"intervals" of a buffer causes the byte-compiler to warn spuriously about
calling `cl-map-overlays' and `cl-map-intervals' at runtime.

On GNU Emacs 23.2.1 when evaluating the form below:

(let ((auto-save-default nil)
      (make-backup-files nil)
      (backup-inhibited nil))
  (with-temp-file "./extent-interval-cmpl.el"
     "\n\(eval-when-compile \(require 'cl\)\)

\(defun %loop-interval-or-overlay \(&optional olay-or-interval\)
  \(case olay-or-interval
     \(loop for ov being the overlays of \(current-buffer\)
           collecting ov\)\)
     \(loop for iv being the intervals of \(current-buffer\)
           collecting iv\)\)\)\)

\(defun plain-old-loop \(\)
  \(loop for i from 0 to 10 collecting i\)\)

\(provide 'extent-interval-cmpl\)\n"))
  (byte-compile-file "./extent-interval-cmpl.el")
  (delete-file "./extent-interval-cmpl.el")
  (delete-file "./extent-interval-cmpl.elc")
  (with-current-buffer (get-buffer-create "*Compile-Log*")
    (display-buffer (current-buffer) t)))

Following is what *Compile-Log* has to say about things:
| In %loop-interval-or-overlay:
| extent-interval-cmpl.el:8:23:Warning: Function `cl-map-extents' from cl
|     package called at runtime
| extent-interval-cmpl.el:10:16:Warning: assignment to free variable `iv'
| extent-interval-cmpl.el:11:23:Warning: reference to free variable `iv'
| extent-interval-cmpl.el:11:23:Warning: Function `cl-map-intervals' from cl
|     package called at runtime

Can anyone else confirm this behavior?

Unless, I've somehow mucked up my cl-*.el files I find these warnings
to be unbelievably bogus!

There is nothing in `cl-map-overlays' nor `cl-map-intervals' which is specific
to Common Lisp, and whatever compatibility code was in `cl-map-extents' has long
since been removed. AFAIK none of these functions have ever been features
provided by Common Lisp and aren't required for compatibility with Common
Lisp. These were features _added_ by cl.el on top of the `loop' macro.
Likewise, none of thes functions require use of CL style keywords so
its not like
there is anything which would suggest that the "cl-" namespacing is
needed. Regardless it certainly shouldn't be causing the byte-compiler to issue

My impression is that GNU Emacs' policy on use of `loop' macro is that top-level
functions are allowed to contain loop forms without penalty of the byte-compiler
signalling warnings about their expansion at compile-time. Disregarding
whether the rationale behind this policy is entirely reasonable, it is more than
a little hypocritical to enforce explicit constraints on how and when one may
use a feature distributed _with_ Emacs core (inside the
lisp/emacs-lisp directory)
only to penalize users when they attempt to use some non-Common Lisp
feature that
Emacs strapped onto a Common Lisp compatibility library.

Given the existing prejudiced policy regarding use of cl.el at runtime, TRT to
do w/re these and any other similar such `loop' features not explictity provided
for in the CL spec would be to:

 - remove them from the `loop' macro. IOW completely disallow the ability to map
   over buffer overlays and intervals, windows, frames, screens, buffers,
   etc. as none of thse are specific to Common Lisp either (cf Bug#7492 re
   mapping windows and minibuffer frames);

 - move `cl-map-overlays', `cl-map-intervals', and `cl-map-extents' into a
   different namespace;

 - subsitute some other non predjudiced procedure in place of `loop's use of
   `cl-map-overlays' and `cl-map-intervals';

 - subsitute some other non predjudiece procedure in place of `loop's use of
   `cl-map-overlays' and `cl-map-intervals';

>From lisp/ in trunk current through bzr revision 102638 rgrep matches for:

;; cl-map-overlays:

./emacs-lisp/cl-extra.el:273:(defun cl-map-overlays (cl-func &optional
cl-buffer cl-start cl-end cl-arg)
./emacs-lisp/cl-extra.el:314:(defalias 'cl-map-extents 'cl-map-overlays)
./emacs-lisp/cl-loaddefs.el:11:;;;;;;  cl-map-overlays
cl-map-intervals cl-map-keymap-recursively
./emacs-lisp/cl-loaddefs.el:96:(autoload 'cl-map-overlays "cl-extra" "\
./ChangeLog.9:18443:    (cl-map-overlays): Use with-current-buffer.

;; cl-map-intervals:

./emacs-lisp/cl-macs.el:940:                    `(cl-map-intervals
./emacs-lisp/cl-loaddefs.el:11:;;;;;;  cl-map-overlays
cl-map-intervals cl-map-keymap-recursively
./emacs-lisp/cl-loaddefs.el:91:(autoload 'cl-map-intervals "cl-extra" "\
./ChangeLog.9:18441:    (cl-map-intervals): Use with-current-buffer.
Don't check for

;; cl-map-extents:

./emacs-lisp/cl-macs.el:915:                    `(cl-map-extents
./emacs-lisp/cl-extra.el:314:(defalias 'cl-map-extents 'cl-map-overlays)
./ChangeLog.8:268:      (cl-map-extents): Remove compatibility code.


reply via email to

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