Hi Meikel, thanks for your comments!
> Well on the one hand you can define interfaces "by documentation". > Define the interface in the documentation and export the functions > which do things as advertised from your namespace. For interfaces with a single implementation, this sounds fine. And closure/zip is a fine example. But assume I wanto to provide two implementations for such an interface, in two separate namespaces. Can I then write client code that will work with either one? I would have to pass it the namespace as an argument. I wonder if the client code would still remain readable. Perhaps some clever macro would help... Next, assume that I need to use two or more implementations of my interface in parallel, in the same code, just as I can use lists and vectors indifferently with client routines using the seq interface. I guess that is impossible using the "interface-by-documentation" approach, right? > If you are more the "Give a programmer a tree and rope and he will > use them!" type, you can use gen-class from clojure itself and > gen-interface from clojure.contrib to define an opaque interface > and a class implementing the interface. I just looked at gen-class. It looks more like a Java interfacing tool than like a Lispish language construct, but I guess it would do the job. Are there any published examples for using gen-class and/or gen- interface that I could look at for inspiration? Preventing programmers from doing bad things isn't the main issue for me; I am mostly a Python programmer at the moment, and I am fine with Python's "we are all consenting adults" attitude. What I do care about is modularity: being able to write code based on an interface specification and being able to plug in different implementations. A related question concerns the interfaces that Clojure already uses: ISeq and Number, for example. Can I implement my own data structure in Clojure that supports the ISeq interface? Can I implement a new number type and have it work with +, -, etc.? Konrad. --~--~---------~--~----~------------~-------~--~----~ 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 To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/clojure?hl=en -~----------~----~----~----~------~----~------~--~---