Mercurial > hg > xemacs-beta
comparison lisp/cl-macs.el @ 5356:5dd1ba5e0113
Be better about eliminating `block's that are not `return-from'd, bytecomp.el
2011-02-12 Aidan Kehoe <kehoea@parhasard.net>
* bytecomp.el:
* bytecomp.el (byte-compile-initial-macro-environment):
* bytecomp.el (unwind-protect):
* bytecomp.el (byte-compile-active-blocks):
* bytecomp.el (byte-compile-catch):
* bytecomp.el ('return-from-1): Removed.
* bytecomp.el ('block-1): Removed.
* bytecomp.el (byte-compile-block-1): Removed.
* bytecomp.el (byte-compile-return-from-1): Removed.
* bytecomp.el (byte-compile-throw):
* cl-macs.el (block):
* cl-macs.el (return-from):
In my last change, the elimination of `block's that were never
`return-from'd didn't work if `cl-macroexpand-all' was called
explicitly, something much code in cl-macs.el does. Change the
implementation to something that doesn't require shadowing of the
macros in `byte-compile-initial-macro-environment', putting a
`cl-block-name' property on the gensym'd symbol argument to
`catch' instead.
author | Aidan Kehoe <kehoea@parhasard.net> |
---|---|
date | Sat, 12 Feb 2011 14:07:38 +0000 |
parents | 38e24b8be4ea |
children | f00192e1cd49 00e79bbbe48f |
comparison
equal
deleted
inserted
replaced
5355:70b15ac66ee5 | 5356:5dd1ba5e0113 |
---|---|
745 references may appear inside macro expansions and in lambda expressions, but | 745 references may appear inside macro expansions and in lambda expressions, but |
746 not inside other functions called from BODY." | 746 not inside other functions called from BODY." |
747 (let ((cl-active-block-names (acons name (copy-symbol name) | 747 (let ((cl-active-block-names (acons name (copy-symbol name) |
748 cl-active-block-names)) | 748 cl-active-block-names)) |
749 (body (cons 'progn body))) | 749 (body (cons 'progn body))) |
750 ;; Tell the byte-compiler this is a block, not a normal catch call, and | |
751 ;; as such it can eliminate it if that's appropriate: | |
752 (put (cdar cl-active-block-names) 'cl-block-name name) | |
750 `(catch ',(cdar cl-active-block-names) | 753 `(catch ',(cdar cl-active-block-names) |
751 ,(cl-macroexpand-all body cl-macro-environment)))) | 754 ,(cl-macroexpand-all body cl-macro-environment)))) |
752 | 755 |
753 ;;;###autoload | 756 ;;;###autoload |
754 (defmacro return (&optional result) | 757 (defmacro return (&optional result) |
761 "Return from the block named NAME. | 764 "Return from the block named NAME. |
762 This jumps out to the innermost enclosing `(block NAME ...)' form, | 765 This jumps out to the innermost enclosing `(block NAME ...)' form, |
763 returning RESULT from that form (or nil if RESULT is omitted). | 766 returning RESULT from that form (or nil if RESULT is omitted). |
764 This is compatible with Common Lisp, but note that `defun' and | 767 This is compatible with Common Lisp, but note that `defun' and |
765 `defmacro' do not create implicit blocks as they do in Common Lisp." | 768 `defmacro' do not create implicit blocks as they do in Common Lisp." |
766 `(throw ',(or (cdr (assq name cl-active-block-names)) (copy-symbol name)) | 769 `(throw ',(or (cdr (assq name cl-active-block-names)) |
767 ,result)) | 770 (prog1 (copy-symbol name) |
771 (and-fboundp 'byte-compile-warn (cl-compiling-file) | |
772 (byte-compile-warn | |
773 "return-from: no enclosing block named `%s'" | |
774 name)))) | |
775 ,result)) | |
768 | 776 |
769 ;;; The "loop" macro. | 777 ;;; The "loop" macro. |
770 | 778 |
771 (defvar args) (defvar loop-accum-var) (defvar loop-accum-vars) | 779 (defvar args) (defvar loop-accum-var) (defvar loop-accum-vars) |
772 (defvar loop-bindings) (defvar loop-body) (defvar loop-destr-temps) | 780 (defvar loop-bindings) (defvar loop-body) (defvar loop-destr-temps) |