From c3fd05a910bf6cd474815bf9f0cae74345ea832c Mon Sep 17 00:00:00 2001
From: gerd <gerd>
Date: Mon, 28 Jul 2003 10:43:15 +0000
Subject: [PATCH] 	CLtS effectively forbids method load-time
 precomputation of 	effective methods (which I think is either yet another
 oversight, 	or bad language design).  Found by Paul Dietz.

	Set *max-emf-precomputation-methods* to > 0 to allow
	precomputation of effective methods at method load-time for
	generic functions having less than the specified number of
	methods.

	* src/pcl/dfun.lisp (*max-emf-precomputation-methods*): Set to 0.

	* src/pcl/pkg.lisp ("PCL"): Export *max-emf-precomputation-methods*.
---
 docs/cmu-user/extensions.tex | 25 +++++++++++++++++++++++++
 general-info/release-19a.txt |  9 ++++++---
 pcl/dfun.lisp                | 10 ++++++----
 pcl/pkg.lisp                 |  5 +++--
 4 files changed, 40 insertions(+), 9 deletions(-)

diff --git a/docs/cmu-user/extensions.tex b/docs/cmu-user/extensions.tex
index 04caff6cd..a50185847 100644
--- a/docs/cmu-user/extensions.tex
+++ b/docs/cmu-user/extensions.tex
@@ -2187,6 +2187,31 @@ provided for forcing such an update of effective methods.
 
 
 
+\subsection{Effective Method Precomputation}
+\cpsubindex{effective method}{precomputation}
+\cpsubindex{methods}{load time}
+\cpsubindex{methods}{emf precomputation}
+
+When a generic function is called, the generic function's
+discriminating function computes the set of methods applicable to
+actual arguments and constructs an effective method function from
+applicable methods, using the generic function's method combination.
+
+Effective methods can be precomputed at method load time instead of
+when the generic function is called by setting
+\code{pcl:*max-emf-precomputation-methods*} to a nonzero number.
+
+\begin{defvar}{pcl:}{*max-emf-precomputation-methods*}
+  If nonzero, precompute effective methods when methods are loaded,
+  and the method's generic function has less than the specified
+  number of methods.
+  
+  If zero, the default, compute effective methods only when the
+  generic function is called.
+\end{defvar}
+
+
+
 \subsection{Sealing}
 \cindex{sealing}
 \cpsubindex{sealing}{subclasses}
diff --git a/general-info/release-19a.txt b/general-info/release-19a.txt
index 57c788e77..f58ad7622 100644
--- a/general-info/release-19a.txt
+++ b/general-info/release-19a.txt
@@ -207,9 +207,12 @@ New in this release:
        called, the generic function PCL:NO-PRIMARY-METHOD is called.
        The default method of this generic function signals a
        continuable error of type PCL:NO-PRIMARY-METHOD-ERROR.
-     - Effective methods are not precomputed at method load time if
-       the generic function has >= PCL::*MAX-EMF-PRECOMPUTATION-METHODS* 
-       methods (default value 100).  This prevents a O(n^3) behavior.
+     - Effective methods are no longer precomputed at method load
+       time, for conformance with CLtS.
+       PCL:*MAX-EMF-PRECOMPUTATION-METHODS* can be set to a number >
+       0 to allow effective method precomputation when the generic
+       function in question has less than the specified number of
+       methods.
 
   * Improvements to Hemlock, the Emacs-like editor:
 
diff --git a/pcl/dfun.lisp b/pcl/dfun.lisp
index 795274d3b..3950af579 100644
--- a/pcl/dfun.lisp
+++ b/pcl/dfun.lisp
@@ -25,7 +25,7 @@
 ;;; *************************************************************************
 
 (file-comment
-  "$Header: /Volumes/share2/src/cmucl/cvs2git/cvsroot/src/pcl/dfun.lisp,v 1.31 2003/07/17 12:40:35 gerd Exp $")
+  "$Header: /Volumes/share2/src/cmucl/cvs2git/cvsroot/src/pcl/dfun.lisp,v 1.32 2003/07/28 10:43:15 gerd Exp $")
 
 (in-package :pcl)
 
@@ -769,9 +769,11 @@ And so, we are saved.
 ;;; 
 (defvar *early-p* nil)
 
-(defvar *max-emf-precomputation-methods* 100
-  "Precompute effective methods only if the generic function
-   has less than this number of methods.")
+(defvar *max-emf-precomputation-methods* 0
+  "Precompute effective methods at method load time if the generic
+   function has less than this number of methods.  The default value
+   of 0 means do not precompute effective methods at method load time,
+   which seems to be the behavior required by ANSI.")
 
 ;;;
 ;;; Try to finalize all unfinalized class specializers of all methods
diff --git a/pcl/pkg.lisp b/pcl/pkg.lisp
index 37f6a2e88..825263939 100644
--- a/pcl/pkg.lisp
+++ b/pcl/pkg.lisp
@@ -26,7 +26,7 @@
 ;;;
 
 (ext:file-comment
-  "$Header: /Volumes/share2/src/cmucl/cvs2git/cvsroot/src/pcl/pkg.lisp,v 1.28 2003/06/17 09:45:40 gerd Exp $")
+  "$Header: /Volumes/share2/src/cmucl/cvs2git/cvsroot/src/pcl/pkg.lisp,v 1.29 2003/07/28 10:43:15 gerd Rel $")
 ;;;
 ;;; CMUCL 18a: Jan-1998 -- Changing to DEFPACKAGE.
 
@@ -92,7 +92,8 @@
 	   "WITH-SLOTS"
 	   )
 
-  (:export "SEAL" "UNSEAL" "SEALED-ERROR")
+  (:export "SEAL" "UNSEAL" "SEALED-ERROR"
+	   "*MAX-EMF-PRECOMPUTATION-METHODS*")
 
   ;; Function names.
   (:export "EFFECTIVE-METHOD" "FAST-METHOD" "SLOT-ACCESSOR"
-- 
GitLab