1

are there any documentation on clojure built-in java method? for example, .toUpperCase from java.lang.String and .indexOf from clojure.lang.PersistantVector.

Is there anyway I can find useful java method without looking at the source code?

3 Answers 3

4

As others have pointed out, you can get the java.* and javax.* documentation online pretty easily as it is part of core Java.

For the clojure.*, your best reference is the source. Even so, I'd recommend not relying on it since this code should really be considered an implementation detail of Clojure. You have no guarantee that the functionality won't change in future versions of Clojure and break any code that depends on it.

Sign up to request clarification or add additional context in comments.

2 Comments

in this question [link] (stackoverflow.com/questions/4830900/…), it seems that using .indexOf is the most simple way to accomplish the job. Should one write his own version in clojure or just use the code in JAVA in such situation?
You should use Java interop for sure when it provides functionality you need (especially for java.* classes which are guaranteed to be available and likely to be backward compatible forever). But I suggest wrapping any interop inside a small utility function so that your main code base is Java-interop free.
2

How about the Java API? All of Java's classes and methods are listed there. That covers all of the "clojure built-in java methods".

On the other hand, Clojure's classes are documented in here, Clojure's API. You have to learn to distinguish between Clojure's classes and Java's classes. All packages starting with java.* or javax.* belong to Java and are documented in the first link. The packages starting with clojure.* are from Clojure, you'll find their documentation in the second link.

4 Comments

apparently I can not find any documentation about clojure.lang.APersistentVector.indexOf(java.lang.Object) in the website you provided
You have to learn to distinguish between Clojure's classes and Java's classes. All packages starting with java.* belong to Java and are documented in the link I provided. The packages starting with clojure.* are from Clojure, you'll find their documentation in Clojure's web page
In particular, the documentation for the class clojure.lang.APersistentVector can be found in here
That answers my question, thanks a lot. Though I'm still curious why they don't document these methods in clojure's classes as they did for clojure core API, or just wrap them in clojure. I have to trace all the way to java.util.List to find out what indexOf does.
2

If the package for the class starts with java or javax then you can look it up in the Java documentation on Oracle's website.

For Clojure implementation classes (where the package name starts with clojure) you are probably stuck with looking at the source code. There is documentation for the intended API (the Clojure language) but not for the Java classes implementing it. You may be able to find some articles (like this one) depending on if what you're looking for is something a blogger has taken an interest in.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.