Page 1 of 3

CLOS usage

Posted: Fri Jul 04, 2008 11:23 pm
by findinglisp
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.

Re: CLOS usage

Posted: Sat Jul 05, 2008 12:30 pm
by donkey
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++.

Re: CLOS usage

Posted: Sat Jul 05, 2008 1:02 pm
by AlexPaes
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.

Re: CLOS usage

Posted: Sat Jul 05, 2008 5:09 pm
by Jeff
I tend to use methods with structs more than classes.

Re: CLOS usage

Posted: Sun Jul 06, 2008 7:27 am
by Alexander Lehmann
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

Posted: Tue Jul 08, 2008 6:59 am
by luskwater
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.

Re: CLOS usage

Posted: Tue Jul 08, 2008 7:38 am
by findinglisp
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.
"Resistance is futile..." :D

Re: CLOS usage

Posted: Wed Jul 09, 2008 6:25 pm
by mike
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

Posted: Wed Jul 09, 2008 11:17 pm
by Alexander Lehmann
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.
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...

Re: CLOS usage

Posted: Thu Jul 10, 2008 12:02 am
by mike
Alexander Lehmann wrote:
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.
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...
I agree. I only meant to contrast it more with java where side-effects are commonplace.