
ELS’18, April 16–17 2018, Marbella, Spain Didier Verna
and in particular guring out whether alternative combinators are
possible or not. As of this writing, the code is in fact already ported
to Cmucl, but surprisingly enough, it doesn’t work as it is. Most of
the tests fail or even trigger crashes of the Lisp engine. It seems that
Cmucl suers from many bugs in its implementation of Pcl, and it
is our hope that xing those bugs would suce to get combinators
working.
One still undecided issue is whether to ke ep long and short forms
implemented separately (as in Pcl), or unify everything under the
long form. We prefer to defer that decision until more information
on how other vendors implement combinations is acquired. The
second issue is on the status of the long form’s lambda-list (currently
deactivated) and consequently whether new combinators should
be represented by new classes or only instances of the general one
(see Section 4.3.1).
As we have seen, the lack of specication makes it impossible to
implement method combinators in a completely portable way, and
having to resort to
reinitialize-instance
is overkill in many
situations, at least in theory. Getting insight on how exactly the
dierent vendors handle applicable and eective methods caches
could give us hints on how to implement method combinators more
eciently, alternative combinators in particular.
Apart from the additional functionality, several aspects of method
combinators and their protocols only ll gaps left open in the Mop.
Ultimately, these protocols (generic function updating notably)
should belong in the Mop itself, although a revised version of it is
quite unlikely to see the day. It is our hope, however, that this paper
would be an incentive for vendors to rene their implementations
of method combinations with our propositions in mind.
Finally, one more step towards full orthogonality in the generic
function design can still be taken. The Common Lisp standard for-
bids methods to belong to several generic functions simultaneously.
By relaxing this constraint, we could reach full 3D separation of
concerns. Method combinators exist as global objects, so would
“oating” methods, and generic functions simply become muta-
ble sets of shareable methods, independent from the way(s) their
methods are combined.
ACKNOWLEDGMENTS
Richard P. Gabriel provided some important fee dback on the history
of method combinations, Christophe Rhodes some documentation
on Sbcl’s internals, and Pascal Costanza and Martin Simmons some
valuable insight or opinions on several aspects of the Mop.
REFERENCES
[1]
Daniel G. Bobrow, Kenneth Kahn, Gregor Kiczales, Larry Masinter, Mark Stek,
and Frank Zdybel. Commonloops: Merging lisp and object-oriented programming.
SIGPLAN Notices, 21(11):17–29, June 1986. ISSN 0362-1340. doi: 10.1145/960112.
28700. URL http://doi.acm.org/10.1145/960112.28700.
[2]
Daniel G. Bobrow, Linda G. DeMichiel, Richard P. Gabriel, Sonya E. Keene, Gregor
Kiczales, and David A. Moon. Common lisp object system specication. ACM
SIGPLAN Notices, 23(SI):1–142, 1988. ISSN 0362-1340.
[3]
Giuseppe Castagna. Object-Oriented Programming, A Unied Foundation. Progress
in Theoretical Computer Science. Birkhäuser Boston, 2012. ISBN 9781461241386.
[4]
Giuseppe Castagna, Giorgio Ghelli, and Giuseppe Longo. A calculus for over-
loaded functions with subtyping. SIGPLAN Lisp Pointers , 5(1):182–192, January
1992. ISSN 1045-3563. doi: 10.1145/141478.141537. URL http://doi.acm.org/10.
1145/141478.141537.
[5]
Linda G. DeMichiel and Richard P. Gabriel. The common lisp object system:
An overview. In European Conference on Object Oriented Programming, pages
151–170, 1987.
[6]
Richard P. Gabriel and Kent M. Pitman. Technical issues of separation in function
cells and value cells. Lisp and Symbolic Computation, 1(1):81–101, June 1988. ISSN
1573-0557. doi: 10.1007/BF01806178. URL https://doi.org/10.1007/BF01806178.
[7]
Richard P. Gabriel, Jon L. White, and Daniel G. Bobrow. Clos: integrating object-
oriented and functional programming. Communications of the ACM, 34(9):29–38,
1991. ISSN 0001-0782.
[8]
Andrew Hunt and David Thomas. The Pragmatic Programmer: From Journeyman
to Master. Addison-Wesley Longman Publishing Co., Inc., Boston, MA, USA, 1999.
ISBN 0-201-61622-X.
[9]
Sonja E. Keene. Object-Oriented Programming in Common Lisp: a Programmer’s
Guide to Clos. Addison-Wesley, 1989. ISBN 0-20117-589-4.
[10]
Gregor J. Kiczales, Jim des Rivières, and Daniel G. Bobrow. The Art of the Metaob-
ject Protocol. MIT Press, Cambridge, MA, 1991.
[11]
Patty Maes. Concepts and experiments in computational reection. In OOPSLA.
ACM, December 1987.
[12]
Kristen Nygaard and Ole-Johan Dahl. The development of the SIMULA languages.
SIGPLAN Notices, 13(8):245–272, August 1978. ISSN 0362-1340. doi: 10.1145/
960118.808391. URL http://doi.acm.org/10.1145/960118.808391.
[13]
Andreas Paepcke. User-level language crafting – introducing the Clos metaobject
protocol. In Andreas Paepcke, editor, Object-Oriented Programming: The CLOS
Perspective, chapter 3, pages 65–99. MIT Press, 1993. Downloadable version at
http://infolab.stanford.edu/~paepcke/shared-documents/mopintro.ps.
[14]
Tim Sheard. Accomplishments and research challenges in meta-programming. In
Walid Taha, editor, Semantics, Applications, and Implementation of Program Gen-
eration, volume 2196 of Lecture Notes in Computer Science, pages 2–44. Springer
Berlin / Heidelberg, 2001. ISBN 978-3-540-42558-8.
[15]
Brian C. Smith. Reection and semantics in Lisp. In Symposium on Principles of
Programming Languages, pages 23–35. ACM, 1984.
[16]
Ansi. American National Standard: Programming Language – Common Lisp.
ANSI X3.226:1994 (R1999), 1994.
A LONG SHORT METHOD COMBINATIONS
The Common Lisp standard provides several examples of built-
in method combinations, and their equivalent denition in long
form
16
. In a similar vein, the macro proposed in Figure 6 denes
method combinations similar to those created with the short form,
only with the following dierences:
(1) the primary methods must not be qualied,
(2) :before and :after methods are available.
As in the original short form of
define-method-combination
,
identity-with-one-argument
is available as an optimization avoid-
ing the call to the operator when a single method is invoked. The
long form’s lambda-list is used to dene the
order
optional argu-
ment, directly passed along as the value of the
:order
keyword to
the primary method group.
B LONG METHOD COMBINATION WOES
This section demonstrates an inconsistent behavior of generic func-
tions using long method combinations in Sbcl, when the com-
bination is redened. First, we dene a
progn
-like long method
combination, ordering the methods in the default, most specic
rst way.
(define-method-combination my-progn ()
((primary () :order :most-specific-first :required t))
`(progn ,@(mapcar (lambda (method)
`(call-method ,method))
primary)))
Next, we dene a generic function using it with two methods.
(defgeneric test (i) (:method-combination my-progn)
(:method ((i number)) (print 'number))
(:method ((i fixnum)) (print 'fixnum)))
16
http://www.lispworks.com/documentation/lw70/CLHS/Body/m_de_4.htm