Re: organizing lisp code



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/
.



Relevant Pages

  • Re: organizing lisp code
    ... Is there any convention for organizing lisp code into different files? ... there is no convention that you can mechanically follow. ... In Java, a file can also contain several classes, even without inner ... Whenever you would use the Visitor pattern, ...
    (comp.lang.lisp)
  • Re: Static vs Dynamic
    ... > AWKWARD solution and compare it to what Lisp does simply and easily? ... powerful capabilities, and did it in almost the same amount of code. ... uncontrolled subclass errors of unknown types, ... We were talking about the Visitor Pattern, ...
    (comp.lang.lisp)
  • Re: [CLOS] Ensuring a method exists
    ... the basic philosophic differences between say Java and Lisp. ... It's a matter of convention. ... There are much better tools (documentation not ... Ship it and let them flee like the dogs they are!" ...
    (comp.lang.lisp)
  • Re: C++ code in a kernel module?
    ... It seems to come up when you try to link C++ code with the C linking ... convention. ... Lisp has jokingly been called "the most intelligent way to misuse a ...
    (freebsd-hackers)
  • Re: Novice: problem with atoms showing up in caps with append
    ... but give the newbies time to lose their old ... >> habits and convince themselves of the goodness of the lisp way. ... > If in our pedagogy we can organize lists of reasons for doing things ... I have this convention since a long time with all programming ...
    (comp.lang.lisp)