Perl6 Objects vs. the Common Lisp Object System
Home : Perl : Perl6
[this is a work in progress. -- rgr, 3-Apr-05.]
Table of contents
- Perl6 Objects vs. the Common Lisp Object System
- Table of contents
- Feature comparison
- Class scoping.
- [finish. -- rgr, 3-Apr-05.]
- Method scoping.
- Perl6 supports lexical and package scoping for multimethods.
Lisp methods, even if named by unexported symbols, are
nevertheless visible globally.
- Local methods and submethods.
- Perl6 has 'em; Lisp does not.
- Anonymous metaobjects.
- Lisp supports anonymous classes and generic functions; Perl6 does
not. Needless to say, this is only useful if you indent to
define methods on them dynamically.
- Multiple vs. single dispatch.
- Perl6 supports separate syntax for both independently (Perl5 had
only single dispatch), but tries to blur the boundaries.
Lisp has only multimethod syntax; if you want single dispatch,
then only specialize the first argument.
[Still trying to figure out the extent of semantic
differences. -- rgr, 3-Apr-05.]
- Typed methods and method combination.
- Lisp has a concept of "method combination," which controls how to
call the matching methods, and how to use their return values;
method combinations are user-extensible, one of which is
specified by each generic function (at least implicitly), and
method combination is done at compile time. Perl6 has no typed
methods, and no explicit notion of method combination, but
provides flexible tools for finding and calling methods at
dispatch time; some aspects of method combination are provided by
the .*, .?, and .+ operators [is this
for single-dispatch only?], which is under the control of the
caller and not the multisub.
- Dispatch specializers.
- Perl6 supports discrimination based only on the class of the
argument, while Lisp additionally supports EQL
specializers, which are essentially singleton classes.
- What the heck is a "multi sub" decl for, given the existence of
"multi method"? -- rgr, 3-Apr-05.
|| These are state variables.
Both languages support a choice of class or instance scope for
a given attribute/slot.
|| This is how methods are named, and is composed of the short or
GF name plus the list of specializers (called the signature in
|| This is how a program invokes multiple-dispatch methods; in
both languages, it looks like an ordinary subroutine call.
|| Within a method, this calls the next applicable method. [is it
possible to change the arglist in perl6? -- rgr, 3-Apr-05.]
||generic function name
|| This is the name invoked by the caller.
|| The restricted type of a multimethod argument, which is said to
be "specialized to that type.
Appendix: Other MMD implementations
Dylan (1996). Dylan draws heavily on CL. However, its MMD
is symmetric (see the
Method Dispatch section of the reference manual),
so it says that methods are "ambiguous" when they cannot be
(2000). This paper has the following quote:
Multiple dispatch is found in Common Lisp [Steele Jr. 1990,
Paepcke 1993], Dylan [Shalit 1997, Feinberg et al. 1997], and
Cecil [Chambers 1992, Chambers 1995].
However, this is less relevant since Java is statically typed.
Interestingly, MultiJava makes the language more dynamic by
introducing open classes. [Maya is
another such system; I find it amusing that there is such a huge
literature devoted to making Java less broken. -- rgr,
$Id: perl6-objects.html 115 2005-06-28 00:31:32Z rogers $