> How would that have helped? The problem lay in the fact that there
> could be many subclasses of Document, but only one specific subclass,
> Attachment, could go into the attachments[] field. So if we had to
> split the code into two files, we'd have
>
> class Attachment(Document) # <-- attachment.py needs to import from 
> document.py
>  ...
>
> and
>
> class Document
>  def create_attachment
>    self.attachments += Attachment.new() # <-- document.py needs to
> import from attachment.py

What python allows to break the circular dependency is function-level imports:

attachment.py:
from document import Document
class Attachment(Document):
 pass

document.py:
class Document(object):
 def create_attachment(self):
   from attachment import Attachment
   self.attachments += Attachment.new()

I don't think clojure has anything like this; it looks like imports
are at the file-level, rather than the function level as in python.
Perhaps there is a way though?

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en

Reply via email to