From xemacs-m  Sun Jan 26 17:57:22 1997
Received: from synaptics.synaptics.com (synaptics.synaptics.com [207.92.223.3])
          by xemacs.org (8.8.4/8.8.4) with ESMTP
	  id RAA13045 for <xemacs-beta@xemacs.org>; Sun, 26 Jan 1997 17:57:21 -0600 (CST)
Received: (from mail@localhost) by synaptics.synaptics.com (8.7.5/8.7.3) id OAA19602; Sun, 26 Jan 1997 14:55:14 -0800 (PST)
X-Authentication-Warning: synaptics.synaptics.com: mail set sender to <daveg@thymus> using -f
Received: from synaptx.synaptics.com(192.147.44.16) by synaptics.synaptics.com via smap (V1.3)
	id sma019600; Sun Jan 26 14:55:13 1997
Received: from thymus.synaptics.com by synaptx.synaptics.com (4.1/SMI-4.1)
	id AA27891; Sun, 26 Jan 97 15:44:22 PST
Received: by thymus.synaptics.com (4.1/SMI-4.1)
	id AA05340; Sun, 26 Jan 97 15:44:03 PST
Message-Id: <9701262344.AA05340@thymus.synaptics.com>
To: Steven L Baur <steve@miranova.com>
Cc: xemacs-beta@xemacs.org, bug-gnu-emacs@prep.ai.mit.edu
Subject: Re: Oh no, another autoload bug 
In-Reply-To: Your message of "25 Jan 97 22:45:34 PST."
             <m2k9p1vss1.fsf@altair.xemacs.org> 
Reply-To: daveg@synaptics.com
Date: Sun, 26 Jan 97 15:44:00 -0800
From: Dave Gillespie <daveg@synaptics.com>

Steven L Baur writes in xemacs-beta:
> fred.el:
> (setq fred (concatenate 'vector '(1 2 3 4)))
> !! error (("file \"cl-extra\" didn't define \"concatenate\""))

This same bug occurs in GNU Emacs 19.33.

I don't have an up-to-date version of XEmacs installed, but here is
the reason for the bug in 19.33.

In byte-opt.el, the following function attempts to do in Lisp what
do_autoload() does in C:

----
(defun byte-compile-inline-expand (form)
  (let* ((name (car form))
	 (fn (or (cdr (assq name byte-compile-function-environment))
		 (and (fboundp name) (symbol-function name)))))
    (if (null fn)
	(progn
	  (byte-compile-warn "attempt to inline %s before it was defined" name)
	  form)
      ;; else
      (if (and (consp fn) (eq (car fn) 'autoload))
	  (load (nth 1 fn)))
      (if (and (consp fn) (eq (car fn) 'autoload))
	  (error "file \"%s\" didn't define \"%s\"" (nth 1 fn) name))
      (if (symbolp fn)
	  (byte-compile-inline-expand (cons fn (cdr form)))
	(if (byte-code-function-p fn)
	    (progn
	      (fetch-bytecode fn)
	      (cons (list 'lambda (aref fn 0)
			  (list 'byte-code (aref fn 1) (aref fn 2) (aref fn 3)))
		    (cdr form)))
	  (if (not (eq (car fn) 'lambda)) (error "%s is not a lambda" name))
	  (cons fn (cdr form)))))))
----

There is a blatant bug right after the `load' call.  The function
loads the desired file, then checks the *stale* value in `fn' to
see if it has magically transformed away from an `autoload' form.
I don't see how this ever worked.  The C version of do_autoload()
correctly executes Findirect_function() to re-fetch the function
definition after loading.

This bug mysteriously occurs for some functions in cl-extra.el
and not for others.  I eventually tracked it down to inlining:
`concatenate' appears in cl-macs.el in a "proclaim 'inline"
declaration.  Therefore, `byte-compile-inline-expand' is called
for `concatenate' but not for many other cl-extra functions.

The 'inline declaration is in cl-macs.el because I put all
compilation-related CL stuff there, to reduce the impact of the
other files when not compiling.

								-- Dave

