Newsgroups: comp.lang.clos
Path: cantaloupe.srv.cs.cmu.edu!bb3.andrew.cmu.edu!newsfeed.pitt.edu!gatech!newsfeed.internetmci.com!in2.uu.net!news.sandia.gov!sargon.mdl.sandia.gov!shannon.sandia.gov!user
From: svspire@sandia.gov
Subject: Compile-time method dispatch?
X-Nntp-Posting-Host: shannon.sandia.gov
Message-ID: <svspire-1704961257070001@shannon.sandia.gov>
Sender: news@mdl.sandia.gov (Usenet News Admin)
Organization: Sandia Nat. Labs./New Mexico, IRN
Date: Wed, 17 Apr 1996 19:57:07 GMT
Lines: 37

Is it supposed to be possible in CLOS, through declarations or wrapping
generic functions, to have the compiler do compile-time (static)
method dispatch when it has enough information to do so? For example,
in:

(defmethod a-method ((me foo))
  (do-something-for-foos))

(defmethod a-method ((me goo))
  (do-something-for-goos))

(defmethod static-dispatch1 ((thing foo))
  (a-method thing))

(defun static-dispatch2 (thing)
  (declare (type foo thing))
  (a-method thing))

Should static-dispatch1 or static-dispatch2 compile to
call the appropriate a-method directly, instead of calling
the a-method gf? 

If the compiler did this, you'd probably lose the ability
to redefine the gf or remove methods from it, because it would
be difficult to propagate those changes to callers. So you'd
probably want to do this as a final compilation switch for
maximum speed at the cost of changeability.

(Of course, if you wrote code that could take advantage of this
feature, it might mean you were inappropriately decomposing your
program's functionality, but let's ignore that for the moment.)

Does the standard say anything about this and do any compilers
do it?

Shannon Spires
svspire@sandia.gov
