[CLJ-1188] Public Java API Created: 30/Mar/13 Updated: 12/Apr/13 Resolved: 12/Apr/13 |
|
| Status: | Resolved |
| Project: | Clojure |
| Component/s: | None |
| Affects Version/s: | None |
| Fix Version/s: | Release 1.6 |
| Type: | Enhancement | Priority: | Major |
| Reporter: | Stuart Halloway | Assignee: | Stuart Halloway |
| Resolution: | Completed | Votes: | 0 |
| Labels: | None | ||
| Attachments: |
|
| Patch: | Code and Test |
| Approval: | Ok |
| Description |
|
Problem: Java consumers need an API into Clojure that does not drag in a ton of concrete implementation detail. Solution: Very small API class that allows looking up Vars (returning IFn), and reading data (as edn). Uses Clojure logic where possible, e.g. Var.intern. Current patch: Also considered:
See also http://dev.clojure.org/display/design/Improvements+to+interop+from+Java |
| Comments |
| Comment by Kevin Downey [ 02/Apr/13 11:34 AM ] |
|
the attached patch would turn ...
public static Var ENQUEUE = RT.var("greenmail.smtp","enqueue");
...
ENQUEUE.fn().invoke(userManager, state.getMessage());
...
in to something like ...
public static VRef ENQUEUE = API.vref("greenmail.smtp/enqueue");
...
ENQUEUE.fn().invoke(userManager, state.getMessage());
...
what is the value of VRefs over using Vars directly? |
| Comment by Kevin Downey [ 02/Apr/13 5:56 PM ] |
|
using this from a java api, it looks like if the namespace the var is in is not loaded when you go to create a VRef it will return null, generally my java code that calls clojure looks something like public static Var FOO = RT.var("namespace", "name");
public static NAMESPACE = Symbol.intern("namespace");
public static Var REQUIRE = RT.var("clojure", "require");
static {
REQUIRE.invoke(NAMESPACE);
}
can you tell me without checking the java/jvm spec if FOO is null? does the static init block run before or after static fields are init'ed? returning null just seems like a bad idea. |
| Comment by Stuart Halloway [ 03/Apr/13 6:53 AM ] |
|
Per discussion on the ticket and with Rich, the wrapper-free approach (Apr 3 patch) is preferred. |
| Comment by Stuart Halloway [ 03/Apr/13 7:03 AM ] |
|
Hi Kevin, The purpose of not returning Vars is outlined in the design discussion. That said, it is possible to return IFn, which does not drag in too much implementation detail (just a javadoc config tweak, see CLJ-1190). Today's patch returns IFn, which addresses the wrapper ickiness demonstrated by your code examples. Java static initializers run in lexical order, and I trust Java programmers to know Java. I can think of several options other than returning null when a var is not available, and they are all complecting, inconsistent with Clojure, or both. |
| Comment by Kevin Downey [ 03/Apr/13 12:08 PM ] |
|
Hey, Always returning the var is very consistent with clojure, it is what RT.var does. It is what the var lookups emitted by the compiler do. RT.var is most likely the point through which most java that calls clojure goes at the moment. As to "hiding" vars, how about creating a clojure.lang.ILink interface with both deref() and fn(), have Var implement it. The previous discussion I see linked all seems to presume hiding Var without discussion of why it should be hidden. What I see Rich saying is:
and
It seems like Rich is suggesting that ILink or whatever should also bring in IFn, but I wonder if having a fn() that does the cast for you is an acceptable alternative to that. |
| Comment by Rich Hickey [ 12/Apr/13 8:24 AM ] |
|
The API should be called var, not fn, and should return IFn. Also, I really want the logic of RT.var (i.e. Var.intern) to be used, not this new logic. Please find another way to handle the string/symbol support. |
[CLJ-1174] Website doc link for 1.4 api docs returns a 404 Created: 05/Mar/13 Updated: 05/Mar/13 Resolved: 05/Mar/13 |
|
| Status: | Resolved |
| Project: | Clojure |
| Component/s: | None |
| Affects Version/s: | Release 1.4 |
| Fix Version/s: | None |
| Type: | Defect | Priority: | Minor |
| Reporter: | Ed O'Loughlin | Assignee: | Tom Faulhaber |
| Resolution: | Completed | Votes: | 0 |
| Labels: | None | ||
| Environment: |
All |
||
| Description |
|
The API docs for Clojure 1.4 (http://clojure.github.com/clojure/branch-clojure-1.4.0/index.html), linked to from http://clojure.github.com/clojure/, returns a 404. I logged it under this category because I can't see anywhere else to log bugs about clojure.org. |
| Comments |
| Comment by Tom Faulhaber [ 05/Mar/13 8:29 PM ] |
|
Fixed. Thanks for pointing this out. |
[CLJ-999] Wrong link in gh-pages index (api-index.html) Created: 18/May/12 Updated: 20/May/13 Resolved: 20/May/13 |
|
| Status: | Resolved |
| Project: | Clojure |
| Component/s: | None |
| Affects Version/s: | Release 1.3 |
| Fix Version/s: | None |
| Type: | Defect | Priority: | Trivial |
| Reporter: | Bogdan Popescu | Assignee: | Tom Faulhaber |
| Resolution: | Completed | Votes: | 0 |
| Labels: | docs, documentation | ||
| Patch: | None |
| Description |
|
The api-index.html includes wrong links for the following:
The links point to pages that do not exist. The problem is that the documentation for those entries is on a "parent" page, for example, the link clojure.core.protocols-api.html#clojure.core.protocols/internal-reduce should have been clojure.core-api.html#clojure.core.protocols/internal-reduce Not a huge bug for me, but you might want to get it fixed. And please give my huge thanks to whoever is in charge of the documentation, I'm the developer behind Dash, a Mac OS X documentation browser, and I was in the process of creating a documentation set for Clojure, and because you guys have an index, you made my work 1000 times easier. |
| Comments |
| Comment by Andy Fingerhut [ 11/Mar/13 3:01 PM ] |
|
Is this fixed now? Tom Faulhaber has regenerated the docs after the recent Clojure 1.5 release, and I think updated other things besides, so it might be. |
| Comment by Tom Faulhaber [ 11/Mar/13 4:43 PM ] |
|
Nope, not fixed. This one either slipped by me or came in right when I was changing jobs so didn't stick in my brain. I'll take a look now. Thanks for the report, Bogdan, and thanks for the bump, Andy to get it on my radar. |
| Comment by Gabriel Horner [ 10/May/13 4:00 PM ] |
|
Tom, I'm happy to help if you need it. Could you document on a wiki page how autodoc is run here? I couldn't find such a page. |
| Comment by Tom Faulhaber [ 20/May/13 4:18 PM ] |
|
This is fixed with gh-pages commit 919143e (autodoc doesn't follow the regular Clojure release path since it's a website built off the source checkins). |
| Comment by Tom Faulhaber [ 20/May/13 4:24 PM ] |
|
Gabriel, Thanks for the offer. I fixed this one, but may take you up on it if more come up. There is currently no wiki page about the autodoc process but it's an excellent suggestion. I'll put it on my list to write something up. In the meantime source on the autodoc program itself is at https://github.com/tomfaulhaber/autodoc and a description of how it works is at http://tomfaulhaber.github.io/autodoc. Two caveats: (1) autodoc is currently undergoing a bunch of work (thus this bug fix) in preparation for a new release and (2) the documentation doesn't talk much about how it's used for documenting Clojure itself. |