CLOS usage
-
- Posts: 447
- Joined: Sat Jun 28, 2008 7:49 am
- Location: Austin, TX
- Contact:
CLOS usage
I was just reading the poll topic in the Books forum about which Lisp book is your favorite. At one point in the discussion, I mentioned that a big difference between ANSI Common Lisp and Practical Common Lisp is the use and coverage of CLOS. Paul Graham doesn't seem to like CLOS and spent only a chapter covering it in ANSI Common Lisp, whereas Peter Seibel uses it all the time in Practical Common Lisp. I thought I'd ask people how much they use CLOS when writing day-to-day programs. In the discussion, feel free to provide some "color commentary" on your answer.
Cheers, Dave
Slowly but surely the world is finding Lisp. http://www.findinglisp.com/blog/
Slowly but surely the world is finding Lisp. http://www.findinglisp.com/blog/
Re: CLOS usage
Personally, I tend not to use CLOS very often. It's not that I have some sort of a l33t spirit -- I just don't fancy object orientation for some projects. In fact, unless I absolutely require the use of OOP to make a meaningful architecture (e.g. I really need inheritance), I tend not to use it at all. Structures, or for some simple cases even simple lists are often more than enough.
I will admit, however, that I do enjoy CLOS when I use it. It's a very complete and powerful feature, and I especialy liked it when I saw it, considering that I was coming from the world of C++.
I will admit, however, that I do enjoy CLOS when I use it. It's a very complete and powerful feature, and I especialy liked it when I saw it, considering that I was coming from the world of C++.
Re: CLOS usage
CLOS is amazingly powerful and above all it's amazingly simple to use when you look at how powerful it is. The other system i have played with, that seemed as friendly in it's approach to Object Orientation was Smalltalk but it didn't feel as natural to me since it enforces a strict OOP style and i tend to find that limiting and harder than it should. CLOS is great because you can use a powerful OO model without having to abandon other programming styles, you can simply mix the best of two worlds when they make sense.
CL-USER> (setf *boss* (make-instance 'smart-person))
NIL
CL-USER>
NIL
CL-USER>
Re: CLOS usage
I tend to use methods with structs more than classes.
Jeff Ober
---
Old programmers don't die; they just parse on...
---
Old programmers don't die; they just parse on...
-
- Posts: 23
- Joined: Sat Jun 28, 2008 11:27 pm
- Contact:
Re: CLOS usage
Hm, I like CLOS and fairly often use objects. However, I prefer using "regular" functions instead of methods wherever methods aren't explicitly neccessary.
Re: CLOS usage
I was originally going to vote for "When it makes sense" (or even a step down), until I realized that I frequently have a print-object method defined for my structs or conditions or whatever, and use conditions, and use defmethod on structs, etc. CL-SQL uses it, and I use that as well.
-
- Posts: 447
- Joined: Sat Jun 28, 2008 7:49 am
- Location: Austin, TX
- Contact:
Re: CLOS usage
"Resistance is futile..."luskwater wrote:I was originally going to vote for "When it makes sense" (or even a step down), until I realized that I frequently have a print-object method defined for my structs or conditions or whatever, and use conditions, and use defmethod on structs, etc. CL-SQL uses it, and I use that as well.

Cheers, Dave
Slowly but surely the world is finding Lisp. http://www.findinglisp.com/blog/
Slowly but surely the world is finding Lisp. http://www.findinglisp.com/blog/
Re: CLOS usage
To my own surprise, because I come from Java, I'm not using clos, only lists, maps, etc, and mostly functions or methods that are functional (no setf). I may be better off moving towards the middle with structs for certain things. But I would like to stay mostly functional.
-
- Posts: 23
- Joined: Sat Jun 28, 2008 11:27 pm
- Contact:
Re: CLOS usage
What speaks against using structs or objects and still do functional programming? A simple example might be the implementation of a binary tree using structs. In spite of using structs there's no reason to use setf or other functions with side-effects...mike wrote:To my own surprise, because I come from Java, I'm not using clos, only lists, maps, etc, and mostly functions or methods that are functional (no setf). I may be better off moving towards the middle with structs for certain things. But I would like to stay mostly functional.
Re: CLOS usage
I agree. I only meant to contrast it more with java where side-effects are commonplace.Alexander Lehmann wrote:What speaks against using structs or objects and still do functional programming? A simple example might be the implementation of a binary tree using structs. In spite of using structs there's no reason to use setf or other functions with side-effects...mike wrote:To my own surprise, because I come from Java, I'm not using clos, only lists, maps, etc, and mostly functions or methods that are functional (no setf). I may be better off moving towards the middle with structs for certain things. But I would like to stay mostly functional.