#clojure logs

2009-01-07

01:20durkaException in thread "pool-2-thread-2" java.lang.OutOfMemoryError: Java heap space
01:20durkadoes the agent system recover from this?
01:26ChouserI don't think so
01:28durkai think this may be a bug...
01:28ChouserIf it's catchable/preventable, I would agree.
01:28ChouserI've got a simple test case here, just a sec.
01:28durkai saw the exception in the console, but i can't get at it from the REPL
01:28durka(agent-errors nil)
01:29durka(.getQueueCount agt) = 1
01:29durkai meant, (agent-errors agt) = nil
01:29durkaand it normally finishes faster than this...
01:29durkai'll try giving the jvm more memory
01:30lisppaste8Chouser pasted "OOM in agent" at http://paste.lisp.org/display/73224
01:31Chouserdurka: that's probably worth posting to the google group.
01:32durkashall i?
01:32Chouserplease
01:33ChouserI really ought to be in bed.
01:33durkagoodnight then
01:34Chouser:-) g'night
01:34durkaand can i cite your test case?
01:34Chousersure
02:06durkaapparently agents can throw Exceptions, but when they throw OutOfMemoryErrors this weirdness happens
02:09lisppaste8durka annotated #73224 with "more direct test case" at http://paste.lisp.org/display/73224#1
02:14lisppaste8durka annotated #73224 with "more general" at http://paste.lisp.org/display/73224#2
02:14durkacuriouser and curiouser
02:16durkai think maybe there is a "catch (Exception e) {" that should be a "catch (Throwable e) {"
08:06AWizzArdclojurebot: max people
08:06clojurebotmax people is 116
08:08duck1123I would be cool if clojurebot could announce when the record is broken. Does it have hooks for join/parts?
08:09knaprdoes it keep track itself?
08:09knaprGUIs have never been easier than swing+miglayouy+clojure
08:45AWizzArdHow can I convert a collection (vector of numbers between -128 and 127) into a byte array? (to-array col) produces an Object[] and (into-array col) produces an Integer[].
08:45AWizzArd(make-array Byte/TYPE (count col)) returns a byte array of the right size, but I can't fill it via doseq, as (aset ...) requires an index.
08:46AWizzArdrhickey_: would it be difficult to add an optional parameter to to-array that specifies the type?
08:46gnuvince_AWizzArd: (doseq [[i e] (map vector (iterate inc 0) col)] ...)
08:48AWizzArdthx
08:57gnuvince_AWizzArd: you could make that map a function too; I like the name "enumerate" from Python.
09:10knaprIm using a database, now derby but will probably switch to mysql or postgresql because it is a bit slow. however I read about some people storing as binary? what does that mean? storing the records as hashes and then accessing them like that?
09:10AWizzArdknapr: you should try #sql or read an introduction to sql.
10:18rhickeyChouser: (count (reduce #(cons %2 %) [0] (range 4601)))
10:18rhickey4602
10:18rhickeyuser=>
10:18rhickey(count (reduce #(cons %2 %) [0] (range 46010)))
10:18rhickey46011
10:18rhickeyuser=>
10:18rhickey(count (reduce #(cons %2 %) [0] (range 460100)))
10:18rhickey460101
10:18rhickey?
10:20Chouserthat's what mine does too.
10:23rhickeyheh, that was Java 5, on Java 6:
10:23rhickey(count (reduce #(cons %2 %) [0] (range 46010)))
10:23rhickey46011
10:23akingmust vm dependent - I get: java.lang.StackOverflowError (NO_SOURCE_FILE:0)
10:23rhickeyoops:
10:23rhickeyuser=> (count (reduce #(cons %2 %) [0] (range 46010)))
10:23rhickeyjava.lang.StackOverflowError (NO_SOURCE_FILE:0)
10:25durkadid my message to the group go through?
10:32AWizzArdIs there an easy way to convert hex numbers between 0 and FF to a java (unsigned) byte?
10:32rhickeyChouser: I see this as a non-problem - why consing onto vector like that?
10:32rhickeyrepeatedly consing
10:32AWizzArdByte/parseByte only accepts numbers between 0 and 7F
10:35Chouserrhickey: It was reported here, not in my own code. But it seems easy to write code that expects a list and cons's onto it a lot, then to have a user that's using a vector, passes it to your func, and it works a lot of the time but has a landmine lurking.
10:35Chouser*shrug* your call of course.
10:35ChouserAWizzArd: hex numbers encoded as one or two chars in a string?
10:36rhickeyChouser: consing onto non-lists was originally disallowed specifically because of this, but the bottom line is vectors aren't lists
10:36rhickeygenerally, people should use conj
10:36AWizzArdChouser: as one/two chars in a string. (hex-to-signed-byte "F3")
10:38drewolsonhey all, are the "correct" svn repos for both clojure and contrib on google code now?
10:39pdI think the primary clojure-contrib repo is on github now
10:39pdhttp://github.com/kevinoneill/clojure-contrib/tree/master
10:39ChouserAWizzArd: (.byteValue (Integer/parseInt "FF" 16))
10:39ChouserAWizzArd: does Java have such a thing as an unsigned byte?
10:39pdHe also provides a mirror of the clojure svn if you'd prefer a git copy
10:39drewolsonpd: i saw that a while ago, figured it was just a mirror
10:40ChousukeChouser: apparently not
10:40ChousukeChouser: java doesn't seem to have unsigned anything :/
10:40AWizzArdChouser: cool thanks
10:40Chouserpd, drewolson: primary for clojure and contrib are SVN at code.google.com
10:40drewolsonChouser: ok, good, that's what i thought
10:40pdI didn't even know clojure-contrib was on code.google
10:41pdty
10:41ChouserChousuke: I approve. If the complexity of dealing with unsigned numbers was ever worth that one bit, it certainly isn't now.
10:42ChousukeChouser: unsigned types make more sense for size types though. :/
10:43ChousukeAFAIK most sizes in java are ints
10:43Chousukethough even having "primitive" types like ints and longs is somewhat fail.
10:44Chouseryeah
10:46Chouserrhickey: if you're rejecting the patch on the grounds its unnecessary (or for any other reason, really) I'd appreciate very much a firm notification. Here is ok, but on the group is best.
10:47rhickeyChouser: sure, just discussing now, trying to understand the use case and options
10:48Chouserok, wasn't sure if you were done or not. :-)
10:48rhickeyalso the difference between jdk 5 and 6 on this
10:49Chouserhow is it possible that the jvm can avoid the stack overflow. It's clearly a non-tail mutually-recursive function, isn't it?
10:50rhickeyChouser: the JVM optimizer is always free to do TCO, just never promises it will
10:50rhickeyTCO at language level is a promise
10:50Chouserbut it's not even in the tail position
10:51Chouser1+RT.count(_rest)
10:51rhickeyright, this is just some opt
10:51Chouserhuh
10:51rhickeyI agree :)
10:52ChouserI think I'm on OpenJDK 1.6 at the moment. I always forget how to check and change it.
10:57rhickeydurka: fixed
11:00rhickeyChouser: in any case, I think we need Counted marker interface
11:02durkaawesome
11:03Chouserrhickey: it would have other uses?
11:04rhickeyChouser: yes, there are several places where it could help - vector creation for example.
11:04rhickeythat was the reason on the todo list
11:05ChouserI can't get to it anymore
11:06ChouserSo Counted would mean its count() is faster than linear time?
11:07rhickeyChouser: right, Counted indicates O(1) count
11:08danlarkinat the cost of insertion time
11:08rhickeydanlarkin: ?
11:08danlarkinright?
11:08danlarkinI mean, certainly a very small cost
11:09rhickeyno, almost everything in Clojure is Counted
11:09rhickeyalready, just no marker
11:09ChousukeI think he means incrementing the counter instance variable.
11:09rhickeywhatever cost there is to counting is already being incurred
11:12durkais clojure intended for use with java 5 or 6 or either?
11:12rhickeydurka: 5 and up
11:39knaprhttp://paste.pocoo.org/show/98460/
11:39knaprim trying to connect to postgresql
11:39knaprthe database and table is there
11:40knaprso i must be doing something els wrong
11:42knaprah be damned colons!
11:56pjb3just discovered clojure contrib javadoc, very neat
11:57pjb3If you are at a REPL, and you have clojure contrib on your classpath
11:57pjb3(use 'clojure.contrib.javadoc)
11:57pjb3(javadoc String)
11:57pjb3and you get the javadocs for String in a swing frame
12:00Chouserhm, maybe that and the stuff from repl-utils should be combined?
12:02Chousukepjb3: I wish it'd open in Firefox though.
12:02Chousukepjb3: the swing thing is *slow*
12:03Chousukeor at least, was last time I tried. :/
12:03danlarkinChousuke: I just tried it... still pretty slow
12:22triddellI'm trying to port an existing eclipse plug-in to use Clojure instead of Groovy. At runtime I'm currently getting the following stack trace:
12:22triddelljava.lang.ExceptionInInitializerError
12:22triddell at java.lang.J9VMInternals.initialize(J9VMInternals.java:222)
12:22triddell at clojure.lang.Namespace.<init>(Namespace.java:31)
12:22triddell at clojure.lang.Namespace.findOrCreate(Namespace.java:116)
12:23Chouser(with-alter [my-var inc] ...) vs. (binding [my-var (inc my-var)] ...) ?
12:23triddellline 31 of Namespace.java is: mappings.set(RT.DEFAULT_IMPORTS);
12:23triddellwhat is RT in this instance?
12:23Lau_of_DKGood evening gentlemen
12:23Chousertriddell: paste the whole stack trace to paste.lisp.org?
12:24danlarkingood afternoon Lau
12:24kotarakHola, Lau.
12:25lisppaste8triddell pasted "untitled" at http://paste.lisp.org/display/73240
12:28Chousertriddell: the "Caused by:" sections are often pretty key.
12:29rhickeyright:
12:29rhickeyCaused by: java.lang.IllegalArgumentException: URI scheme is not "file"
12:29rhickey at java.io.File.<init>(File.java:377)
12:29rhickeyis the problem
12:30Lau_of_DKHow difficult would it be to make some type of Fly-make for Clojure?
12:31triddelluh, ok, I'm stupid... I had a problem getting the clojure.jar to be found and this was the first error since... didn't pay attention very well... thanks
12:32Chouserit's a shame that slime apparently forces you to specifically ask to see anything more than the final cause.
12:37Lau_of_DKWhats involved in determining which line in the source is producing a given problem ?
12:38Chouserheh, um. It's a process called 'debugging' and is learned via much practice.
12:39Lau_of_DKSo I cant expect to automate it ?
12:40danlarkinSo I have a function in one namespace which calls (require ) a variable number of times based on its arguments. Calling (loaded-libs) in the namespace which calls my require-calling-function shows that the required-libs bleed through. Is there a way I can remove the lib from *loaded-libs* but still return a closure capable of calling a function from inside that lib?
12:40danlarkinugh, that is pretty hard to read isn't it
12:41Chouserloaded-libs is global, isn't it?
12:42Chouseryou asking if there's a way for it to not be?
12:42danlarkinyeah
12:42kotarakside question: wouldn't it make sense to check for the namespace instead of bookkeeping a list in require?
12:44Chouserthat would only exacerbate danlarkin's problem.
12:44cgrandChousuke, danlarkin: which JRE are you using and which OS? (clojure.contrib.javadoc/javadoc try to use a real browser before opening the swing browser)
12:45Chousukecgrand: Java 1.5, Mac OS 10.5.6
12:45danlarkincgrand: same as Chousuke
12:46ChousukeI guess finding the native browser does not work on OS X java.
12:46cgrandwell it requires java 6 ...
12:46Chousukeright.
12:47kotarakOn OS X it's just "open <url>"...
12:47Chouserooh, works here -- javadoc comes right up in firefox.
12:47Chousuketrue.
12:47ChouserUbunutu
12:48Chousukemaybe add a check for OS X and use the system "open" instead of java stuff :/
13:04jomaI must say jdbc+postgresql+pgadminIII+clojure rocks
13:05Chousukeyay, works
13:08mfredricksontechnomancy: ditto. i was looking at that yesterday. neat stuff
13:09technomancyseems like you could use it for persistence instead of an RDBMS
13:10jomause what instead of rdbms?
13:10technomancyuse terracotta
13:20gnuvince_What's terracotta?
13:21technomancygnuvince_: it's a transparent clustering/persistence mechanism for the JVM
13:22technomancyyou just tell it what data to track, and it makes it available to any JVMs in the cluster as if it were local
13:23gnuvince_That's pretty cool
13:24gnuvince_I'm looking at their web page: you just write your program exactly as you would and it automagically becomes clustered?
13:25technomancyyou need to give it a little help just to tell it which pieces of data you want to share... maybe also tell it what terracotta server to connect to
13:25technomancybut it's really simple
13:27technomancyhaven't actually *used* it yet; just read about it.
13:27gnuvince_ok
13:37Chousukehm
13:38jomaim using contrib.sql and it seems im evaing the functions outside the scope of the connection which means I should just pass the statement but eval it inside the function. so how can I do that? i pass (do-statement #(statm)) instead of (do-statement (statm))?
13:38jomaim asking becasue i cant test right now, damn windows
13:38Chousukemy hack to contrib.javadoc is far from optimal, but here it is for the mac users: http://code.google.com/p/clojure-contrib/issues/detail?id=2
13:39ChousukeI didn't even bother searching for a 1.5 cross-platform solution :/
13:40Chousukenow it only needs some way to set the documentation URL to 1.5 instead of 1.6...
13:41Chousukemakes me think; would a OS identification library be useful for contrib?
13:47philscottedIs there some variable that is always bound to the last expression evaluated at the REPL, like * in CL?
13:48Chousukephilscotted: *1, *2, *3, *e (last exception)
13:50philscottedCheers! Sorry, I'm sure it's in the documentation somewhere, but I hadn't come across it.
13:50gnuvince_technomancy: about terracotta, does an instance of the application pick one of the terracotta server to execute on?
13:50philscottedAck. Just found it. Right at the top of the API page.
13:51technomancygnuvince_: I don't think so.
13:51technomancyI've only done the most cursory of examinations though.
13:51gnuvince_ok
13:52gnuvince_I'm wondering if it's the kind of thing were you add a new box, update the XML file and boom, you have more processing power to accomodate and larger number of concurrent users.
13:56triddellrhickey: looking back at this paste: http://paste.lisp.org/display/73240 is it possible that this error is caused by the clojure classloader within an eclipse/equinox/osgi environment? The error occurs when trying to initialize the first clojure-based class: solo.Generator on line 6
14:00Lau_of_DKCan someone here show me how to put 'binding' to good use?
14:00leafwLau_of_DK: ?
14:01leafwyou mean a good usage case?
14:01leafwthe archetypical is for redirecting stdout
14:01Lau_of_DKOk
14:01Lau_of_DKbrb
14:02leafw(binding [*out* (.getSomeStdout an-instance)] .... any code .... )
14:03leafwany calls to println in any of the code called within the binding block will use that *out*
14:03leafwincluding from other functions indirectly called by functions within the block.
14:04Lau_of_DKk
14:04Lau_of_DKThanks
14:04knaprhttp://paste.pocoo.org/show/98475/
14:04leafwStuart's book calls it "acting at a distance", because it lets you redefine just about anything.
14:04knaprhow do I replace that annoyingly ugly loop?
14:05gnuvince_(doc reduce)
14:05clojurebotf should be a function of 2 arguments. If val is not supplied, returns the result of applying f to the first 2 items in coll, then applying f to that result and the 3rd item, etc. If coll contains no items, f must accept no arguments as well, and reduce returns the result of calling f with no arguments. If coll has only 1 item, it is returned and f is not called. If val is supplied, returns the result of app
14:06gnuvince_knapr: with that
14:06leafwknapr: with map, likely, since you accumulate results into a vector. Just call vec on the resulting list from map.
14:07Chouser(reduce conj [] res)
14:08Chouserknapr: ^^
14:08Chouserknapr: except your loop stops when it finds a nil inside res, or reaches the end of res
14:08Chouser...while that reduce will include any nils, stopping only at the end.
14:08Chouseroh, even better: (into [] res)
14:11knaprwhat is the standard return-value for sideeffectful functions in Clojure? return nothing? it seems it is to return nil whihc I hate since nil==false
14:11knaprreturning true makes more sense
14:12gnuvince_knapr: a function returns the value of its last expression
14:12danlarkinknapr: perhaps have it return what it has affected
14:12gnuvince_If your last expression is a println, that'll be nil.
14:13knaprbut lets say evaling statements into a database
14:13knaprexamplemin contrib.sql returns nil
14:13knaprid rather have true
14:13knaprwhat is idiomatic?
14:15ChouserI don't know that there's a strong idiom
14:15Chouserprint and friends return nil
14:15Chousersend and send-off return their first arg
14:16leafwChouser: ref and agent -friendly functions return always the first arg ... because it's the ref itself.
14:18ChouserI use the return value from 'send' about as often as the return value from 'print'
14:18knaprChouser: anyway why cant I just return res directly but have to perform that function?
14:20StartsWithK_triddell: do you have a working osgi bundle using clojure? if so, i would like to know how you created it
14:20Chouserknapr: with-results uses resultset-seq, which is a lazy seq over query results
14:22triddellStartsWithK_: not yet, working one right now
14:23StartsWithK_triddell: how far did you go? like, can you register clojure.jar as separate bundle and have it work with another that has some clojure code in it?
14:23StartsWithK_or you have to include clojure.jar with your own bundle
14:27triddellStartsWithK_: I'm building an eclipse plugin right now and I've tried separate bundles an d combined. I think I have a classloading issue as soon as a clojure compiled class is called.
14:27triddellRIght now trying to add: Class.forName("clojure.lang.RT") in bundle's start() according to this: http://groups.google.com/group/clojure/browse_thread/thread/d8e577b5bf41c1bb/4202854a7ed14aca?lnk=gst&amp;q=osgi#4202854a7ed14aca
14:28triddellBut it's not working yet
14:28StartsWithK_i had the same problem
14:28StartsWithK_"solved" it by including clojure.jar with my bunde, but had to do that for every bundle
14:29StartsWithK_and i couldn't make it talk with other bundles, classloader problem
14:29triddellwere you creating an eclipse plug-in or an osgi bundle?
14:30StartsWithK_i tried equinox and knoplerfisg as osgi containers with clojure, none worked
14:30StartsWithK_i wanted to use osgi in my app
14:32StartsWithK_at the end i was able to create one mega bundle with everything inside it, no dependencies to other bundles.. not much point in that so i gived up
14:34triddellStartsWithK_: bummer... well I'm still banging my head on it.. for this app one bundle should work ok, since I'm just one of many bundles inside eclipse... I can see how it wouldn't work out for you... Do you have a Manifest from your mega-bundle that worked for reference?
14:35StartsWithK_triddell: sorry i don't, it was couple of months ago and i deleted it.
14:35triddellStartsWithK_: np, you've given me some hope though :-)
14:37StartsWithK_triddell: biggest problem was using (proxy), when i would create object with it and used it as argument to method with object from another bundle, i would get strange classloader errors
14:37StartsWithK_maybe creation of such proxy object should go inside (binding [*use-context-classloader* true] ..)
14:37StartsWithK_i don't know, its not documented anywhere how to use it
14:39ChouserStartsWithK_: It's likely the way proxy creates and loads classes may have changed since you tried.
14:39triddellI'm not using Proxy so I might not run into that.
14:40StartsWithK_Chouser: Problem is that when proxy object (maybe even a normal one) is created in one bundle it gets his classloader from RT, and then when used it another bundle it still remember its old classlader, but osgi will change that during objects lifetime
14:41StartsWithK_i don't think that changed, there is still one classloader that RT initializes in its static part
14:49kotarakCould this be considered a bug? (use/require :reload some.name.space) does not reload files included with load.
14:50ChouserStartsWithK_: but now you have the option of AOT compiling code, including the proxy, and then no special classloader is needed at runtime, even if you use a new proxy definition (as long as it has the same base classes as an already-compiled proxy)
14:51StartsWithK_Chouser: is then *use-context-classloader* unused now? if it was used before for anything
14:52rhickeyStartsWithK_: yes, it is still used
14:53StartsWithK_rhickey: can you explain how it should be used
14:54rhickeyone of the problems I have with people using osgi for Clojure is I never get a sense of why - i.e. what is the objective, or is some environment forcing it? Also, where is there a short description of how osgi supports dynamic bytecode?
14:55StartsWithK_by environment: glassfish v3 and eclipse, apache felix is ported do android
14:56StartsWithK_netbeans uses something similar to serviceloader from java6, but serviceloader uses same classloader for 'bundles' as for main app
14:56rhickeyAOT-compiled Clojure should look like any other Java app
14:57rhickeyClojure is not a service, so sharing it between modules would be an encapsulation violation - probably want one instance of Clojure per module
14:58StartsWithK_scala is not a service, but you can use scala standard library as osgi bundle (requires small change to manifest file)
14:58StartsWithK_it dosn't need to have any special osgi support in it
14:59StartsWithK_any .jar can be converted to osgi bundle by adding extra metadata to manifest
14:59StartsWithK_it then is not registered as service, more like its on 'classpath' for other bundles
15:00rhickeyscala is a static language whose namespaces are java packages. Clojure is a dynamic language whose namespaces are in data structures you might not want to share
15:00rhickeybut if you did you could
15:00rhickeyseems like most osgi problems relate to dynamic bytecode, not a nissue for scala
15:00StartsWithK_only requirement i could find is that any code in it dosn't hold on to his classloader
15:00Chousukehm
15:01rhickeyStartsWithK_: right, but there is no standard classloader that loads bytecode from bytes publicly, so dynamic bytecode requires custom classloader
15:01waltersrhickey: basically the java classpath and package concepts just aren't good enough as a module system
15:01StartsWithK_well i can take jetty.jar and turn it to osgi bundle, and jetty has no direct osgi support, or log4j or any other 'normal' jar
15:02rhickeyStartsWithK_: and when you take AOT clojure.jar what happens?
15:02StartsWithK_i haven't tired, it was long before AOT
15:02StartsWithK_i should create new test suits with AOT
15:03StartsWithK_but it was such a pain last time to try all the combinations
15:03rhickeyI'd much rather someone who understands how osgi supports dynamic bytecode would point me to a short reference
15:04StartsWithK_i'm not that someone :) but i'll try to find slides from knoplerfish project that have some problems outlined in them
15:04jomahttp://paste.pocoo.org/show/98494/
15:05jomawhy doesnt that work when (Hmm) does?
15:05joma(hmm)
15:05jomaah wait
15:07jomawell that returns nil
15:07jomabut doesnt happen
15:11jomahow do I call getNextException ?
15:12gnuvince_Is there a quick tutorial on java.util.concurrent so that I could know what's in it?
15:13gnuvince_I know Rich often recommends using it
15:16philscottedAnyone know if this issue has been resolved? http://groups.google.com/group/clojure/browse_thread/thread/43a413ae55ed25d0
15:16philscottedI'm adding a jar file with add-classpath but imports are not working.
15:16philscottedHowever, I can refer to the classes by their fully qualified names.
15:18danlarkinlisppaste8: url
15:18lisppaste8To use the lisppaste bot, visit http://paste.lisp.org/new/clojure and enter your paste.
15:19lisppaste8danlarkin pasted "refactoring help" at http://paste.lisp.org/display/73247
15:20danlarkinso in the patterns function I just pasted I have the same (let ) block on lines 16 and 23
15:20danlarkinbut I am not sure how to remove the duplication
15:22StartsWithK_rhickey: i don't know if it helps, http://www.eclipsecon.org/2008/?page=sub/&amp;id=145 link to pdf is under the title
15:24kotarakI think I found a bug: when using AOT compilation (require :reload-all 'some.name.space) does not correctly reload all "loaded" files! Only the master file of the namespace gets reloaded.
15:31jomahow do I call getNextException ?
15:31kotarakHow is the general procedure regarding the Issue Tracker? Should I post this to the list or should I add an issue?
15:32kotarakjoma: I'm not sure, what need, but that should give you a start: http://clojure.org/java_interop
15:32Chouserkotarak: it seems like that may be the current intended behavior. If there's any doubt at all as to whether it should be fixed, I think the list the right place to start.
15:32rhickeykotarak: for that one, please create an issue, then post on the list with a link to issue - thanks
15:33rhickeyStartsWithK_: not any help
15:33kotarakrhickey: ok, will do.
15:34rhickeyChouser: I'm sure it doesn't work, but reloading needs to be addressed - right now the built-in make-like logic prevents reloading
15:34triddellStartsWithK_ and rhickey: I think I just found a major issue with clojure on equinox/osgi. I now have a working eclipse plugin with clojure.
15:34rhickeyChouser: you
15:34rhickeyChouser: your advice still generally correct, I pre-approve this report
15:34Chouserheh, ok.
15:35rhickeytriddell: what's the trick
15:35rhickey?
15:35StartsWithK_triddell: yes, share please
15:36triddellrhickey: In RT.java, lastModified function... url.getProtocol() checks for "jar" and if it doesn't get it falls through to file... this produces:
15:36triddellCaused by: java.lang.IllegalArgumentException: URI scheme is not "file" at java.io.File.<init>(File.java:377) at clojure.lang.RT.lastModified(RT.java:351)
15:36triddellif I force the "jar" line: I get:
15:37triddellCaused by: java.lang.ClassCastException: org.eclipse.osgi.framework.internal.core.BundleURLConnection incompatible with java.net.JarURLConnection at clojure.lang.RT.lastModified(RT.java:347)
15:37triddellif I just return 1 it works!
15:38rhickeydo BundleURLConnection and JarURLConnection share any superinterfaces?
15:39triddellI'm only within one bundle at this point but I was getting the same initial error when using multiple bundles
15:39triddellnot sure, didn't check into that yet... will do though
15:39StartsWithK_clojure.jar is inside your bundle? or separete one?
15:39triddellthe protocol also must be returning something other than "jar" as well
15:40triddellStartsWithK_: inside right now, but was getting same initial before
15:40triddellinitial error
15:44triddellrhickey: no interface but base class java.net.URLConnection it appears
15:46rhickeytriddell: fixed hard else to File in lastModified - svn 1200
15:47zakwilsonIs anybody using Clojure with the current CVS version of Slime? I'm having a problem.
15:48Chousukezakwilson: let me guess: no fancy repl?
15:48jomaHOW DO I CALL getNextException?
15:48zakwilsonChousuke: yes.
15:48Chousukezakwilson: wait a moment
15:49Chousukehttp://github.com/Chousuke/dotfiles/tree/master/Aquamacs-customizations.el#L59 you need that
15:49kotarakjoma: 21:30 joma: I'm not sure, what need, but that should give you a start: http://clojure.org/java_interop
15:50zakwilsonChousuke: Thanks. I'll give that a try.
15:54zakwilsonProblem solved. Adding slime contrib and running slime-repl-init fixed it. Thanks Chousuke.
15:54triddellrhickey: that did it, thanks!
15:55Chousukecgrand: your fix for OS X works too.
16:00jomahow do I call printStackTrace?
16:00Chousukejust call it?
16:00Chousuke(.printStackTracke myexception)
16:30knaprwhen passing a string of "2008-12-02" to contrib/sql into a column with the type DATE it works in derby but it postgresql I get nosuchfieldexception. anyone know why?
16:36knapri need to pass '2008-12-02' instead of "2008-12-02", how?
16:36hiredmanI wonder if it might want a date object instead of a string?
16:37hiredmanI haven't used contrib/sql
16:38Chouserknapr: are you using do-prepared?
16:38danlarkinugh it's so hard to choose a good name for software :-/
16:39Chouserit's hard to choose a good name for anything
16:49Chouserrhickey: print-dup output has a whole lot of PersistentArrayMap/create in it now
16:52jomaI wish github would format clojure better
16:52rhickeyChouser: yep - the problem is I can't tell when it is important to someone that they get back an ArrayMap. To be correct it needs to know the threshold for when using {} yields ArrayMap
16:52rhickeythose cases can be turned into {} literals
16:54Chouserprint-dup of course has to be careful, I just thought that if you were no guaranteeing {} would default to PersistentArrayMap below a certain size, print-dup could take that into account.
16:54rhickey8 items or less
16:54jomawhy does clojure code look like it is leaning?
16:54Chousermight also just be unnecessary fragility.
16:55Chouserjoma: why does java code look like it's trying to consume as many lines as possible?
16:55rhickeyuser=> (class {1 1 2 2 3 3 4 4 5 5 6 6 7 7 8 8})
16:55rhickeyclojure.lang.PersistentArrayMap
16:55rhickeyuser=> (class {1 1 2 2 3 3 4 4 5 5 6 6 7 7 8 8 9 9})
16:55rhickeyclojure.lang.PersistentHashMap
16:55Chouserjoma: sorry, that sounded testier than I meant it. Clojure has this is common with most lisps
16:57_hrrldComing from a C++/Ruby/Scheme background (never having used java)... I want to write the result of my clojure program out to disk and I can't figure out how. Do I need to use java facilities to write files with clojure?
16:58Chouser_hrrld: it's fine to use Java classes directly. You have a string you want to write out?
16:59_hrrldYup.
17:00Chouser_hrrld: I don't think there's anything in clojure.core to help you, so you can either look at clojure.contrib.duck-streams, or just use the Java calls directly.
17:00jomaCan't infer the SQL type to use for an instance of java.util.Date.
17:01_hrrldSo it would be a process of learning some Java file I/O, then translating it into clojure?
17:01Chouser_hrrld: yes, or looking at existing clojure examples, or using duck-streams.
17:02hiredmanactaully the I/O thing is in the faq on the website
17:02hiredmanwell
17:02_hrrldCan you point me to an example of file I/O, I didn't see anything in the reference docs.
17:02hiredmanI thought it was in the faq
17:02Chouserjoma: looks like you want java.sql.Timestamp
17:02hiredmanwhere did I see that
17:02Chouserjoma: http://github.com/stuarthalloway/programming-clojure/tree/master/examples/snippet.clj
17:04hiredman_hrrld: you can (doto (java.io.FileWriter. "somefile") (.write "string") (.close))
17:04ChouserWhich is essentially what 'spit' does: http://code.google.com/p/clojure-contrib/source/browse/trunk/src/clojure/contrib/duck_streams.clj#177
17:04hiredmanthere is also with-open
17:06jomaime - milliseconds since January 1, 1970, 00:00:00 GMT. A negative nu
17:06_hrrldwhat does the '&' mean in the docs for with-open? (from: http://clojure.org/api)
17:06jomayeah so how do I convert?
17:07Chousuke_hrrld: it means it's a variable-length argument
17:07Chouservarargs
17:07Chousuke_hrrld: your code is given as a parameter to the with-open macro
17:08Chousuke_hrrld: (with-open [myfile (java.io.FileWriter "out.txt")] (do-stuff-with myfile) (more-stuff-with myfile))
17:08Chousukeoops
17:08Chousukemissing a .
17:08_hrrldThat's really helpful. Much appreciated. (:
17:09Chousukewith-open also supports multiple name, init pairs
17:10_hrrldAnd closes them all automatically, I presume?
17:10Chousukeyes
17:10Chousukein reverse order of initialisation
17:12_hrrld"java.lang.IllegalArgumentException: No matching method found: .write" (Am I missing an import, or something?)
17:13Chouserthat more indicates incorrect parameters to .write
17:14Chousukeyou probably forgot to give the file as the first argument
17:14Chousermake sure the first arg really is a Writer, and the the rest are of types supported by the .write method
17:14hiredmanor you are calling a write method on something that has no write method
17:14Chousukeor something.
17:14_hrrldTrying this: (doto (java.io.FileWriter. "a.txt") (.write "foo") (.close))
17:14Chousukeright
17:14Chousukehmm
17:15hiredmanwait
17:15hiredmanwhat version of clojure?
17:15Chouserhiredman: ah, good call.
17:15_hrrldclojure_20080916
17:15Chousukeold
17:15_hrrld(!)?
17:15Chousukeupdate from google code :)
17:16_hrrldhaha. The way to write files out has changed in the last two months?
17:16Chousukeclojurebot: download?
17:16clojurebotIt's greek to me.
17:16Chousukeclojurebot: download is http://code.google.com/p/clojure/downloads/list
17:16clojurebotOk.
17:16Chousuke_hrrld: no, doto has changed
17:16Chousuke_hrrld: the old version of doto did not need the . for java methods
17:16_hrrldNeat. I'll get the latest and try again.
17:17Chousuke_hrrld: many other changes too
17:17hiredmanwhich is why the exception shows the method as ".write" instead of "write"
17:17Chousuke_hrrld: for example, trying to open multiple files in with-open with that version would have worked, but there was a bug so that the files other than the first one never got closed
17:18Chousuke_hrrld: and there's precompilation, clojure.main, and all kinds of neat stuff.
17:18Chousukeor was clojure.main after that release? :/
17:18_hrrldCute. Hey, it worked.
17:19hiredmanclojure.main?
17:20Chousukehiredman: the new startup thing
17:20Chousukehiredman: clojure.lang.Repl and Script are deprecated now.
17:21drewolsonChousuke: hrm, didn't know that. does main handle both scripts and repl with no arg?
17:21ChouserI suppose that means I should switch over.
17:21Chousuketry java -cp clojure.jar clojure.main --help
17:22hiredmanoh really
17:22Chousukeor java -jar clojure.jar --help I guess
17:22hiredmancheck that out
17:26powr-tocChousuke: cool... I hadn't realised that had been implemented
17:30drewolsonChousuke: ahh, so much better this way, thanks.
17:30red_fishwhere is documentated #()?
17:31vogelrnred_fish: it's mentioned in the reader section of the webpage
17:32rhickeyChouser: got your test.html from you appletviewer test handy?
17:32red_fishvogelrn: thx
17:32rhickeytrying to get applets working
17:34Chouserrhickey: dunno what code you're looking at, but here's what's in my clojure-applet directory:
17:34Chouser<applet code="net.n01se.HelloWorld" archive="hello.jar" width="800" height="800"></applet>
17:35rhickeyChouser: thanks - looking at: http://groups.google.com/group/clojure/msg/6bc1c0fe0165053f
17:37Chouserok
17:40Chouserwell, shoot. clojure.main doesn't do what I want, and I've accidentally overwritten my old clojure startup script.
17:40drewolsonChouser: i just actually rewrote mine, want me to pastie?
17:40Chouserheh. if you want.
17:40Chouserclojure.main is close
17:41drewolsonhttp://pastie.org/355135
17:41Chouserbut I want to provide a startup script for when it runs a repl
17:41Chouserand I want to be able to add to the classpath on the commandline
17:42drewolsonah, gotcha
17:42ChouserI'm amazed by how personal these startup scripts are.
17:42drewolsonheh, yep
17:42ChouserI assumed we all wanted roughly the same thing (nobody has their own python or ruby startup script), but in fact they're all quite different.
17:44lisppaste8rhickey pasted "applet load error" at http://paste.lisp.org/display/73258
17:44rhickeyanyone know applets well enough to explain above error?
17:45waltersrhickey: i'm guessing it means you can't refer to any class sun.awt.*
17:45hiredmaninteresting
17:45waltersrhickey: maybe the AOT compiler is traversing the class hierarchy in a way that javac doesn't?
17:45ChouserI saw this.
17:45powr-tocrhickey: are you trying to popup a window or anthing like that?
17:46Chouserdangit. I can't remember what it was.
17:46Chouserproxy tries to implement things it shouldn't. or something.
17:47cmvkkby the way, if you guys are working at making clojure applets work, then that is very exciting.
17:47cmvkki was just trying to do it earlier today and it didn't work.
17:47rhickeyjust this simple class:
17:47rhickey(ns clojure.examples.applet
17:47rhickey (:gen-class
17:47rhickey :extends java.applet.Applet))
17:48Chousersomething descends into the Applet heirarchy and finds platform-specific classes that it's not supposed to touch
17:49ChouserI'm very agitated. I had this, and I think I found a work-around.
17:49fffejI've got a confusing error - No matching method found: indexOf for class java.lang.String - can anyone point me into the right direction?
17:50rhickeyChouser: cuase it seems like I'm past the classloader problem
17:50rhickeycause
17:50Chouserrhickey: excellent!
17:50Chousukefffej: are you giving it the right argiuments?
17:50rhickeyseems being the operative word :)
17:50Chousukearguments*
17:51fffejchousuke: it's taking a JTextFIeld.getText() for both arguments and works most of the time until an exception is thrown
17:51aking,(.indexOf "Hello" "o")
17:51clojurebot4
17:51Chouserhm, I have :excludes #{"applyCompoundShape"} in my gen-class example
17:51rhickeybasically I've made ROOT_CLASSLOADER load-on-demand, will never create a dynamic loader if no dynamic code
17:52hiredmanthe javadoc for runtime permission has a description of the accessClassInPackage permission, but it is greek to me
17:52Chouserapparently I had a patch against gen-class, but I don't seem to have it in my git repo
17:53ChouserI'm pretty sure that :excludes is to work around the access error
17:55durkarhickey: where does add-classpath go then?
18:04fffeji'm not understanding re-find. (re-find #"bar" "bar") => "bar" whereas (re-find #"(foo)|(bar)" "foo bar") => ["foo" "foo" nil] - why does one return a vector and one just the result directly?
18:05durkalooks like the second is capturing groups?
18:06fffejbut shouldn't the return type be consistent? (e.g. a vector of 1 in the first example), otherwise my code has to check whether the return val is a collection which doesn't feel right
18:06hiredman,(re-find #"(foo)|(bar)" "foo bar")
18:06clojurebot[foo foo nil]
18:07hiredman,(re-find #"bar" "foo bar")
18:07clojurebotbar
18:07hiredman,(re-find #\w" "foo bar")
18:07clojurebotEval-in-box threw an exception:No dispatch macro for: \
18:07hiredman,(re-find #"\w" "foo bar")
18:07hiredmanclojurebot: well?
18:07clojurebotf
18:07clojurebotexcusez-moi
18:08cmvkkf?
18:08hiredman,(prn "f")
18:08clojurebotnil
18:08clojurebot"f"
18:09hiredmanI guess clojurebot should capture a prn into a stringwriter instead of just calling .toString
18:10fffejIs the weirdness with re-find me being daft, or should I file a bug report?
18:11jomaWhy can't I load a namespace into the repl? #'progs.netflix.parsing/parse-intervals works but when I try to us it it fails
18:11joma(parsing/str-to-date "2008-12-02")
18:11jomajava.lang.Exception: No such namespace: parsing (NO_SOURCE_FILE:44)
18:11jomauser=> (str-to-date "2008-12-02")
18:11jomajava.lang.Exception: Unable to resolve symbol: str-to-date in this context (NO_SOURCE_FILE:45)
18:11jomauser=>
18:12hiredmanhow are you trying to "load" the namespace?
18:13jomaah (progs.netflix.parsing/str-to-date "2008-12-02")
18:17leafwjoma, how about (load-file "progs/netflixs/parsing") ?
18:18hiredman(doc require)
18:18clojurebotLoads libs, skipping any that are already loaded. Each argument is either a libspec that identifies a lib, a prefix list that identifies multiple libs whose names share a common prefix, or a flag that modifies how all the identified libs are loaded. Use :require in the ns macro in preference to calling this directly. Libs A 'lib' is a named set of resources in classpath whose contents define a library of
18:26zakwilsonI'm having trouble getting Slime to eval expressions in the correct namespace. Has anybody else had a similar problem?
18:38powr-tocwill clojure ever ship with contrib?
18:43durka(doc re-groups)
18:43clojurebotReturns the groups from the most recent match/find. If there are no nested groups, returns a string of the entire match. If there are nested groups, returns a vector of the groups, the first element being the entire match.; arglists ([m])
18:44durkafffej: so if it is a bug, it is a documented bug anyway
18:44hiredman,(prn "f")
18:44clojurebotnil
18:44clojurebot
18:44clojurebot"f"
18:45hiredmanhmmm
18:45hiredman,(identity "f")
18:45clojurebotf
18:45clojurebot
18:45clojurebot
18:46hiredmanwe will call that a regression
18:49hiredman,(identity "f")
18:49clojurebotf
18:49vladsharpcan you see how a macro was expanded?
18:50danlarkin(doc macroexpand)
18:50clojurebotRepeatedly calls macroexpand-1 on form until it no longer represents a macro form, then returns it. Note neither macroexpand-1 nor macroexpand expand macros in subforms.; arglists ([form])
18:51vladsharpah ha, thanks
18:54hiredman,(identity nil)
18:54clojurebotnil
18:54Chousukefun to see you developing clojurebot :P
18:54Chousukesomething magically changes and then the bot behaves differently!
18:55hiredmanso the result is now (prn ...) to a stringwriter so we get quotes and stuff
18:57joma(defn split [string delim] (seq (.split string delim))) , into core?
18:59hiredmanoops
19:00hiredmanI think I just commited to github with the wrong commit message
19:04jomawhy does clojure code look like it is leaning?
19:04joma(defn split [string delim] (seq (.split string delim))) , into core?
19:05jomacan anyone add to clojurebot?
19:10powr-tochiredman: if you've not pushed the commit you can git commit --amend
19:11hiredmanpowr-toc: I am figuring that out
19:12powr-tochiredman: but if you've pushed it things are uglier
19:13hiredmanyeah
19:13hiredmanwell it's ugly now
19:13powr-toclol
19:13hiredmanI think I will leave it
19:13hiredmandamn it
19:13hiredmannow I have two duplicate commit messages
19:13hiredmanyeah, time to leave be
19:13powr-tochiredman: is it your project? And is it highly unlikely anyone has pulled?
19:14hiredmanyes, and yes
19:14hiredmanI can just leave it be
19:14hiredmanI don't mind too much
19:15danlarkintoo late, hiredman, it's already in my feed reader as a duplicate message :)
19:16hiredmanI know
19:16dreishPeople will be talking about it for years.
19:16hiredmanthere are 2 duplicate messages now
19:16hiredman4 total messages
19:17powr-tochiredman: it's probably reasonably easy to recover from by deleting the remote branch, rebasing it (so long as no one else has pulled it) and pushing back again
19:17jomaanyone have an example of doing a prepared statement with contrib.sql?
19:18hiredmanthe "merge branch live" thing is new
19:18hiredmanlive being the name of the branch I run clojurebot out of
19:18hiredmanmust be because I made the commits in that branch?
19:18rhickeyApplet started!
19:18hiredman!!
19:18durka:D
19:19danlarkingreat success!
19:19hiredman,(Date.)
19:20clojurebot#<Date Wed Jan 07 16:18:00 PST 2009>
19:20hiredmanclojurebot: Wed Jan 07 16:18:00 PST 2009 is <reply>"Applet started!" -- rhickey
19:20clojurebotYou don't have to tell me twice.
19:20rhickeylast prob was that gen-class and proxy both gen stubs for package-private methods, shouldn't
15:20durkawhen java is looking through the classpath for imports, how does it decide which classes to make available?
15:21durkait kind of looks like it ignores the versions of plain .class files, but checks the versions in .jar manifests against the current JVM version
15:21durkadoes anyone know if this is the case?
15:47rhickeyChouser: any tests for binding-assertions patch? looks ok, but I haven't exercised it
15:47pjb3rhickey: Applet started? What was that about?
15:48rhickeypjb3: got a dummy applet running using AOT, resolved classloader and security issues
15:48rhickeysvn 1201
15:48pjb3cool, does that mean you can run Clojure code in an applet?
15:49rhickeyyes, when AOT compiled
15:49pjb3Cool, it would be cool if we had something like this for Clojure: http://sisc-scheme.org/sisc-online.php
15:50pjb3A REPL in an Applet, would that still work? Because you would be defn'ing stuff from a REPL in an applet
15:50hiredmanclojurebot: Jan?
15:50clojurebot"Applet started!" -- rhickey
15:50rhickeypjb3: that is not going to happen, at least not without a cert - Clojure is not interpreted and the default security prohibits custom classloaders needed for eval
15:51pjb3Ah, that's what I thought
15:51rhickeyclojurebot: svn?
15:51clojurebotsvn is http://clojure.googlecode.com/svn/trunk/
15:51pjb3Step one would be making a swing REPL I guess
15:51albinowhy not do what all the cool kids do and put a REPL as a server process talking over a socket to an ajax front end
15:52pjb3then futzing around with a signed applet or whatever to get the custom classloaders, assuming that is possible
15:52pjb3albino: Yeah, I thought about that, but then it's hard to have a general purpose "Try Clojure Online!" thing
15:52hiredmanalbino: hmmmmm
15:52pjb3right?
15:52pjb3because then everybody is connected to the same repl, defing things, etc.
15:53powr-tochow would you create a constant unmodifiable reference in clojure?
15:54powr-toci.e. an immutable pointer to an immutable object.
15:54albinoIIRC that's how this one works http://tryruby.hobix.com/
15:54rhickeypowr-toc: in a ref?
15:54albinopjb3: well you can have a process per user, or thread per user...whatever
15:55pjb3albino: right, then you got to host that and everything
15:55albinopjb3: perfect, so you're volunteering then? :)
15:55pjb3Where as if you had an applet, you can server it as a static file
15:55hiredmanalbino: the main diff between that and an applet is an applet runs on the user's computer and uses their resources
15:55hiredmanso you can let them do everything clojure does
15:55albinohiredman: right
15:55albinoI was just speaking on the fastest way to get a "try it now in a browser" clojure thing going
15:56hiredmanbut, uh, you need to sandbox a repl running on your own machine
15:56hiredmanand effective sandboxing blows
15:56pjb3What about that web start stuff? That just downloads a java app and runs it, right?
15:56albinohiredman: I assume you're already sandboxing clojurebot?
15:56powr-tocrhickey: not sure... I'm just trying to grok the difference between var's, ref's, agent's etc... I really just want a constant value equivalent to a final reference to something
15:56hiredmanalbino: yes
15:56hiredmanalbino: but not very effectively
15:56pjb3Well, either way, step 1 is a swing gui REPL
15:56albinohiredman: so you've already got a start at it
15:56rhickeypowr-toc: to prevent accident or malice?
15:57hiredmanI mean, no IO out of the jvm
15:57hiredmanbut you can still dealock the bot if you try hard
15:57albinowhat would be fun (maybe not practical) is forking a openvz container per user
15:57hiredmandeadlock
15:57albinoOS level sandboxing
15:57powr-tocaccident
15:57hiredmanalbino: or just find someone who really understands jvm sandboxing
15:58pjb3Of Course I guess it should be that hard for people to download a jar file and run "java -jar clojure.jar" from the command line
15:58hiredmanI just cargo culted the jvm sandboxing that clojuebot uses
15:58albinohiredman: who is the expert on that?
15:58hiredmanno clue
15:58rhickeypowr-toc: most Clojure data structures are immutable
15:59albinoha, just found this in my bookmarks http://calumleslie.blogspot.com/2008/06/simple-jvm-sandboxing.html
15:59albinoI wonder if you could build something with this http://www-jpc.physics.ox.ac.uk/index.html
16:00albinomaybe with JPC you could get it to run on the client machine without jumping through applet hoops
16:00hiredmanugh
16:00powr-tocrhickey: yeah, I understand that... I'm really just after the idiomatic way of doing it... the value will be accessible across a variety of threads. I'm wondering if there is effectively a way to freeze a reference to a particular object
16:00powr-tocdo I just use def?
16:01rhickeypowr-toc: how is it getting passed to the threads?
16:01rhickeypeople don't usually accidentally say alter/swap!/set! etc
16:02rhickeybut you could set up a validator that will reject all changes like this:
16:02rhickey(let [aval {:never :change}]
16:02rhickey (def aconst (ref aval :validator #(identical? % aval))))
16:02rhickey(dosync (alter aconst assoc :a 1))
16:02rhickeyjava.lang.IllegalStateException: Invalid reference state (NO_SOURCE_FILE:0)
16:02powr-tocrhickey: it's not yet :-) - I'm thinking it'll be initialised immediately at start up though and I'd like it to be visible to all threads
16:02rhickeysame technique could work for vars/atoms
16:04powr-tocok... It's no biggy really... it's just when I'm in java I'm used to using the final modifier not only to help enforce immutability, but to also indicate intent... i.e. this reference won't ever be changed.
16:04zakwilsonIf you create a var with def, isn't it only rebindable thread-locally?
16:05rhickeypowr-toc: that's kind of the default intent in Clojure
16:05powr-tocrhickey: lol - good point! :-)
16:07powr-tocrhickey: In which case presumably idiomatic clojure is simply to declare such values with something like (def pi 3.14159) and be done with it
16:07powr-tocwhich suits me
16:07rhickeyyeah
16:08pjb3But if you can do (ns-unmap 'user 'pi) (def pi 42), right?
16:08hiredmanis there a lazy-seq of the digits of pi yet?
16:09mmcgranaAnyone have a good solution for the problem of setting up different "environment" in e.g. Compojure? For example in a webapp I have a "host" config option that needs to be different in deployment and production. I've thought through several possibilities but none were satisfactory, hopefully someone has encountered this problem before.
16:09mmcgrana* different "environments"
16:09pjb3mmcgrana: specify the environment as a startup option, load a .clj matching the environment?
16:09pjb3production.clj, develoment.clj?
16:10pjb3environment.clj loads for everything?
16:10mmcgranahow do you suggest "specifying the environment as a startup option"?
16:10danlarkinmmcgrana: I haven't used compojure, but in django it's commonly solved with having settings.py import settings_local.py -- where settings.py defines settings common to dev, prod, stage, etc. and settings_local.py defines database connection settings etc
16:10mmcgranaexcuse my ignorance in advance...
16:10pjb3command-line argument
16:10pjb3assume development if not present
16:11pjb3Does compojure run in a servlet engine like Jetty?
16:11pjb3Then maybe a JNDI or web.xml setting
16:12mmcgranaI think so, I'm not actually using compojure I just thought people who had been using it would have thought about the issue
16:12pjb3mmcgrana: not using it either
16:13mmcgranabtw the basic environment.clj, production.clj etc approach sounds basically right, i just have to get the mechanics down
16:14powr-tocmmcgrana: the environment.clj development.clj production.clj approach is used heavily in the ruby/rails community if you want any further inspiration
16:16mmcgranain fact rails/merb is what pushed me away from ruby into clojure (did rails full time for a while)
16:16powr-tocmmcgrana: do you mean the rails/merb fracture?
16:17powr-tocor do you just dislike those frameworks? :-)
16:17mmcgranajust the style of the frameworks: crazy side effects and excessively coupled apis in particular
16:18powr-tocmmcgrana: yeah, I've been getting increasingly dissillusioned with OOP for many problems
16:19danlarkin"you know you've been programming in an FP language too long when"... side effects start to confuse you
16:20danlarkinthat has been happening to me :-o
16:20Chousukehas there been a time when side effects have *not* confused you?
16:21powr-tocdanlarkin: don't you mean you know you've NOT been programming in an FP language when side effects start to confuse you? ;-)
16:21Chouserabsolutely
16:22mmcgranai must be missing something obvious: say i'm in a boot script an i have an env value, like :dev. I'd like to require myapp.config and end up with myapp.config/env bound to :dev and the various myapp.config/setting{a,b,c} bound according to the env. I don't know how to communicate the env value to the myapp.config namespace so that it sets everything correctly. I guess i could put the env-determination logic in myapp.conf
16:24hiredman.conf? sounds like something that should be a .clj
16:25mmcgranahiredman: when i say myapp.config i mean a namespace defined by /myapp/config.clj
16:26hiredmanyou want a seperate library for reading the the config that you can including in other projects?
16:27mmcgranai'm not sure what you mean: myapp.config is just a namespace to hold config values
16:28hiredmanyou appear to be concerned with where to put the logic, and I am asking why
16:30mmcgranaI just want config values to be in a single place, that's all. I don't want to put the env-determination logic in the config namespace because I will want to use multiple mechanism to make such determinations.
16:31mmcgranalisppaste8: url
16:31lisppaste8To use the lisppaste bot, visit http://paste.lisp.org/new/clojure and enter your paste.
16:32lisppaste8mmcgrana pasted "config" at http://paste.lisp.org/display/73269
16:33lisppaste8mmcgrana annotated #73269 with "untitled" at http://paste.lisp.org/display/73269#1
16:33hiredmanurm
16:34hiredmanyou just need (eval (read ...))
16:35Chousera.k.a. load-file
16:35hiredmanYes.
16:35hiredman(doc load-file)
16:35clojurebotSequentially read and evaluate the set of forms contained in the file.; arglists ([name])
16:39mmcgranai like the idea of root config values and then additional/changed values for different envs, but i dont think i want to commit to requiring different files for each env. for example in the simple case in the paste everything could just be in the myapp.config file. sorry if i'm being thick, maybe i just need to sleep on it.
16:39powr-tocwhat's the clojure predicate that returns whether or not a supplied item is present in a seq?
16:39hiredman(doc some)
16:39clojurebotReturns the first logical true value of (pred x) for any x in coll, else nil.; arglists ([pred coll])
16:40powr-tocmmcgrana: can you not just represent the whole config as a hashmap?
16:40hiredman,(#(some #{%} %2) :a [:a :b :c])
16:40clojurebot:a
16:40hiredman,(#(some #{%} %2) :d [:a :b :c])
16:40clojurebotnil
16:41mmcgranaindeed i could, its how i have it sketched now, but you still need some val that holds the env that you use to index into the first level of the map
16:42dreishWhy that syntax and not (some #{:a} [:a :b :c]) ... (some #{:d} [:a :b :c])
16:42hiredmanmmcgrana: I have that val
16:43hiredman(keyword (first *command-line-args*))
16:43mmcgranayes i see, but outside of the myapp.config namespace only
16:44hiredmandreish: well he asked for a predicate
16:44hiredmanwhich is a function that returns nil or (not nil)
16:44hiredman#(some #{%} %2) is such a function
16:49powr-toc(defn includes? [val seq]
16:49powr-toc (not (nil? (some #{val} seq))))
16:49powr-toc
16:49hiredmanuh
16:49hiredmanno
16:50hiredman(defn includes? [val seq] (some #{val} seq))
16:50mmcgranahiredman: the (keyword... code would correspond to (determine-env-from-cl) in the paste
16:50hiredman,(let [f (fn [val seq] (some #{val} seq))] (f :a [:a :b :c]))
16:50clojurebot:a
16:50hiredman,(let [f (fn [val seq] (some #{val} seq))] (f :d [:a :b :c]))
16:50clojurebotnil
16:52hiredmannil? is bascially the same as not
16:52hiredman,(= (nil? :a) (not :a))
16:52clojurebottrue
16:52hiredmanso you have a double negative
16:55Chousukehiredman: except for (nil? false) (not false)
16:57hiredmanwell
16:57hiredmanFine
16:58hiredmanactually
16:58hiredman.(nil? false)
16:58hiredman,(nil? false)
16:58clojurebotfalse
16:58hiredman*sigh*
16:59powr-toc,(true? :a)
16:59clojurebotfalse
17:00hiredmantrue and false are for java interop, so I don't care, so there
17:02Chousuke(true? (Boolean. true))
17:02Chousuke,(true? (Boolean. true))
17:02clojurebotfalse
17:03Chousukehmm :D
17:03powr-toclol
17:03danlarkinJVM bug
17:03Chousukecreating new Boolean instances is apparently bad style anyway
17:04ChousukeI wonder why the constructor is even public :/
17:04danlarkinrich mentions it in his clojure-for-java-programmers presentation IIRC
17:04hiredman,(true? true)
17:04clojurebottrue
17:04hiredmanfor boxing booleans?
17:04Chousuke(true? (Boolean/TRUE))
17:04Chousukegah
17:04Chousuke,(true? Boolean/TRUE)
17:04clojurebottrue
17:05Chousukehiredman: you can just replace them with Boolean/TRUE
17:05Chousukeor FALSE
17:06hiredman*shrug*
17:06Chousukeor well, I guess the constructor is easier if you don't know which one it is :/
17:07hiredmanclojurebot: java?
17:07clojurebot?
17:09vogelrn,(= true (Boolean. true))
17:09clojurebottrue
17:09Chousukewell that's interesting :/
17:10vogelrnah
17:10vogelrnit's because true? uses identical?
17:10vogelrnit assumes that all trues are the same
17:10vogelrnobject, that is
17:10vogelrnwhereas using Boolean to create a new true won't be the same, cached one
17:14vogelrnI'm kind of torn because that could lead to some really nasty bugs, but like you said, you shouldn't be using the constructor anyway, should use Boolean/TRUE or Boolean.valueOf
17:14hiredmanclojurebot: max people?
17:14clojurebotmax people is 116
17:18danlarkinhow can I apply to a macro?
17:19ChousukeI think you'll have to write a macro-apply :/
17:19mmcgranai don't think that you can, e.g. (apply or '(1 2 3)) doesn't work
17:20mmcgrana* i dont think that you can apply to a macro that is, i dont' know about a macro-apply
17:20hiredmanugh
17:20danlarkin:'(
17:21hiredmanthanks guys, I totally just burnt dinner
17:25danlarkinHm. I'm not sure macro-apply is possible
17:25danlarkinone "can't take the value of a macro"
17:25Chousukedanlarkin: you can produce code that expands into a macro given the name of a macro though.
17:25mmcgranawhat if macro-apply was itself a macro?
17:25danlarkinoh.. well I guess maybe if macro-apply were a macro
17:25Chousukewell it has to be
17:26mmcgranaright
17:26ChousukeI'm trying to figure it out
17:26Chousuke(defmacro macro-apply [mac & args] `(~mac ~@(apply concat args))) works somehow but fails for (macro-apply or 1) :/
17:27mmcgrana(defmacro macro-apply [mac & args] `(~mac ~@args)) ?
17:28duck1123How would I, in a macro, take a sequence of forms (from a macro-expand time function), and output it as just those forms.
17:28mmcgranaduck1123: i think a macro needs to return a single form
17:28mmcgrana(do ~@forms)
17:28hiredman^-
17:30duck1123ok, what I want to do, is in a compojure defservice form, break the list of my handlers into separate functions. ~@(users-handlers) would do the trick?
17:30hiredmanuh
17:30dreish,(System/identityHashCode (Boolean. true))
17:30clojurebot13603674
17:30danlarkinChousuke: you are getting close
17:30dreish,(System/identityHashCode (Boolean. true))
17:30clojurebot22150794
17:31hiredmanduck1123: you want a macro to define more than one function?
17:33duck1123defservice requires all the handlers to be at the same level, I want to have several functions that each return a seq of handlers that get flattened into the same bottom level.
17:35duck1123I think I can make ~@(handler-fn) work.
17:35Chousukedanlarkin: I'm going to have to go to sleep now though :/
17:35danlarkinChousuke: aw :)
17:40danlarkinChousuke: (defmacro macro-apply [mac & args] `(~mac ~@(apply eval args)))
17:40danlarkinone step better?
17:41danlarkineven though it uses eval, which could be avoided I think
17:42danlarkinoh and not to mention... java.lang.UnsupportedOperationException: Can't eval locals
18:12lisppaste8mmcgrana pasted "contrib broken on head?" at http://paste.lisp.org/display/73274
18:13mmcgranaanyone tried recent clojure + clojure-contrib together, particularly w.r.t. clojure.contrib.repl-utils?
18:13mmcgranaI'm getting the pasted error.
18:19Chousermmcgrana: huh. yeah, I'm seeing that. hang on.
18:29Chousermmcgrana: fixed, clojure-contrib SVN 352
18:31mmcgranaChouser: wow, thanks for the quick response!
18:34Chousersure, thanks for pointing it out. I'm flailing around with clojure.main and hadn't noticed I wasn't loading repl-utils.
18:41scottjRe: snakes w/o globals. Does putting variables that you might want to customize in a let inside a main function make it harder to make customizations than using globals?
18:43scottjthat is, with globals you could just create a let binding with your customizations and run the program inside that, but with the main function and let inside that, you now have to write your own custom main function.
19:11ChouserClojure applet. Warning: it's rather demanding and may take down your browser: http://chouser.n01se.net/misc/tree.html
19:13vogelrnsurprisingly it hasn't killed my EEE PC
19:13Chouserbut does it work?
19:13vogelrnyeah
19:13Chouseroh! well, cool.
19:14vogelrnit probably draws a lot more slowly than it's supposed to, but it does take form :P
19:14ChouserThen I'm off. g'night.
19:21durkaChouser: OS X: Applet net.n01se.Tree notinited
19:25durkaChouser: it works in appletviewer, however
19:31hiredmanugh
19:31hiredmanclojurebot: haskell?
19:31clojurebotYo dawg, I heard you like Haskell, so I put a lazy thunk inside a lazy thunk so you don't have to compute while you compute.
19:32vogelrn:P
19:33danlarkinhaha
19:33danlarkinthat is a good one
19:34hiredmansome much good functional stuff in haskell
19:34hiredmanjust looking at the code makes me break out in hives
19:35lisppaste8durka pasted "problem with Chouser's applet on OS X" at http://paste.lisp.org/display/73276
19:37durka(firefox tosses the same error at the java console)
20:20hiredmanclojurebot: ping?
20:21hiredmanping?
20:22hiredman1d6
20:22clojurebot5
20:25hiredmanclojurebot: ping?
20:25clojurebotPONG!
20:30hiredman2d8+2
20:32hiredman2d8+2
20:32clojurebot6
20:56herdrickquestion for the crowd:
20:58herdricksorry - answered my own question
23:49AWizzArdHow can I make a Byte[] and put in some initial values? Something like (make-array Byte [1 2 3 4 5])?
23:52AWizzArd(into-array Byte/TYPE [1 2 3 4 5]) throws an exception.