From: CRDGW2::CRDGW2::MRGATE::"SMTP::PREP.AI.MIT.EDU::INFO-GNU-EMACS-REQUEST" 14-JUL-1989 01:32 To: MRGATE::"ARISIA::EVERHART" Subj: Bug fix for byte-compile Received: by life.ai.mit.edu (4.1/AI-4.10) id AA01612; Thu, 13 Jul 89 07:36:29 EDT Return-Path: Received: from AENEAS.MIT.EDU by life.ai.mit.edu (4.1/AI-4.10) id AA01566; Thu, 13 Jul 89 07:29:25 EDT Received: from EDDIE.MIT.EDU by AENEAS.MIT.EDU (5.61/4.7) id AA04945; Thu, 13 Jul 89 07:29:20 -0400 Received: by EDDIE.MIT.EDU with UUCP with smail2.5 with sendmail-5.45/4.7 id ; Thu, 13 Jul 89 07:29:00 EDT Received: by think.com (smail2.5) id AA05451; 13 Jul 89 07:29:21 EDT (Thu) Received: from galaxy.compass.com by compass.com (3.2/SMI-3.2) id AA29242; Wed, 12 Jul 89 19:48:55 EDT Received: by galaxy.compass.com (3.2/SMI-3.2) id AA10049; Wed, 12 Jul 89 19:47:14 EDT Date: Wed, 12 Jul 89 19:47:14 EDT From: compass!worley@eddie.mit.edu (Dale Worley) Message-Id: <8907122347.AA10049@galaxy.compass.com> To: info-gnu-emacs@eddie.mit.edu Subject: Bug fix for byte-compile The following code seems to fix the bug in byte-compiling forms whose function is a lambda expression. It does so by rewriting the form into one that uses funcall (not apply!) as the function: ((lambda (...) body) a b c ...) => (funcall '(lambda (...) byte-compiled-body) a b c ...) It seems to work in simple cases. There is probably a better way. Don't forget to byte-compile the fix -- it's the inner loop of the byte-compile functions, which are none too fast! Dale -- Dale Worley, Compass, Inc. worley@compass.com The War on Drugs -- Prohibition for the '80s. (defun byte-compile-form (form) (setq form (macroexpand form byte-compile-macro-environment)) (cond ((eq form 'nil) (byte-compile-constant form)) ((eq form 't) (byte-compile-constant form)) ((symbolp form) (byte-compile-variable-ref 'byte-varref form)) ((not (consp form)) (byte-compile-constant form)) ((eq (car-safe (car form)) 'lambda) (byte-compile-form (cons 'funcall (cons (list 'quote (byte-compile-lambda (car form))) (cdr form))))) ((not (symbolp (car form))) (signal 'invalid-function (list (car form)))) (t (let ((handler (get (car form) 'byte-compile))) (if handler (funcall handler form) (byte-compile-normal-call form))))) (setq byte-compile-maxdepth (max byte-compile-maxdepth (setq byte-compile-depth (1+ byte-compile-depth)))))