I've come across claims that Common Lisp Object System (CLOS) is superior to traditional (class-based) Object-Oriented systems. Wikipedia entry for CLOS mentions differences between the two approaches - mainly multiple dispatch and the separation of classes and methods in CLOS. Are these merely differences or true advantages of CLOS?
Advantages of CLOS over other class-based OO systems
1.8k Views Asked by FilipK At
1
There are 1 best solutions below
Related Questions in OOP
- How do I apply the interface concept with the base-class in design?
- Creating multiple instances of a class with different initializing values in Flutter
- System.InvalidCastException while inheriting a class
- How to add logging to an abstract class in php
- creating cutscenes using OOP and pygame
- What effect does the `virtual` modifier have on an interface member?
- How to pass the value of a function of one class to a function of another with the @property decorator
- Creating a C++ Class Instance for every server request?
- Dart OOP programming
- Containing Object Design
- Clean architecture/OOP and optimization: how to organize for classes with same logic
- How to get 5 LEVEL hierarchy users from database using PHP and MYSQL
- TypeError: unsupported operand type(s) for /: 'property' and 'complex'
- How can I refer to this metaclass inside a metaclass without specifying its name in the code?
- Why customed "-eq" do twice in Powershell?
Related Questions in COMMON-LISP
- UTF-8 string has too many bytes using SBCL and babel on Windows 64 bits
- Common Lisp: How to use a macro within a macro?
- How do I get a notification upon table change with Postmodern in Common Lisp?
- in SBCL why does setting *print-circle* to T in LET in common lisp not work, but SETF does print circular list fine?
- Case statement/form errors?
- unexpected interaction between macroexpand-1 and macrolet
- common lisp type vector of fixnums
- Testing with fiveam
- How to load FRL into Clisp?
- How do I force a CFFI-defined foreign library to use a specific version of a shared library?
- SBCL VLIME use CFFI
- SBCL REPL Wrong Reuse of Cons Cells?
- How do you get the SBCL foreign function interface example from the SBCL User Manual to work?
- Reading hash table from file fails
- do v. do*: Why does the same code produce a different result?
Related Questions in CLOS
- Anonymous methods in common lisp
- Can't variables be used within generic function methods? (CLOS/LISP)
- Diamond inheritance and the Common Lisp Object System
- CLOS make-instance is really slow and causes heap exhaustion in SBCL
- Advantages of CLOS over other class-based OO systems
- Efficient evaluation of spliced lists with a recurring argument
- Undefining a class and all its methods in Common Lisp
- Common Lisp method specialized on symbol - can't use in other packages, can't export?
- specifying a slot value as a key when removing duplicates
- Calling another overloaded method in Lisp
- make-operator returns swindleobject
- Are lambda functions CLOS objects?
- How to use call-next-method in initialize-instance with multiple key arguments CLOS
- How to reduce code duplication using method combination but keeping possible early return
- When is an initform used?
Trending Questions
- UIImageView Frame Doesn't Reflect Constraints
- Is it possible to use adb commands to click on a view by finding its ID?
- How to create a new web character symbol recognizable by html/javascript?
- Why isn't my CSS3 animation smooth in Google Chrome (but very smooth on other browsers)?
- Heap Gives Page Fault
- Connect ffmpeg to Visual Studio 2008
- Both Object- and ValueAnimator jumps when Duration is set above API LvL 24
- How to avoid default initialization of objects in std::vector?
- second argument of the command line arguments in a format other than char** argv or char* argv[]
- How to improve efficiency of algorithm which generates next lexicographic permutation?
- Navigating to the another actvity app getting crash in android
- How to read the particular message format in android and store in sqlite database?
- Resetting inventory status after order is cancelled
- Efficiently compute powers of X in SSE/AVX
- Insert into an external database using ajax and php : POST 500 (Internal Server Error)
Popular Questions
- How do I undo the most recent local commits in Git?
- How can I remove a specific item from an array in JavaScript?
- How do I delete a Git branch locally and remotely?
- Find all files containing a specific text (string) on Linux?
- How do I revert a Git repository to a previous commit?
- How do I create an HTML button that acts like a link?
- How do I check out a remote Git branch?
- How do I force "git pull" to overwrite local files?
- How do I list all files of a directory?
- How to check whether a string contains a substring in JavaScript?
- How do I redirect to another webpage?
- How can I iterate over rows in a Pandas DataFrame?
- How do I convert a String to an int in Java?
- Does Python have a string 'contains' substring method?
- How do I check if a string contains a specific word?
Depends on what you see as advantage.
First CLOS is a class-based object system, compared to non-class-based prototype-oriented object systems. CLOS has classes with multiple inheritance. CLOS objects are instances of classes.
CLOS does not make classes namespaces. CLOS also does not make methods reside inside classes and namespaces of those classes.
This means that CLOS is not message-passing OO. One does not pass a message to some object, where the object then runs the corresponding method.
Historically earlier object systems for Lisp, from which CLOS was developed, started as traditional class-based and message-passing systems (LOOPS, Flavors). With several years of experimentation and research the CLOS model was seen to fit better into Lisp and to be more powerful.
CLOS uses a generic function model, whose main advantage is that it fits better into a functional programming paradigm. CLOS uses function calling of generic functions. The generic function can have more than one argument and can dispatch on more than one argument. This fits into the rest of Common Lisp, since other functions also can have more than one argument. CLOS generic functions can also be passed around, returned from functions or be stored in data structures. So they are also first-class functions. If you find these things (higher-order functions and multiple dispatch) useful, then CLOS has an advantage. Additionally CLOS generic functions are CLOS objects themselves.
A few things then are different from other class-based OO-systems - the lack of a namespace per class and that methods are not organized by class is already mentioned above. Since CLOS is not message-passing OO, forwarding all messages sent to some object to another object does not apply - if there is no message-passing we cannot forward non-existant messages.
One obvious possible advantage is that since CLOS class do not bundle methods and methods can be defined individually, a class and the set of methods is not closed. One can add or remove new methods at any time. This means that for new or changed functionality, one does not need the source code, somehow 're-open' a class or even subclass a class to add the new functionality to a subclass. All that is not necessary in CLOS.
A few other possible advantages:
CLOS has for organizing functionality the generic function. Thus functionality does not need to be scattered around classes, but can be brought together in generic functions.
the dispatch mechanism of CLOS is extremely flexible. At runtime the effective method can be assembled from a set of applicable methods and the assembly can be controlled in almost arbitrary ways. This way new dispatching ways can be implemented by the user without the need to change the underlying implementation. An example is the implementation of Design by Contract. CLOS is so flexible that this can be implemented by a user.
Generally the advanced CLOS implementations are based on the idea that it is a default object system, but allows a wide variety of customizations of the object-system itself. Thus CLOS is defines a region of possible object-systems and not a single fixed one. The default functionality is already quite advanced: multiple inheritance, dynamic updates, multi-dispatch, method combinations, and more.
To read more about the design philosophy of CLOS, the Common Lisp Object System, see these papers: