all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* bytecomp warning for CL functions
@ 2002-06-24 22:13 Dave Love
  2002-06-24 23:04 ` Miles Bader
  2002-06-25 23:32 ` Richard Stallman
  0 siblings, 2 replies; 24+ messages in thread
From: Dave Love @ 2002-06-24 22:13 UTC (permalink / raw)


[-- Attachment #1: Type: text/plain, Size: 192 bytes --]

This helps to debug the use of the CL package at runtime.  It's not
clean but I couldn't see a better way of doing it quickly and simply
and it serves my purposes.  Perhaps someone else can.


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: Type: text/x-patch, Size: 5114 bytes --]

2002-06-19  Dave Love  <fx@gnu.org>

	* emacs-lisp/bytecomp.el (byte-compile-warning-types): Doc fix.
	(byte-compile-warnings): Doc fix.  Add cl-func option.
	(byte-compile-cl-warn): New function.
	(byte-compile-form): Use it.

*** bytecomp.el.~2.85.~	Tue Aug 21 18:01:57 2001
--- bytecomp.el	Wed Jun 19 15:34:15 2002
***************
*** 1,6 ****
  ;;; bytecomp.el --- compilation of Lisp code into byte code
  
! ;; Copyright (C) 1985, 1986, 1987, 1992, 1994, 1998, 2000, 2001
  ;;   Free Software Foundation, Inc.
  
  ;; Author: Jamie Zawinski <jwz@lucid.com>
--- 1,6 ----
  ;;; bytecomp.el --- compilation of Lisp code into byte code
  
! ;; Copyright (C) 1985, 1986, 1987, 1992, 1994, 1998, 2000, 2001, 2002
  ;;   Free Software Foundation, Inc.
  
  ;; Author: Jamie Zawinski <jwz@lucid.com>
***************
*** 326,335 ****
    :group 'bytecomp
    :type 'boolean)
  
  (defconst byte-compile-warning-types
!   '(redefine callargs free-vars unresolved obsolete noruntime))
  (defcustom byte-compile-warnings t
    "*List of warnings that the byte-compiler should issue (t for all).
  Elements of the list may be be:
  
    free-vars   references to variables not in the current lexical scope.
--- 326,340 ----
    :group 'bytecomp
    :type 'boolean)
  
+ ;; `cl-func' isn't here because it probably should only be defined
+ ;; explicitly.
  (defconst byte-compile-warning-types
!   '(redefine callargs free-vars unresolved obsolete noruntime)
!   "The list of warning types used when `byte-compile-warnings' is t.")
  (defcustom byte-compile-warnings t
    "*List of warnings that the byte-compiler should issue (t for all).
+ Actually, t selects all but `cl-func'.
+ 
  Elements of the list may be be:
  
    free-vars   references to variables not in the current lexical scope.
***************
*** 337,349 ****
    callargs    lambda calls with args that don't match the definition.
    redefine    function cell redefined from a macro to a lambda or vice
                versa, or redefined to take a different number of arguments.
!   obsolete    obsolete variables and functions."
    :group 'bytecomp
!   :type '(choice (const :tag "All" t)
  		 (set :menu-tag "Some"
  		      (const free-vars) (const unresolved)
! 		      (const callargs) (const redefined)
! 		      (const obsolete) (const noruntime))))
  
  (defcustom byte-compile-generate-call-tree nil
    "*Non-nil means collect call-graph information when compiling.
--- 342,358 ----
    callargs    lambda calls with args that don't match the definition.
    redefine    function cell redefined from a macro to a lambda or vice
                versa, or redefined to take a different number of arguments.
!   obsolete    obsolete variables and functions.
!   noruntime   functions that may not be defined at runtime (typically
!               defined only under `eval-when-compile').
!   cl-func     calls to runtime functions from the CL package (as opposed to
!               macros and aliases)."
    :group 'bytecomp
!   :type `(choice (const :tag "All" t)
  		 (set :menu-tag "Some"
  		      (const free-vars) (const unresolved)
! 		      (const callargs) (const redefine)
! 		      (const obsolete) (const noruntime) (const cl-func))))
  
  (defcustom byte-compile-generate-call-tree nil
    "*Non-nil means collect call-graph information when compiling.
***************
*** 1126,1131 ****
--- 1135,1161 ----
  		    (delq calls byte-compile-unresolved-functions)))))
        )))
  
+ (defun byte-compile-cl-warn (form)
+   "Warn if FORM is a call of a function from the CL package."
+   (let* ((func (car-safe form))
+ 	 (library
+ 	  (if func
+ 	      (cond ((eq (car-safe func) 'autoload)
+ 		     (nth 1 func))
+ 		    ((symbol-file func))))))
+     (if (and library
+ 	     (string-match "^cl\\>" library)
+ 	     ;; Aliases which won't have been expended at this point.
+ 	     ;; These aren't all aliases of subrs, so not trivial to
+ 	     ;; avoid hardwiring the list.
+ 	     (not (memq func
+ 			'(cl-block-wrapper cl-block-throw values values-list
+ 			  multiple-value-list multiple-value-call nth-value
+ 			  copy-seq first second rest endp cl-member))))
+ 	(byte-compile-warn "Function from cl package called at runtime: %s"
+ 			   func)))
+   form)
+ 
  (defun byte-compile-print-syms (str1 strn syms)
    (cond
     ((cdr syms)
***************
*** 2377,2383 ****
  	       (funcall handler form)
  	     (if (memq 'callargs byte-compile-warnings)
  		 (byte-compile-callargs-warn form))
! 	     (byte-compile-normal-call form))))
  	((and (or (byte-code-function-p (car form))
  		  (eq (car-safe (car form)) 'lambda))
  	      ;; if the form comes out the same way it went in, that's
--- 2407,2415 ----
  	       (funcall handler form)
  	     (if (memq 'callargs byte-compile-warnings)
  		 (byte-compile-callargs-warn form))
! 	     (byte-compile-normal-call form))
! 	   (if (memq 'cl-func byte-compile-warnings)
! 	       (byte-compile-cl-warn form))))
  	((and (or (byte-code-function-p (car form))
  		  (eq (car-safe (car form)) 'lambda))
  	      ;; if the form comes out the same way it went in, that's

^ permalink raw reply	[flat|nested] 24+ messages in thread

end of thread, other threads:[~2002-07-30 18:46 UTC | newest]

Thread overview: 24+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2002-06-24 22:13 bytecomp warning for CL functions Dave Love
2002-06-24 23:04 ` Miles Bader
2002-06-25 23:32 ` Richard Stallman
2002-06-26 14:10   ` Stefan Monnier
2002-07-01 18:11     ` Dave Love
2002-07-02 19:45       ` Richard Stallman
2002-07-03  7:21         ` Juanma Barranquero
2002-07-08 18:20           ` Richard Stallman
2002-07-18 18:48           ` Dave Love
2002-07-19  6:09             ` Juanma Barranquero
2002-07-19 16:54             ` Richard Stallman
2002-07-08 18:19     ` Richard Stallman
2002-07-18 18:53       ` Dave Love
2002-07-19 16:54         ` Richard Stallman
2002-07-19 17:49           ` Stefan Monnier
2002-07-20  0:35             ` Richard Stallman
2002-07-29 22:46           ` Dave Love
2002-07-30 18:46             ` Richard Stallman
2002-07-08 18:20     ` Richard Stallman
2002-07-08 19:30       ` Luc Teirlinck
2002-07-09 18:51         ` Richard Stallman
2002-07-18 18:34         ` Dave Love
2002-07-19 16:54           ` Richard Stallman
2002-07-22 22:15             ` Dave Love

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.