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
- Access objects variable & method by name
- Why does compiler recognize while(true) at compile time but not if(true)
- Pass variables to extended class
- Cast a superclass type to a subclass type?
- Understanding difference in Swift properties for structs and classes in assignment
- Does exist any way to force child class to have at least one field with a specified attribute?
- Symfony : is it better to use a trait or an intermediary class to complete Controller one?
- (Java) What kind of argument is this? With a
- C++ Implementing a Queue of cars in OOP
- Inheritance in openERP (odoo)
- missing 1 required positional argument: 'key'
- how can Object class in ruby be an instance of it's subclass, class "Class"
- How to force others to obey a specific layout for a child class?
- Class variables in OOP
- define_method in a class method
Related Questions in COMMON-LISP
- EMACS-Live + Slime error at startup
- Local dynamic binding in common lisp
- Running compiled lisp program with clisp-2.49 on OS X
- What does the non-terminating-p argument of set-macro-character do?
- Updating the window in response to CLIM frame commands
- What is a common-lisp analogue of python's argparse?
- Anonymous methods in common lisp
- Read next line when loading file in Common Lisp
- Calling CCL + Quicklisp script as executable with command line arguments and achieving the desired output
- Jump to function definition in Emacs by mouse-click
- Avoiding echos in Clozure lisp (noob)
- where is the text printed by C printf
- Backquote String Interpolation
- Structuring large Lisp applications
- If strings are vectors, why are they immutable?
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: