On Jan 23, 2009, at 8:21 PM, e wrote:
Ah hah! I finally understand something. See this is what would really help in the explanation. Something like, "In Java, each file defines only a single outer class, which must have the same name as the file. This simple approach means that there is never any confusion that the last section refers to a class in a given package. Clojure trades simplicity for flexibility. To specify one of the many top-level symbols provided in a namespace, a slash is used to separate it from the namespace" Did I say that right?Nah ..... I still don't see why all dots or all slashes can't be used. In the case that a single file makes up a single namespace, the namespace in clojure equals the outer class in Java, and Java does just fine using dots to get not only to the outer class but to the fields and inner classes. In clojure the last dot gets you to the subdirectory (a.k.a. namespace) .... why can't you just keep on going with one more dot to get to the symbols? And this would work even with more than one file in a namespace. You just couldn't multiply define a symbol w/in the same subdirectory.
Java uses dot separators for many different cases as you've described. In Clojure, a symbol written as x/y always means "the symbol whose namespace part is x and whose name part is y" regardless of the (legal for a symbol) characters that make up x and y. The fact that this is an explicit and simple rule means that working with symbols is fast and unambiguous for both the Clojure reader and compiler and for Clojure programmers.
Given that, it would not be feasible to use slashes to delimit "parts" of a namespace name. Periods are used for that purpose. Period- separated names are pretty and mapping a period-separated name to a location in the filesystem has precedent in Java.
3) yes namespaces can be nested. that's the purpose of the dots, to separate levels of nesting.So it's an error if a file specifies the wrong namespace for where it is in the project hierarchy?
The simple answer is "yes, it's an error". The more complete answer is:If you manage to load a file that contains an ns form that doesn't match its classpath-relative location, the load will succeed. However, if you declare a dependency (:require or :use) on a lib and that lib's file is not located at the correct classpath-relative location, Clojure will not be able to find the file to satisfy the dependency.
--Steve
smime.p7s
Description: S/MIME cryptographic signature