#clojure logs

2008-06-27

01:42Lau_of_DKMorning!
01:42Lau_of_DKQuestion: Does any of Clojure's concurrency features help me, when multiple programs access the same file?
01:55cgrandmultiple programs = multiple threads lauched from clojure or multiple processes?
02:02cgrandif it's inside clojure you can use an agent to enforce serial access to some resource (eg a file)
02:04Lau_of_DKIts about 20 users who are going to submit data to the same XML file
02:07cgrandbut 20 users going through 1 instance of your app or 20 users going through 20 instances of your app or ...?
02:11Lau_of_DK20 instances
02:15cgrandthen Clojure won't help you -- except if you break your app in two: client and server (which only purpose would be to handle writes to the xml file send from the clients)
02:48Lau_of_DKThats what I figured - I wondered if thats really complicated though :)
09:09cemerickI'm just now looking at lib.clj -- having a couple of issues, though. (a) isn't require supposed to fail if it can't load a library, and (b) what's the correct incantation to get require/use to grab a library from a package? I have foo.clj in com/pkg, and none of these seem to work: (use com.pkg.foo) (use "com.pkg.foo") (use 'com.pkg.foo), etc.
09:10cemerickI feel like I'm missing something fundamental here. (using r55 out of svn, btw)
09:28Chouser_I still haven't tried out lib.clj, sorry.
09:40spacebat_hi, I'm not having much luck with clojure, I guess its going to take a while for the alien tech to sink in
09:40Chouser_spacebat_: what's the problem?
09:41spacebat_I guess there's the problem of not knowhing where to start, I'm used to imperative languages
09:41spacebat_half of the terminology is fairly opaque since I'm not steeped in lisp/scheme
09:42spacebat_someone helped me last week to count the invocations of a function with a Var, using bindings
09:42spacebat_but I'm not sure what that's really for or why it works
09:43rhickeyspacebat_: what languages do you know?
09:43spacebat_c/c++/java/perl/python, the usual suspects
09:44spacebat_I'm familiar with the term binding of variables
09:45spacebat_but def's third argument has something to do with a Root, which I don't get
09:45rhickeyhttp://en.wikibooks.org/wiki/Clojure_Programming#Examples has a version of a program and a link to a description of how it works and an implementation in Python
09:45rhickeythe spelling corrector
09:45spacebat_cool thanks
09:46spacebat_I just started working through practical_clojure.clj because I recently did that capter in practical common lisp
09:46Chouser_I do think functional languages import a bunch of jargon that isn't used in the imperative world.
09:47spacebat_oh I just sorted one problem, I'm using a script I got to start clojure from the command line
09:48spacebat_when my cwd isn't the clojure build dir, I get exceptions about wrong number of args for set, and strcat not found in this context
09:49rhickeyhttp://blip.tv/file/982823 is a gentle introduction of Clojure oriented towards Java programmers
09:49spacebat_but when I run it from the build dir it works, so I mustn't be setting up the environment properly
09:49spacebat_thanks again rhickey
09:49Chouser_strcat has been gone a long time, i think. What is trying to call strcat?
09:49spacebat_half the clojure source code on the net
09:50spacebat_;)
09:51spacebat_what should I use instead of strcat?
09:51Chouser_probably just str
09:51rhickeyhttp://en.wikibooks.org/wiki/Clojure_Programming#Where_did_the_x_function_go.3F
09:52spacebat_strangely it was seeing Language::Lisp::ECL on the CPAN that pushed lisp over the threshold from vague interest to "I've got to learn this"
09:52spacebat_about two weeks ago
09:53spacebat_I like that ECL has C linkage so its very interoperable
09:53Chouser_It's great you found your way from lisp in general to Clojure. I've tried to learn LISP (mainly Common Lisp) before, and it just never happened. Clojure's going swimmingly for me.
09:53spacebat_that's also what I like about clojure, the library problem is conveniently solved by java interop
09:54spacebat_would it be fair to say that clojure is close to being a scheme (except the lack of continuations and tail recursion optimization)
09:55spacebat_its the square brackets floating around that make me wonder
09:55rhickeyThose 2 make it pretty definitively not Scheme
09:56spacebat_yes, I thought someone would say that :)
09:56rhickeySquare brackets are synonyms for parens in Schemes, whereas they represent real vectors in Clojure
09:56spacebat_worked as a java programmer for a few years, but it was a dismal company making online casino software
09:57rhickeyOf CL and Scheme, I think Clojure shares more mindset with CL
09:57rhickeyBeing functional sets it apart from either
09:57spacebat_I don't really like writing java code, too verbose, so I toyed with Jython but its a bit rough, hope to see it improve
09:58spacebat_perhaps clojure will be my way back to using things from the java universe
09:58scgilardiHi folks. Is cemerick here? I have some answers about lib.clj.
09:58spacebat_thanks for the insight rhickey
09:59spacebat_I know that things are moving quickly, its good that there are so many resources alredy
10:00spacebat_is there a docstring convention for clojure and/or a help function to read them?
10:00rhickeyspacebat_: sure - stick with it, and especially look into refs and transactions. Clojure is actually for solving the problems one solves with C#/Java. It supports functional programming _and_ sane state
10:02spacebat_when I mention the properties of clojure to some people, they sometimes mention erlang
10:02spacebat_I guess with the right libs that sort of distributed fault tolerant concurrency would be in easy reach
10:03rhickeyClojure currently only addresses the non-distributed case
10:04spacebat_yes, and distributing things is probably best left to the libs
10:04rhickeyWith, IMO, a much more approachable model than Erlang's
10:06spacebat_thanks guys, I'm making some progress now, cheers for now
10:07scgilardirhickey: currently loadResourceScript silently fails if the resource doesn't exist. I would prefer it to either throw an exception or return an indication of failure. Would you consider that?
10:12rhickeyscgilardi: yes, something, either taking a flag indicating throw if not found or a return value. Unconditional throw is out, as I use it for speculative reads and don't like EH for flow control
10:13rhickeyscgilardi: thanks for all your help on the group
10:16scgilardiok, cool. is it for user.clj that it's speculative? A return value seems a little cleaner than a flag, but either would work for me.
10:17scgilardiyou're quite welcome. I'm glad to see interest in clojure (as indicated by new folks in the group) on the upswing. I'm happy to help out with the easy stuff.
10:55jmbrhi
10:57Chouser_jmbr: hi
12:13cemerickdarn, I missed scgilardi :-(
13:44cemerickHaving a :deprecated key in def metdata will eventually be useful for enclojure (and maybe the future when clojure can emit classfiles ;-))
15:28cemericklooks like both clojure.lang.Repl and enclojure's repl force printing of lazy seqs....
15:30cemerick...which makes sense, as there's no lazy?, or other way to determine whether a seq is lazy or strict.
15:33rhickeyYou mean when it is the value returned to the Repl?
15:35rhickeyyou could never really tell if a seq is lazy, as lazy and strict 'links' can be chained together
15:35cemerickYes.
15:35cemerickYeah, you're right.
15:35cemerickOne of the nifty things about scala's repl is that it prints something like [1 2 3 4 5 ...] for streams.
15:36Chouser_I'm not sure how useful it would be, but I suppose ISeq could support some sort of "rest-computed?" flag.
15:36cemerickI just had to kill netbeans because the repl was rendering the result of drop on an infinite seq :-P
15:36rhickeyClojure just needs CL's *print-length* et al
15:37cemerick(that will eventually be unnecessary with some judicious enclojure patches, etc)
15:37rhickeynothing to do with laziness
15:37cemerickI stand corrected. All of the CL work I've done has been very imperative.
16:01cemerickI'm seeing (old) examples that include hints like #^float, but using such things yields an exception (class not found). The primitives section only lists hints for primitive arrays; has simple primitive hinting changed, or gone away?
16:02rhickeyI'm not sure #^float ever worked (#^Float did and does) - where did you see that?
16:02cemerickah, #^{:tag (.TYPE Float)} works
16:03cemericklet me see if I can fish that link up again...
16:03cemerick#^Float is java.lang.Float though, right, not Float.TYPE?
16:04rhickeyIt's enough for the inference engine. These tags are for boxed things
16:04cemerickrhickey: http://blog.finiteimprobability.com/2008/03/27/picnic-invasion-obtimization-explorations/ , which was discussed briefly here: http://groups.google.com/group/clojure/browse_frm/thread/44d84d98372fb177
16:04cemerickright, right -- I forgot that you always emit boxed types, and let hotspot figure it out
16:05rhickeythe difference is, now (let [i (int 7)] ...) makes i a primitive int
16:06rhickeyonly that, or a primitive return value, can give you a primitive local
16:07rhickeyunboxed
16:12rhickey(let [#^float f 7] f) doesn't fail, that's why his code didn't either - the compiler never needs to use the hint (e.g. interpret it as a class)
16:13cemerickThanks much. :-)
16:14cemerickInterestingly, you can't set *warn-on-reflection* to true in enclojure -- it snaps back to false automagically (or maybe is never changed to begin with).
18:09jgranthow do you access command line vars passed to a clojure prog ?
18:09rhickey*command-line-args*
18:10jgrantthx