Top Document: FAQ: Lisp Frequently Asked Questions 3/7 [Monthly posting] Previous Document: [3-15] I'm using DO to do some iteration, but it doesn't terminate. See reader questions & answers on this topic! - Help others by sharing your knowledge Look for problems with your macro definitions, such as a macro that is missing a quote. When compiled, this definition essentially becomes a constant. But when interpreted, the body of the macro is executed each time the macro is called. For example, in Allegro CL the following code will behave differently when interpreted and compiled: (defvar x 10) (defmacro foo () (incf x)) (defun bar () (+ (foo) (foo))) Putting a quote before the (incf x) in the definition of foo fixes the problem. If you use (SETF (SYMBOL-FUNCTION 'foo) ...) to change the definition of a built-in Lisp function named FOO, be aware that this may not work correctly (i.e., as desired) in compiled code in all Lisps. In some Lisps, the compiler treats certain symbols in the LISP package specially, ignoring the function definition. If you want to redefine a standard function try proclaiming/declaring it NOTINLINE prior to compiling any use that should go through the function cell. (Note that this is not guarranteed to work, since X3J13 has stated that it is not permitted to redefine any of the standard functions). ---------------------------------------------------------------- ;;; *EOF* User Contributions:Top Document: FAQ: Lisp Frequently Asked Questions 3/7 [Monthly posting] Previous Document: [3-15] I'm using DO to do some iteration, but it doesn't terminate. Part1 - Part2 - Part3 - Part4 - Part5 - Part6 - Part7 - Single Page [ Usenet FAQs | Web FAQs | Documents | RFC Index ] Send corrections/additions to the FAQ Maintainer: ai+lisp-faq@cs.cmu.edu
Last Update March 27 2014 @ 02:11 PM
|
Comment about this article, ask questions, or add new information about this topic: