Re: organizing lisp code
- From: Pascal Costanza <pc@xxxxxxxxx>
- Date: Tue, 30 May 2006 23:32:50 +0200
liyer.vijay@xxxxxxxxx wrote:
Hi
Is there any convention for organizing lisp code into different files?
No, there is no convention that you can mechanically follow.
I'm most used to Java where every class goes into it's own files (with
a few exceptions, of course) but that seems overkill in lisp where a
defclass would probably be just a few lines at most.
In Java, a file can also contain several classes, even without inner classes. It indeed makes sense to put helper classes together with the classes they help in the same file even in Java.
So the guideline in Common Lisp is this: Think about what code belongs together because of what it does, not in what construct it is expressed.
As an analogy: In a book, you also don't start a new chapter for each sentence, and there is also no convention how to organize your text into chapters.
In another post, it was discussed that the defgeneric's be in defined
on their own since in CLOS methods don't belong to the classes
themselved.
Again: Organize the code according to its meaning, not its structural properties. Sometimes it is better to define methods close to the classes on which they are specialized, and sometimes its better to collect them all together.
Recall what you use the Visitor pattern for in languages like Java: You use the Visitor pattern so that you can group functionality together. Whenever you would use the Visitor pattern, just group all the methods for a generic function together (and forget about double dispatch and all the ugly details of Visitors ;).
Pascal
--
3rd European Lisp Workshop
July 3 - Nantes, France - co-located with ECOOP 2006
http://lisp-ecoop06.bknr.net/
.
- Follow-Ups:
- Re: organizing lisp code
- From: liyer . vijay
- Re: organizing lisp code
- References:
- organizing lisp code
- From: liyer . vijay
- organizing lisp code
- Prev by Date: xml and s-expression
- Next by Date: Relative merits of Lisp-1 vs. Lisp-2?
- Previous by thread: Re: organizing lisp code
- Next by thread: Re: organizing lisp code
- Index(es):
Relevant Pages
|