This is a continuation of a discord discussion. Until the current PR is merged, i’ll post here all issues spotted so far.
- Squeaky Clean is currently missing a project.clj file, as a result it’s not possible to run tests using
lein. A PR for this is already open here
- The above PR also adds a note to task 4 so that all non letters except underscore are cleaned.
Issue not already in PR:
- Squeaky Clean could also be added under the Strings concept.
- In clojure/config.json at main · exercism/clojure · GitHub it is mentioned that “Strings are a sequence of chars”. Since sequences are also a thing in Clojure, this statement will probably make people think that the language treats Strings as sequences, which is incorrect. Clojure strings are nothing more that Java Strings and the
clojure.string functions are directly using the underlying Java methods to achieve better performance. So, i believe a clarification is needed.
These are really good points, thank you!
About the last point, from the Java docs:
Strings, which are widely used in Java programming, are a sequence of characters.
But this does appear to contradict the design notes for clojure.string which clarify that
Strings are objects (as opposed to sequences).
So like, are they sequences, or not? I suppose they are from Java’s point of view, but since Clojure has a specific abstraction known as sequences we should choose a different word.
I’d rather not say “Clojure strings are Java objects” or the like, because it feels like a non-explanation.
Edit: Perhaps just a parenthetical note would work, i.e. (not to be confused with Clojure’s sequences), but it feels a bit clunky for a one-liner.
It’s impossible to know if the Java docs are talking about how a String is implemented or if they are just trying to explain what a String is. In any case, internally a Java String is stored as a
byte array so we can say that it is in fact a Java “sequence”.
clojure.string docs mention that Clojure Strings are objects and that’s also true because they are only referring to the instances of the Java class
String. They are not talking about the internal representation of Strings since this is Java specific.
Bottom line is that Clojure Strings are Java Strings (not Clojure sequences) . If someone wants to treat them as sequences they can call
seq on them and proceed with the more idiomatic way of dealing with them. Many existing clojure functions already do that (
map etc). On the other hand, the
clojure.string functions prefer to bypass the sequence abstraction and treat Strings as Java Strings for performance reasons.