#clojure logs

2008-09-28

00:48scgilardiregarding jmap, prior discussions have pointed out the issue of handling nested Clojure maps. I think that could be handled by whatever "get value for key" method(s) jmap implements, checking for Clojure maps being returned as values and automatically wrapping each one in a new jmap.
01:34yangsxif I use swank-clojure, how should I add clojure-contrib.jar to the path for clojure?
01:37yangsxis adding the jar to ~/.clojure/ the preferred way?
03:05hoeckyangsx: you can use (add-classpath "file:// ...")
03:13yangsxhoeck: indedd
03:13yangsxindeed
09:08ozzileeHas anyone worked on the Clojure java code in NetBeans or Eclipse? There's no way I'm paying $250 for IntelliJ.
09:09ozzileeOr emacs, for that matter.
09:13achim_pozzilee: yeah, i'm using netbeans for that. works just fine.
09:14ozzileeachim_p: Ok, I'll try it. I couldn't get Eclipse to match the... interesting... indentation style.
09:16ozzileeMaybe Eclipse just did interesting things to it, too :-)
09:42achim_phmm, does anybody know how the new print multimethod works? i'm having some problems ...
09:48lisppaste8achim_p pasted "print, ISeq & nth" at http://paste.lisp.org/display/67560
09:51hoeckachim_p: i contributed the print-mm
09:52hoeckachim_p: looks like the destruction in print-sequential is using nth instead of first
09:59hoecklisppaste8: url
09:59lisppaste8To use the lisppaste bot, visit http://paste.lisp.org/new/clojure and enter your paste.
10:01lisppaste8achim_p annotated #67560 with "print-sequential" at http://paste.lisp.org/display/67560#1
10:02rhickeyhoeck: what's the issue there?
10:02achim_phoeck: could this be changed? the paste isn't as elegent as yours, but it should work for all ISeqs, not just ASeqs
10:04achim_prhickey: there's a description of the problem i'm running into in the paste ...
10:04hoecki used destructuring on a seq, which requires the seq to implement nth
10:06rhickeywhat kind of seq?
10:06rhickeynth works on collections that implement sequential
10:06rhickeyclojure.lang.Sequential
10:07achim_pon an arbitrary class that implements ISeq
10:07rhickeywhat arbitrary class?
10:07lisppaste8hoeck pasted "fixed print-sequential" at http://paste.lisp.org/display/67561
10:07achim_pi.e. a proxy [ISeq]
10:08rhickeyproxy [ISeq Sequential]
10:08achim_pit's not about proxies, this was just to illustrate the problem
10:09rhickeybut I want a concrete case
10:10hoeckrhickey: achim_p pasted the problem there: http://paste.lisp.org/display/67560
10:12rhickeyif you want to participate in nth, you have to implement Sequential
10:12rhickeyit's just a marker interface
10:12achim_prhickey: give me a second, concrete case coming up ...
10:15achim_prhickey: here it is: http://www.bitbucket.org/achimpassen/clojure-w-jmap/src/d678f4e0fe4f/src/jvm/clojure/lang/JavaMap.java
10:16achim_pJavaMap$Seq. i need to wrap ISeqs into ISeqs, so i haven't got access to nth (i could cast, though)
10:17rhickeyyou'll get a lot more from implementing ASeq
10:17rhickeyextending
10:18rhickeyall the Clojure seqs do
10:18rhickeyalmost all
10:19hoeckrhickey: but shouldn't the print method be able to print 'raw' ISeqs?
10:20rhickeysure, just wanted to clarify what it takes to get nth support
10:22Guest93833CPL is proving to be a problem for me: it appears to have a lot of license compatibility issues. Are there other licensing options?
10:22rhickeyGuest93833: what are the issues?
10:23achim_prhickey: i'm using JavaMap$Seq to wrap the result of a seq()-call on an APersistentMap, which yields an ISeq. If it's okay to just cast this to an ASeq, i can take advantage of extending ASeq, otherwise it wouldn't help much, would it?
10:23Guest938331. It's incompatible with GPL.
10:23Guest938332. It takes over when used with AFL (which my system uses).
10:23Guest938333. It's incompatible with LGPL (which lots of java coders, stupidly, use).
10:24Guest93833I was really hoping to make a Clojure-based front-end to a large multiagent swarm simulation
10:24Guest93833system that I built and maintain, but it may be out. :-( Kawa I guess.
10:24rhickeyCPL doesn't reach into other parts of a system with which it is interconnected
10:25rhickeyGPL does
10:26Guest93833The takeover issue is: CPL is vague in its notion of "extends". If you hook two pieces of code together, and one is CPL, the other notionally extends it. If this it the case, CPL requires that the entire package be released in a license which contains at least the terms of CPL: that is, a viral license.
10:26rhickeyno one interprets CPL that way
10:26Guest93833And CPL is specifically incompatable with GPL. Not CPL's fault -- GPL is an awful, dark-ages license, but that's life.
10:27Guest93833The state of Virginia does. My system's developed at a state university.
10:27rhickeyUS Copyright law is not state-specific
10:27Guest93833You misunderstand.
10:28Guest93833I am not *permitted* to release code that has open source compatibilities because of legal concerns. Probably you saw this: http://yro.slashdot.org/article.pl?sid=08/09/27/2113248
10:28Guest93833That's my university.
10:29Guest93833"open source compatibilities" -> "open source compatibility concerns"
10:30Guest93833In large institutions, getting your ducks in line open-source-wise is a very big issue, and they're very conservative about it. And CPL has a *lot* of ducks.
10:30rhickeyso you can't use GPL, EPL, MPL either?
10:32rhickeyachim_p: why doesn't JavaMap.seq() just return cmap.seq()?
10:33Guest93833Viral licenses in general are okay. Though in my specific case GPL is out because it's incompatible with AFL, which covers the system I maintain. It depends on how "extends" is interpreted. A word of advice: when trying to gain mindshare, languages benefit form being released under the loosest terms possible. Apache would be a good license choice.
10:34Guest93833Kawa's advantage here is that it's under X.
10:34Guest93833http://www.gnu.org/software/kawa/Software-License.html
10:36rhickeyCPL is not viral, the license does include the word extend, the license specifically states that modules that are separate but distributed together are _not_ contributions, nor are non-derivative works, where derivative is defined by US Copyright law
10:37Guest93833I won't be able to convince my university's lawyers of that.
10:37Guest93833Rosen says it's viral, and that's good enough for them.
10:38Guest93833I think you will find this problem in other institutions as well.
10:38Guest93833:-(
10:38achim_prhickey: ithought it would make sense that a seq of map-entries of a jmap with nested maps returned these nested maps as jmaps
10:38achim_pnote that the code isn't finished, i just uploaded it quickly to show you the problem in context
10:45rhickeyI'm not, at this time, willing to release Clojure under a license with no reciprocity
10:46rhickeyGuest93833: I don't see where Rosen says CPL is viral, he's very complimentary here: http://www.rosenlaw.com/Rosen_Ch08.pdf
10:46Guest93833Well, off to consider other language options then. Crap.
10:47rhickeyI haven't had any license complaints so far
10:52rhickeyachim_p: that's a slippery slope - JMap should be ignorant of what's in it
10:53rhickeyprobably
10:53rhickeyI understand the desire to just jmap the root
11:00achim_prhickey: scgiraldi mentioned the need of nesting: http://clojure-log.n01se.net/date/2008-09-28.html. i personally don't need it at the moment
11:00achim_panother option would be to support nesting only for the java.util.Map-inherited methods
11:19rhickeyachim_p: that makes more sense
11:53Chouserachim_p: I was pondering this earlier (instead of, you know, actually *working* on it) and wondered if it would make sense to pass in to jmap an optional function to be applied on demand to all keys.
11:53Chousersorry, all values
11:54Chouserthis function could, for example, test to see if the value is a map, and wrap it in a jmap -- hense nesting. But it could be used to get other custom behavior as well, while the default would be the simple non-nesting behavior.
11:54Chouser...just a thought. *shrug*
11:55rhickeyI think he might be on the right track in just doing auto JMap-izing in Java's Map APIs
11:56rhickeybut the fn on value access is interesting for maps of delays, which have nothing to do with Java's Map
11:57rhickeyor maps with values reference types
11:57rhickeyauto-deref
11:58Chouserhm, just a general purpose lazy-wrap on maps?
11:59Chousera bit like the map function for seqs
11:59Chousermap-map
12:00rhickeyright, and if I re-introduce Delays-are-IRefs then it could handle Refs/Vars/Agents/Delays uniformly
12:01Chouserif you've have a hash-map of something, you probably know what it is, and passing in the appropriate fn (force, deref, whatever) to map-map wouldn't be a problem.
12:01achim_pChouser: a fn as a value transformer is a nice idea, but i think i'll keep this as simple as possible ;)
12:02Chouserachim_p: not a problem. simple is good.
12:02Chouserrhickey: for ClojureScript? My ports of interfaces are minimal, so not a problem.
12:03rhickeyChouser: good
12:03Chousersince it's all runtime stuff, I just port the name and inheritence. The methods aren't specified.
12:05ChouserI don't have a cljs repl, but I have a js "repl" with the cljs runtime loaded.
12:06Chouserjs> clojure.prn( clojure.hash_map( 1, 2, 3, 4 ) )
12:06Chouserhm, that doesn't quite work yet -- I'm still absorbing the new print-mm stuff
12:07achim_pChouser: besides: i need to transform the keys, too (maps are valid keys), and if i used a user-specified function for this, i had do somehow make sure for it to be ...erm... bijective, otherwise i had to either compute the key transformation for every call to simple ops like size, which is a waste of time, or i had to retain all the keys in memory, which is a waste of space
12:08Chouserachim_p: maps are valid keys in Java maps?
12:10achim_pall objects are
12:11rhickeybut because many of them are mutable the semantics are broken
12:12Chouseroh, do Java APIs modify passed-in maps as a way of communicating back out??
12:12rhickeyno, but if you use a mutable object as a key...
12:15rhickeymutable objects ought to implement equals as identity ==, but often don't in Java. The semantics of that are broken, see :http://home.pipeline.com/~hbaker1/ObjectIdentity.html
12:16rhickeyClojure implements Baker's egal
12:16Chouseryeah, mutable object as a key are scary
12:36scgilardiachim_p: wrapping Clojure maps that would otherwise be returned from java.util.Map-inherited methods is what I intended to recommend. Thanks for considering it.
12:38scgilardirhickey: I'll be attending your MIT talk. I'm looking forward to it.
12:39rhickeyscgilardi: great! will be nice to chat in person
13:47achim_pscgilardi: you're welcome, thanks for suggesting it! i wouldn't have thought of it
13:47achim_pit introduces a minor equality/identity-crisis though :)
13:47achim_phmm, i think my approach is flawed ... since i wrap nested maps on access with disposable flyweights, they can never be equal to anything else (in the java identity sense)
13:48achim_pthat practically means that "containsKey" and "containsValue" would be pretty useless. values obtained via "values" or "keySet" wouldn't be comparable to values later obtained via the same calls.
13:49rhickeyachim_p: why? - 2 things can be equal that are not identical
13:50rhickeyequals for Maps is defined in terms that will allow 2 maps of different concrete types to be equal
14:01achim_pah, i misread you. i thought for the key domain of a java map, it had to be "equal iff identical", but you didn't say that, really.
14:02achim_pi'm sorry for the confusion.
14:03rhickeyequal iff identical should be for mutable maps, but A: Clojure's maps are immutable, and B: java.util.Map defines map equality on (map) value anyway
16:07Chouseroops. Can't use java.lang.* in cljs-emitted code to represent Java stubs, because they can represent real java classes via liveconnect in the browser.
17:37achim_pis .equals(o) not being symmetrical a problem in the java world? the 'two-faced' nature of jmap wrappers turns out to be a bit ugly: if i don't transform the .seq of mapentries, (.equals {:a :b} (jmap {:a :b})) can't be true (it relies on seq).
19:02Chouserrhickey: I think I'm going to try to work up a patch for boot.clj and RT.java that removes all references to java.* classes from the former. Would that be acceptible?
19:03rhickeyChouser: should be
19:06ChouserI don't think I care about clojure.* classes being named.
19:12Chouserhm. or perhaps split boot.clj into genearal and java-specific parts.
19:13rhickeythe problem will be order dependencies
19:13Chouseryeah. meta-tag java-specific defs? *sigh*
19:14rhickeyare there many? encapsulating them in RT is a good idea anyway
19:18Chouserregex, a smattering of io and string stuff, print-methods, array stuff, a couple concurrent classes
19:19ChouserI've been stubbing them out, which would probably be sufficient, except I've now realized that it's actually legal to refer to real Java classes from JavaScript.
19:20rhickeyI saw that - let's encapsulate them
19:20rhickeyIf they are static methods they should inline
19:22ChouserI'm currently also skipping certain boot.clj defs entirely (not emitting js for them), and instead defining using hand-written JS.
19:27ChouserIf I could make my implementation for that less ugly, and make it able to handle defmethods, that might be at least as good.
19:28Chouseralthough if I take that too far I may still have order dependency problems, I suppose.
19:32ChouserI'll look at encapsulation. Any hints on how to handle print-method for Character, Class, BigNumber, etc?
19:34Chouserother that, it looks like a few new RT methods and a few new classes (clojure.lang.StringBuilder, etc?) may do it.
19:34rhickeywoah, why new classes?
19:35Chouserthere are places that make new java.lang.StringBuilder instances -- what should I replace those with?
19:35rhickeyI guess I need to understand better what you are trying to achieve
19:38rhickeywhy wouldn't a call to something like RT.makeStringBuilder() work? It would be typed to return a StringBuilder in Java, your RT function could return anything compatible
19:39Chouseroh, of course you're right.
19:40rhickeymethod handlers use the unadorned class names - are you saying Class or BigInteger will resolve to something else in JS?
20:02ChouserIf there's no Java liveconnect available, java.lang.BigDecimal throws a reference error when evaluated. If there is liveconnect is some kind of JS wrapper around the Java class.
20:06ChouserEither result is probably useless at best for print-method
20:30ChouserI guess I can stub them out if they're undefined, then provide my own print-methods for JS classes.
20:41rhickeythe print-methods could be moved to a separate clj easily, as they are currently last in boot.clj
21:49Chouserhow do you feel about importing RT in boot.clj so I can say (RT/makeException "foo") instead of (clojure.lang.RT/makeException "foo")?
22:06rhickeyit can be imported only after import exists