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 answers
Related Questions in OOP
- php Variable name must change in for loop
- register_shutdown_function is not getting called
- Query returning zero rows despite entries existing
- Retrieving *number* pages by page id
- Automatically closing tags in form input?
- How to resize images with PHP PARSE SDK
- how to send email from localhost using codeigniter?
- Mariadb max Error while sending QUERY packet PID
- Multiusers login redirect different page in php
- Imaginary folder when I use "DirectoryIterator" in PHP?
Related Questions in COMMON-LISP
- php Variable name must change in for loop
- register_shutdown_function is not getting called
- Query returning zero rows despite entries existing
- Retrieving *number* pages by page id
- Automatically closing tags in form input?
- How to resize images with PHP PARSE SDK
- how to send email from localhost using codeigniter?
- Mariadb max Error while sending QUERY packet PID
- Multiusers login redirect different page in php
- Imaginary folder when I use "DirectoryIterator" in PHP?
Related Questions in CLOS
- php Variable name must change in for loop
- register_shutdown_function is not getting called
- Query returning zero rows despite entries existing
- Retrieving *number* pages by page id
- Automatically closing tags in form input?
- How to resize images with PHP PARSE SDK
- how to send email from localhost using codeigniter?
- Mariadb max Error while sending QUERY packet PID
- Multiusers login redirect different page in php
- Imaginary folder when I use "DirectoryIterator" in PHP?
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?
Popular Tags
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)
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: