#clojure logs

2009-09-11

00:15claritasanyone know where to adjust the indentation in slime? when I write nested hash/array literals it only indents by one space and makes it hard to read
00:54travisbrady,(type '(1 2 3))
00:54clojurebotclojure.lang.PersistentList
01:01travisbradywhat does the single quote do in the above?
01:06JAS415holds evaluation
01:06JAS415otherwise it would be have to treat 1 as a function
01:07JAS415,(type (1 2 3))
01:07JAS415,(type (list 1 2 3))
01:08clojurebotjava.lang.ClassCastException: java.lang.Integer cannot be cast to clojure.lang.IFn
01:08clojurebotclojure.lang.PersistentList
01:08JAS415,(type (first '(list b c)))
01:08clojurebotclojure.lang.Symbol
01:09JAS415(,type (first (list 1 2)))
01:09JAS415,(type (first (list list 1 2)))
01:09clojurebotclojure.lang.PersistentList$1
01:10JAS415,(type clojure.lang.PersistentList$1)
01:10clojurebotjava.lang.Class
01:10JAS415,(type 'list)
01:10clojurebotclojure.lang.Symbol
01:22travisbradyJAS415: thanks, but what does it mean to 'hold evaluation'?
01:31JAS415it means that for example, symbols aren't converted into the data they represent
01:31JAS415which is why 'list returns type symbol
01:32JAS415whereas the other one returns the persistentlist class
01:32JAS415,(type +)
01:32clojurebotclojure.core$_PLUS___4094
01:32JAS415^^ function
01:32JAS415,(type '+)
01:32clojurebotclojure.lang.Symbol
01:32JAS415symbol
01:32JAS415so is kind of like the opposite of eval
01:32clojureboteval is sometimes useful - but only sometimes
01:33JAS415oh clojurebot, eval is always useful, but not normally in your code
01:34JAS415so like you can do
01:34JAS415(eval '(+ 2 3))
01:34JAS415,(eval '(+ 2 3))
01:34clojurebotDENIED
01:34JAS415ahh
01:34JAS415clojurebot wont' let you use eval
01:34JAS415as it can be used nefariously
01:34JAS415but in your repl you can do that
01:36JAS415,(type '(fn [x] (identity x)))
01:36clojurebotclojure.lang.PersistentList
01:36JAS415,(type (fn [x] (identity x)))
01:36clojurebotsandbox$eval__6948$fn__6950
02:28travisbradyanyone know of a simple example showing how to loop over stdin in clojure?
02:48JAS415loop over std in in what way?
02:48JAS415like read a file?
02:48JAS415look at clojure.contrib.duck-streams
02:48JAS415can also do java calls if you must
02:56manic12is there a print-object function in clojure which can be extended/overloaded?
02:57dms_there is print-dup.
03:03manic12thanks
03:03manic12I'm not sure how to correctly add a method to it though
03:08dms_Its just a normal mulit-method. To modify printing strings for instance, you will have something like (demethod print-dup java.lang.String [x writer] (pr "my-string" "s"))
03:11dms_Hmm.. There also seems to be print-method which dispatches on (type..).
03:11dms_(doc print)
03:11clojurebot"([& more]); Prints the object(s) to the output stream that is the current value of *out*. print and println produce output for human consumption."
03:22dms_ok. i really dont understand print-dup and friends as much as i thought i did.
03:25manic12no, I figured it out
03:26manic12if you want to see it I'll paste it somewhere, I looked at the clojure source
03:27dms_I just looked at core_print.clj. Now it makes sense. Thanks.
04:10BercilakHas there been anything like doctests done for clojure?
04:10BercilakI read about the :test metadata in Programming Clojure, but it doesn't seem like anybody uses that in the wild.
04:19eevar2Bercilak: unit testing? :use clojure.test
04:20BercilakI've been reading the clojure contrib docs, and I really *want* to like them but there just aren't enough examples.
04:21BercilakI come from a python background, and I love what doctests have done culturally for python.
04:22BercilakSimple, verified examples are weaved directly into the documentation...
04:22ChousukeI think with clojure it's more common to just test your function until you're sure it works ;P
04:22Chousukeand then move onto another one
04:23eevar2Bercilak: i'm sure the clojure api docs could use more examples, yea
04:23Chousukebut hm, while I'm not aware of any doctest stuff, Rich did add support for pre- and post-assertions at some point.
04:24ChousukeI haven't seen that used much either though
04:24somniumI think immutability + isolated side-effects remove a lot of the need for testing in languages like Python/Ruby
04:24hiredmanoh yeah
04:24BercilakMy name just showed up on the clojure contributor page so I'm giddy to do something useful. :-) Examples in documentation are always good.
04:25Chousukedid you already join Assembla and the dev group?
04:25Bercilakassembla yes, not the dev group yet
04:26BercilakI'm not even really interested in the testing aspect of it. It's more about the documentation, but having the documentation verified as correct.
04:26BercilakI was kind of hoping that :test was in wide use, because that could be pretty easily automatically converted into documentation.
04:27BercilakI'll look at doing that with assertions, but I might also whip up some code for doing clojure doctests...
04:27Chousukeit shouldn't be too difficult. :)
04:28Bercilak:-). Nope. Just making sure there wasn't something obvious I was missing...
04:28BercilakI really like clojure.
05:56ol3`hello, how do I define vars which should not be exported?
05:58dms_ (def #^{:private true} myvar [1 2 3])
05:58dms_That keeps the var private. There is defn- for functions.
05:58ol3`dms_: thanks
05:59dms_might also want to see clojure.contrib.def. I remember seeing some related utilities.
06:42ol3`(doc ns)
06:42clojurebot"([name & references]); Sets *ns* to the namespace named by name (unevaluated), creating it if needed. references can be zero or more of: (:refer-clojure ...) (:require ...) (:use ...) (:import ...) (:load ...) (:gen-class) with the syntax of refer-clojure/require/use/import/load/gen-class respectively, except the arguments are unevaluated and need not be quoted. (:gen-class ...), when supplied, defaults to :name correspo
06:52ambientdanm, it's really slow to write the functional stuff, but the code is damn _compact_
06:52ambientjust a few lines does more than 50 lines of Java
06:56LauJensenHey guys
06:57liwpLauJensen: good morning
06:57cgrandhey!
06:58liwpit's pretty quiet here these days during the day (european time)
06:58liwpor at least it seemed busier a little while back
06:58liwpmaybe it's all in my head
06:58achimhi!
06:58achim does anybody know a decent java decompiler? most of those showing up on google seem to be either very old or dubious shareware gui apps
06:58liwpachim: doesn't the jdk include some sort of decompiler?
06:59liwpachim: do you want to decompile class files to java source or byte code (asm)?
07:00achimliwp: .class -> .java, preferably
07:00liwpthe thingy in the jdk 'decompiles' classes to byte code so you can look at the byte code that the compiler produced, so possibly not what you were looking for
07:00liwpok
07:00LauJensenliwp, I sense a little slowing down of our community as well
07:00achimi'm afraid i can't read asm all that well
07:01liwpachim: I think all the decompilers I've looked have always been a little clunky. Not a lot of commercial use for such a tool
07:01liwpachim: the java byte code is quite easy to read since the JVM is a stack machine
07:01liwpi.e. things are put on the stack and then subsequent instructions operate on the operands that are on the stack
07:02liwpit takes a little practise to get used to it (and I'm in no way an expert), but after that it's relatively simple. A lot easier than x86 asm
07:02liwp(lunch)
07:35powr-tocWhat's the syntax for accessing a java inner class in clojure?
07:37powr-toc(OuterClass/InnerClass.) doesn't work
07:37powr-tocnor does (OuterClass.InnerClass.)
07:39arbschtOuterClass$InnerClass
07:39powr-tocahh yeah... just found it as you said :-)
08:03LauJensenDo we have an installer like izPack for Scala?
08:18powr-tocIs there a macro that allows you to def a var with a docstring?
08:23LauJensenDo you need a macro for that?
08:23Chouserpowr-toc: in contrib there's a defvar
08:24Chouserpowr-toc: or you can say (def #^{:doc "my doc string"} foo 5)
08:47AWizzArdtomoj: so far there is not such a starter guide for fnparse. You can try the wiki, there is some documentation. And just try to use (lit ...) in the beginning, that can get you started.
10:17ol3`(doc ~io!)
10:17ol3`,(doc ~io!)
10:17ol3`,(doc io!)
10:17clojurebotjava.lang.ClassCastException: clojure.lang.PersistentList cannot be cast to clojure.lang.Symbol
10:17clojurebotjava.lang.ClassCastException: clojure.lang.PersistentList cannot be cast to clojure.lang.Symbol
10:17clojurebot"([& body]); If an io! block occurs in a transaction, throws an IllegalStateException, else runs body in an implicit do. If the first expression in body is a literal string, will use that as the exception message."
11:23rhickeystuartsierra: latest rdfm is approaching the model I am looking towards, feedback welcome (I know, docs :)
11:29rhickeylisppaste8: url
11:29lisppaste8To use the lisppaste bot, visit http://paste.lisp.org/new/clojure and enter your paste.
11:32stuartsierracool
11:32lisppaste8rhickey pasted "fiddling with rdfm" at http://paste.lisp.org/display/86930
11:32stuartsierraI keep reading "rdfm" as "RTFM".
11:32rhickeynow has transactions and assoc/dissoc model
11:32rhickeystuartsierra: right, it's Brooklynese :)
11:32stuartsierragot it
11:33rhickeylooking for better name
11:35Chouser~I was trying to think of a better name, and getting nowhere, then suddenly it came to me:
11:35clojurebotCLABANGO!
11:37Chouserrhickey: would you have any interest in proxy generating automatically-named methods for base class's protected fields and methods?
11:39rhickeyChouser: my most recent thoughts were that I think it will be the best use of resources to layer reify/proxy, so the circumscribed part (reify) can be thought of as portable Clojure while the icky bits (protected access, ctors) part of the proxy superset, proxy being an interop construct
11:40ChouserI like the separation of concerns for refiy vs. proxy. Are you also saying that proxy would be re-engineered to be implemented using reify?
11:40rhickeyputting more work into the (much slower) proxy seems a waste, and the pressure on reify to supplant proxy will be great
11:40rhickeyChouser: yes, reify + more work == new proxy
11:41Chouserok
11:41rhickeyI don't think many are leveraging the dynamic aspect of proxy, but if so we can find a new name
11:42Chouserok
11:42Chouserso perhaps java-specific features as options to reify that are marked as non-portable?
11:43rhickeyonce based on reify you won't need generated wrappers for protected access
11:43Chouserthen proxy can be just a macro that expands to java-only reify
11:43Chouseroh. oh, right.
11:44rhickeyChouser: I think right now the distinction matters only to me. But what I fear is that people will write new code using reify/proxy as Java-in-parens. proxy should only be used for some-badly-designed-library-is-forcing-me-to-do-this situations
11:46Chouserwould still have an issue with ctor args + closures
11:48rhickeythat depends, right now proxy only let's you flow through ctor args to super ctor, it doesn't have exposed ctor of its own per se
11:49Chouseroh, right the ctor args issue was using reify to provide a base class.
11:52Chousukemaybe (reify [Foo] {:host java} ...)
11:54ChouserChousuke: I was going for something sufficiently onerous that one would definitely prefer using 'proxy' instead
11:55ChousukeChouser: okay, well {:allow-host-features #{feature1, feature2 ...}}
11:56Chousukethough that might be too onerous :P
11:59Chouserso the idea is to discourage the use of 'reify' for purely interop cases. But things like ctor args would likely be available for interop on almost all hosts
12:01Chouserproxy even on reify would still need a way to call super class methods that have been overridden
12:01Chouserwhich again reify may not need, depending on the design of the no-arg ctor base class.
12:01rhickey(.super-whatever this ...)
12:02Chouserauto-named methods of the new class
12:16AWizzArdrhickey: I think there is a type at https://www.assembla.com/spaces/clojure-contrib/milestones where it says "... decide to work on the and ..."
12:16AWizzArdtype ==> typo
12:16AWizzArd:)
12:42AWizzArdHow can I make a private inner class and extend it from an existing one?
12:42stuartsierraIn Clojure?
12:43AWizzArdyes
12:43AWizzArdproxy, right?
12:43stuartsierrainner classes don't really have any meaning in Clojure
12:43stuartsierraYou can proxy almost any class.
12:43AWizzArdstuartsierra: please look at this example: http://www.rgagnon.com/javadetails/java-0538.html
12:44stuartsierrajust proxy javax.mail.Authenticator
12:44AWizzArdoki good
12:50AWizzArdstuartsierra: and how can I make an instance of that proxy?
12:51AWizzArdin the example code the guy did Authenticator auth = new SMTPAuthenticator(); where SMTPAuthenticator was his private inner class that extended the Authenticator
12:51AWizzArdBut I can't just call new on a proxy
12:53Chousukeyou have a function that contains (proxy [Authenticator] [] ...)
12:54Chousukeand then just call the function whenever you need an instance
12:54AWizzArdok, I see
13:58stuartsierrarhickey: I maven-ized your rdfm sources: http://github.com/stuartsierra/rdfm
14:04rhickeystuartsierra: what does that mean?
14:04stuartsierraI wrote a pom.xml with all the necessary dependencies.
14:05rhickeywow - does it really need all of those?
14:05stuartsierraSesame is weird, it's broken up into lots of little modules. I haven't figured out if there's a cleaner way to depend on the whole thing.
14:07rhickeyI know consumers of rdfm using Sesame might end up using a lot of it, but I've tried to minimize the use in the lib itself, in case people want to use with allegrograph or virtuoso probably won't need more than repository and model
14:08stuartsierratrue
14:08stuartsierraI'll see if I can minimize it
14:08rhickeyis there a reason to have src/main/clojure/ then org/clojure/rdfm.clj?
14:09rhickeyis that a maven thing?
14:10stuartsierraIt's the default maven directory layout, things are easier if you follow that.
14:10technomancymaven users generally get paid by the directory. =)
14:10rhickeyah
14:11rhickeysilly me, I just put the deps in http://github.com/richhickey/rdfm/downloads
14:11stuartsierraThere's a kind of logic to it, dividing up all your sources by type means you never need to filter on file names.
14:11rhickeystuartsierra: I'm fine with whatever is easy, just wondering what it will take to rearrange my repo
14:12stuartsierraNothing much, you can just pull from me if you want.
14:12stuartsierraJust pushed a smaller pom.xml
14:13stuartsierraI only changed one line in rdfm.clj, commenting out (set! *print-meta*...)
14:15stuartsierraCopying jars around just got annoying, I'm trying hard to make Maven work.
14:15rhickeystuartsierra: did you get to look at the model? I dropped all used of bnodes, I'm kind of anti-bnode now. once an identity is in the rdf graph you can use rdfm/assoc/assoc*/dissoc/dissoc* (in transactions) to maintain it
14:17rhickeyI have thoughts about being able to tie rdf and jms queue transactions to dosync
14:17stuartsierraI don't like bnodes either, but how do you avoid them?
14:17rhickeythen you could dosync, with linked rdf/queue transactons, and on STM retries you'll get rollbacks, all commit together
14:18rhickeythen you could dosync, with linked rdf/queue transactons, and on STM retries you'll get rollbacks, all commit together
14:19rhickeystuartsierra: I just never create bnodes. for this api the purpose is to rdf-persist Clojure data, so it's just a matter of choice
14:19stuartsierraOk, that makes sense.
14:20rhickeyplus, I can;t rely on bnodes being the determinant of whether something is 'owned/nested'
14:20stuartsierrawhat does owned/nested mean?
14:20rhickeyfinally, bnodes have startling existential semantics that few people using them are aware of
14:21rhickeywhen you store an unnamed composite as an attribute (a nested map/vector) they are considered 'part' of your document (for document style use). These would normally be things for which bnodes would be used, not addressed directly only as a subpart
14:22rhickeybut storing nested as bnode doesn't imply bnode == nested
14:22rhickeyso now there is a proper ns for nested collections
14:23stuartsierraok, so for rdfm, bnodes DO imply nesting?
14:23rhickeywhen you store-root you get a top-level identity (UUID URI if you don't supply your own)
14:26stuartsierraok
14:26rhickeystuartsierra: no, there are no more bnodes at all,
14:28rhickeynested aggregates are under the http://clojure.org/data/collection/ ns
14:28rhickeyhttp://clojure.org/data/collection/vector# "http://clojure.org/data/collection/hash-map#
14:29rhickeyuuid after the #
14:30rhickeyso pull will grab nested by default, but not walk into other URIs
14:30rhickeythe idea is inspired by CBD: http://www.w3.org/Submission/CBD/
14:31rhickeybut pervasive use of bnodes in some graphs renders cdb tricky
14:31rhickeythis way there is a clear document model - don't want ownership then store-root it separately
14:32rhickeystill up in the air are true functional properties, I really want them
14:32stuartsierraOWL has functional properties, but not RDF alone.
14:33rhickeyyeah OWL has FunctionalProperty but no triplestore has enforcement
14:34rhickeyI could use that as a tag, but would need to preload and cache in order to avoid having to look up for every statement store
14:34Chouserignore me if this is too off topic, but do you know of any revision control predicates for RDF?
14:34rhickeybasically I need to know so I can restore a single-statement s p o as either o or #{o}
14:35rhickeyChouser: I once built a triplestore on relational that had full point-in-time snapshot capability
14:36Chouserso the snapshoting was outside the RDF graph?
14:36rhickeybasically was not triples (none are) and had a version/deleted field in each statement
14:36stuartsierraChouser: http://vocab.org/changeset/schema.html
14:40Chouserstuartsierra: ok, interesting. I wish google wave used rdf internally.
14:43stuartsierrarhickey: re restoring single statements, I don't think that's solvable right now. RDF is too vague about that.
14:52rhickeystuartsierra: well. if I or the user would tag those predicates as functional I could easily restore as single vs 1-item-set
14:53rhickeythen {:a 1 :b #{2}} would round-trip =
14:53rhickey:a functional, :b not
14:54stuartsierraok, just figured out how to dump the triples:
14:54stuartsierra(.exportStatements c nil nil nil false (org.openrdf.rio.turtle.TurtleWriter. *out*) (into-array org.openrdf.model.Resource []))
14:55stuartsierraIf you want to round-trip, you might as well define RDFS Classes for each Clojure type.
14:56rhickeystuartsierra: I really want to use as little of rdf as possible. I want to leverage triplestores. RDF itself is another story
14:57rhickeythe only reason I'd use owl:FunctionalProperty is it says what I want. I fully expect to pull partial graphs etc. I don't want an oodb
14:58stuartsierrahm, ok. Those predicates just look odd, like you're embedding type information in the URI.
14:58rhickeyright now if you store :b #{2} you get back :b 2
14:59stuartsierraI'd prefer to store :b 2 and get back :b #{2}
14:59rhickeystuartsierra: I am, and yes. but the alternative is double lookup for everything and my data in your data
15:00rhickeystuartsierra: that's the easy way, but really, most application data is not multi-valued
15:00stuartsierratrue
15:00rhickeyI asked about multimaps here a while ago and got a bunch of - who cares? :)
15:01stuartsierraWhat's a multimap? Like {#{:a :b} #{:c :d}} ?
15:01rhickeyI'd find it really arduous to have to deal with a ton of single-value sets
15:02stuartsierraThat doesn't bother me so much, only because I realized that merging maps that might contain duplicate information, I ended up with lots of single-value sets anyway.
15:02rhickeystuartsierra: multimap is exactly what I'm doing with rdfm (and what rdf does) - you can consider rdf subjects + predicates multivalue maps
15:03rhickeystuartsierra: I think if you are working with pre-existing rdf data there is a completely different set of needs. In fact, AAA theory means you could always get another value for any predicate
15:04stuartsierraright
15:04rhickeythis Clojure data model has a closed-world assumption
15:04stuartsierraok
15:04rhickeyI think it is a really interesting space, but triplestores have been dominated by rdf and semantic web
15:04stuartsierragot to go grab some lunch, back in a few
15:06rhickeyhmmm--- should we use cgrand's parsely for cinc? - http://github.com/cgrand/parsley/blob/master/src/net/cgrand/parsley/demo.clj#L11-42
15:07ChouserChousuke's got a reader mostly done. I haven't looked at it.
15:07Chouserambiguous grammars. huh.
15:09ChousukeI should just find the time to make clojure actually use my reader and work out the bugs :P
15:10Chousukebut a reader based on a proper parser library might be better.
15:11ChouserI was thinking it might be nice to have a lib that converts a Compiler-produced AST to a clojure-collection AST
15:11cgrandrhickey: perfwise, I wouldn't recommend it. It's aim is to serve as the basis for the incremental parser in the Eclipse plugin. I think it has too much baggage to be used in lieu of a simple reader.
15:12rhickeycgrand: I'm sure not as fast as a reader, but incremental, recoverable parser is need for so many tools
15:13Chouserthis would allow work on defining the cinc AST to proceed first (with immediate benefits for understanding current Compiler decisions ala expression-info) and allow java-emit code and cinc compiler work to proceed independently
15:14Chouseralso could be used to compare results of cinc compiler with current compiler.
15:14Chouserthe main drawback: it would all be throwaway code. :-/
15:15Chouseranother benefit: more fun to write than performance-tuning finger trees
15:18stuartsierraQuestion about all the parsers/readers: why not just write a grammar?
15:20rhickeystuartsierra: for what, antlr?
15:20stuartsierrasure, or JavaCC
15:20stuartsierraantlr's easier
15:22Chouserwe'd have to have all antlr in the clojure runtime then, right?
15:22stuartsierrayes, but it's not that big; if you can't bear the thought, use JavaCC
15:22rhickeystuartsierra: #1, it's another dep, #2, it's left-recursive
15:23stuartsierraWhy is left-recursion a problem?
15:26rhickeyhttp://code.google.com/p/clojure/source/browse/trunk/src/jvm/Reader.g?r=300
15:27rhickeyI forget how far I got...
15:28stuartsierraah, ok
15:28rhickeyin the end, a lisp-style reader is so trivial
15:28stuartsierratrue
15:29stuartsierraso why does everyone seem to want to rewrite it?
15:31hamzahey guys, i am trying to save a map to a file for some state saving, i am trying to use prn for this but i can't seem to find how should i direct prn to a file? doc says it outputs to *out* i am assuming it is console?
15:32hiredman*out* is a var
15:32hiredman,(doc *out*)
15:32hiredman:(
15:33hamzain my system it defaults to System/out. can i change it without messing the repl or is there another way to save a map?
15:34hiredmanyou use binding
15:34stuartsierraYou can bind it. (binding [*out* (java.io.FileWriter. "/your/file")] ...)
15:35hamzathanks, am i on the correct route at using prn to save things to files, or is there a better approach?
15:35stuartsierrayes
15:35stuartsierraprn is good
15:37hamzaone other thing how do i read it back?
15:37stuartsierra(read-string (slurp "/your/file"))
15:38hamzathanks, is there a limit on the size of the file for reading? that i should know about/
15:38hamza.
15:38stuartsierraOnly the limit of memory in the JVM.
15:39hamzathanks a lot,
15:40lambda-avengerAre there any examples on using Java enums from clojure?
15:40hiredman,(doc *out*)
15:40clojurebot"; A java.io.Writer object representing standard output for print operations. Defaults to System/out"
15:41stuartsierralambda-avenger: you can refer to an existing enum just a static field, ClassName/VALUE_NAME
15:41stuartsierrabut you can't create new enum types
15:42cschreinerhow can I change the bindings of *out* permantently?
15:42hiredman,(doc reductions)
15:42clojurebot"clojure.contrib.seq-utils/reductions;[[f coll] [f init coll]]; Returns a lazy seq of the intermediate values of the reduction (as per reduce) of coll by f, starting with init."
15:43stuartsierracschreiner: not recommended, but (alter-var-root (var *out*) (fn [_] the-new-value))
15:43lambda-avengerBeen trying that, but keep getting java.lang.Exception: Unable to find static field: OneStar in class jcolibri.test.recommenders.travelData.TravelDescription
15:43cschreinerstuartsierra: thx
15:44hiredmanlambda-avenger: uh
15:45hiredmanaccording to http://guru-games.org/projects/jcolibri/jcolibri2/doc/api/jcolibri/test/recommenders/travelData/TravelDescription.Seasons.html there is no enum constant with that name in that enum
15:46lambda-avengerThat's a different enum. http://gaia.fdi.ucm.es/projects/jcolibri/jcolibri2/doc/api/jcolibri/test/recommenders/travelData/TravelDescription.AccommodationTypes.html
15:47hiredmanwell that is the enum you are looking for OneStar in
15:47hiredmanaccording the exception you pasted
15:48lambda-avengerBut both enums reside in the same class TravelDescription
15:48hiredmanno
15:49hiredmanoh
15:49hiredmanare you sure that is the full exception message?
15:51hiredmanjcolibri.test.recommenders.travelData.TravelDescription$AccommodationTypes/OneStar
15:51lambda-avengerThat works, thanks hiredman.
15:51clojurebothiredman is lazy
15:51hiredmanclojurebot: thanks, jerk
15:51clojurebotHuh?
15:52hiredmanclojurebot: you heard me!
15:52clojurebothiredman: I'm just giving you a second chance
15:52hiredmanclojurebot: why, I outta!
15:52clojurebothttp://clojure.org/rationale
15:53hiredmanclojurebot: brain?
15:53clojurebotbrain dump is http://clj.thelastcitadel.com/clojurebot
15:59lpetithi
16:03cschreinerthe clojurebot is pretty cool
16:03cschreinercan clojure rule the world?
16:03hiredmanclojurebot: well?
16:03clojurebotExcuse me?
16:04cschreinerclojurebot: can you rule the world?
16:04clojurebotwhat the world needs is more higher order functions
16:04cschreinerclojurebot: what is reality?
16:04clojurebotreality is an illusion which arises due to a lack of drugs
16:04cschreinerok, I see
16:04hiredman:/
16:06technomancyhamza: you can use with-out; that encapsulates what you want
16:06technomancy~doc with-out
16:06clojurebotI don't understand.
16:06technomancy,doc with-out
16:06clojurebotjava.lang.Exception: Can't take value of a macro: #'clojure.core/doc
16:06technomancy,(doc with-out)
16:06clojurebotNo entiendo
16:06hiredman,(doc with-out-str)
16:06clojurebot"([& body]); Evaluates exprs in a context in which *out* is bound to a fresh StringWriter. Returns the string created by any nested printing calls."
16:06technomancyyou think by now I'd get the hang of this
16:06technomancyyes, that
16:06steganohi guys I am curious about clojure ... and by reading the brief description on the home page it seems the language is dynamic like Ruby .. and its a compiled language too ... so I am wondering does the compilation to bytecode happen at execution time or not ??
16:06hiredmanstegano: depends
16:07technomancystegano: Ruby is compiled and dynamic too (YARV/Rubinius)
16:07steganohiredman: hmm ... could you elaborate onthis
16:07dnolenstegano: when you start up a Clojure REPL and evaluate forms they get compiled on the fly.
16:08hiredmanyou can take a .clj file and compile it to byte code a head of time
16:08dnolenyou can also Ahead-Of-Time (AOT) compile files as well.
16:08dnolenstegano: Clojure is never interpreted.
16:08hiredmanor you can just load the .clj file, and it will be compiled to bytecode then executed
16:08cschreiner,(doc union)
16:08clojurebotExcuse me?
16:09hiredmanclojure.set/union
16:09cschreinerah, thx
16:11steganodnolen: so clojure REPL is like Scala's and AOT is also similar .... actually there is only AOT in clojure right?
16:11steganoi mean AOT compilation
16:12Chouserfor some reason we use AOT to refer only to saving out .class files
16:12hiredmanwell, the other is sort of JIT to bytecode
16:13hiredmansort of
16:13ChouserYeah, I suppose.
16:15steganoChouser: so .clj i take it is the extension for clojure source file ... what I am trying to understand is when does JIT happen in clojure and when does AOT happen .... or is AOT always manual invoked ?
16:15ChouserAOT is manually invoked using the 'compile' fn.
16:15Chouser,(doc compile)
16:15clojurebot"([lib]); Compiles the namespace named by the symbol lib into a set of classfiles. The source for the lib must be in a proper classpath-relative directory. The output files will go into the directory specified by *compile-path*, and that directory too must be in the classpath."
16:17hiredmanstegano: I wouldn't actually go around calling it the compile to byte code just before execution bit a JIT
16:17hiredmanit is bound to be confused with the jvm's JIT to native code
16:19steganohiredman: i agree it will be confusing ... so is there a term used in the clojure land to describe to compilation to bytecode .... and more importantly is the compilation to bytecode invoked from within the code ...... it seems it is using (doc compile) ... am I wrong ?
16:20hiredmancompile is just for the AOT of time stuff
16:20hiredmanwhich is somewhat exceptional
16:21hiredmanmostly I just type stuff into the repl like (+ 1 2) and it gets compiled to bytecode and executed
16:22steganohiredman: so compile is just for AOT ... which is manually invoked from within clojure code using (doc compile) ?? or is there a shell command to AOT compile clj sources
16:22hiredmanthere are a few ways you can do it
16:22hiredman~clojure-stub
16:22clojurebotclojure-stub is http://github.com/nakkaya/clojure-stub/tree/master
16:22hiredmanis a stub project that uses ant to AOT compile clojure code
16:24steganohiredman: cool thanx for letting me know about clojure-stub ..... so the dynamicity of clojure is from the fact that there is duck typing and the code doesn't need to compiled Ahead of Time ... so its almost interpreted in a way ??
16:24hiredmanno
16:24hiredmanit is definetely compiled
16:26steganohiredman: ok only in REPL the clj source doesn't need to be compiled ahead of time ... in that way its like lisp/ruby/scala REPL .... but outside of REPL I assume clojure is like scala in that the source file need to be pre-compiled
16:26hiredmannope
16:27steganohiredman: ok i am thoroughly confused :(
16:27hiredman~compile
16:27clojurebotthe unit of compilation in clojure is the namespace. namespaces are compiled (not files). to compile a namspace the namespace needs to be on the classpath and so does ./classes/ (and the directory needs to exist) because clojure writes the class files to that directory. http://clojure.org/compilation
16:27hiredmanthe url there has a list of reasons why people might need to AOT compile their code
16:28hiredmanbesides that there isn't much of a reason
16:28Chouseryou can think of it this way: every top-level expression (at the REPL or in a file) gets compiled to bytecode and then run by the JVM
16:28hiredmanrlwrap java -server -Djava.security.manager -cp $CLASSPATH:./clojurebot/ clojure.main -i clojurebot/hiredman/clojurebot.clj -r
16:28Chouserit can *also* (by use of the 'compile' function) be saved to a .class file just before it's run by the JVM.
16:28hiredmanis how I launch clojurebot, from a .clj file, no AOT compilation
16:30drewris there something, in commons-httpclient perhaps, that will decode HTML?
16:30steganoclojurebot: so namespace can span multiple clj files and these files can be loaded in REPL shell or they can be executed outside of REPL .... in the latter style of execution ... won't the clj files need to be precompiled ??
16:30drewrI need "foo & bar" -> "foo & bar"
16:30dnolenstegano: AOT is all about deployment. Perhaps you just want to deploy a jar of compiled code. Perhaps you want fast start up time (say you have a _lot_ of clojure files). perhaps you running on a platform where compiling code on the fly is unrealistic (Google App Engine, Android)
16:31hiredmanthe repl is not anything special
16:31hiredmanit is just a few clojure functions
16:32drewrah, here we go
16:32drewrhttp://stackoverflow.com/questions/994331/java-how-to-decode-html-character-entities-in-java-like-httputility-htmldecode/994339#994339
16:32steganohiredman: so basically clojure REPL is not much different from scala's REPL except that in clojure you can compile a namespace
16:32steganohiredman: is that right ?
16:32clojurebothiredman is an evil genius.
16:32hiredmandrewr: http://gist.github.com/185550 is pretty useful
16:32hiredmanclojurebot: knock it off
16:32clojurebotHuh?
16:33hiredmanstegano: I don't know anything about scala's repl
16:34hiredman~scala ((x: Any, y: Any) => (f: Function2[Any, Any, Any]) => f(x, y))(1, 2)((x: Any, y: Any) => x)
16:34clojurebotAny = 1
16:35steganoyou guys just drew circles around me and that too of parenthesis :) shame on you :)
16:35steganojust kidding
16:39lpetitDoes anybody know if there's an automated way to migrate a google code project's wiki pages and issues to e.g. github ?
16:44hiredmanthere was an issue filed about it in the googlecode issue tracker
16:44hiredmanI know clojure's issues where migrated by hand
16:45lpetitoh ok. I just have 30 bugs in clojuredev to be migrated to ccw, I guess I'll do that by hand too.
18:17manic12is it better to use slime for clojure, because I'm having a helluva time with enclojure?
18:22ambientuse what feels best for you. dont fix what aint broken
18:24manic12yeah, but I want to learn clojure, I'm already good with common lisp
18:25ambientenclojure is good, i use it. it's great. use it
18:25manic12then please help me
18:25ambienti've found no problems with it
18:25ambientyou're not presenting me with any problem
18:26manic12i'm on the #enclojure channel, can you talk to me there?
18:26ambientsorry, can't right now
18:26manic12can't talk or can't switch?
18:45steganohi guys could you name some testing frameworks for clojure and webframeworks too please
18:46Chousukeclojure.test (only in git at the moment though) and compojure :P
19:33crioshello
19:34criosI'm a clojure newbe. Could anyone help me on an example of "clojure programming" book?
19:36arbschtcrios: state your question and someone will help you if they can :)
19:37criosI cannot understand how the "parse" xml function is included into the "examples/tasklist.clj" example
19:38criosthe example starts with a "(:use [clojure.contrib.duck-streams :only (reader)])"
19:38criosbut does not contain (:use [clojure.xml :only (parse)])
19:39criosthe function is then used in this way: (parse (InputSource. (reader (File. arg)))
19:39criosetc
19:41criosHow is 'parse' imported? After two hours trying to understand I'm a bit puzzled :)
19:43Chousukeit might just be a mistake in the example :/
19:43crioshere the code: http://pastebin.com/d28b74b0e
19:44criosno, it compiles with (compile 'examples.tasklist)
19:44crios(and that was also my first thougth :))
19:45Chousukethat uses clojure.xml/parse directly though. hm.
19:45criosI checked also the "clojure.contrib.duck-streams" library, but no 'parse' import, too
19:45Chousukedoes it run as well? :/
19:46Chousukejust compiling it does not guarantee that it runs.
19:46crios@Chousuke: the (clojure.xml/parse is mine
19:46criosthe original version is (parse
19:47criosAnd yes, it worked.
19:48JAS415parse is in clojure ns
19:48Chousukeyou're not running it from the repl or anything?
19:48Chousuke,`parse
19:48clojurebotsandbox/parse
19:48Chousukeapparently not :/
19:48JAS415hmm
19:49crioshere the original version: http://pastebin.com/d3bb9cfa2
19:49criosparse is into xml.clj , into clojure.jar
19:49Chousukeah, duh.
19:49Chousukeit's not clojure.xml/parse at all
19:50Chousukeit's a method of the SAX parser object.
19:50Chousukenote the .. form on the previous line
19:51JAS415lol
19:51Chousukeit's like SAXParserFactory.newInstance().newSAXParser().parse(new InputSource( ...))
19:51criosso an instance method can start without a dot? I was expecting (.parse
19:51Chousukecrios: it's ..
19:52Chousukecrios: (.. foo bar (foo bar)) means foo.bar().foo(bar)
19:52criosAh ok, I understand!
19:53Chousukeyou might prefer -> to ..
19:53criosreally puzzled , thank you Chousuke
19:53Chousuke,(-> "Hello" (.substring 2 5) .toUpperCase)
19:53clojurebot"LLO"
19:54Chousuke,(.. "Hello" (substring 2 5) toUpperCase)
19:54clojurebot"LLO"
19:54Chousuke,(-> "Hello" (subs 2 5) .toUpperCase); -> works with clojure functions too
19:54clojurebot"LLO"
19:55Chousuke.. is pretty much obsolete because of -> but it was there first.
19:55criosah, never seen this notation : ->
19:55criosso -> is "deprecated" ?
19:55Chousukeneither is. -> is more powerful than ..
19:56Chousukeif anything, .. should be deprecated
19:56crioswhy more powerful?
19:56clojurebothttp://clojure.org/rationale
19:56Chousukecrios: you can't mix clojure functions and java methods with ..
19:56Chousukecrios: it's strictly method-only
19:57Chousukecrios: whereas -> actually just transforms code like (-> foo .bar) to (.bar foo)
19:58criosso if (.. whatever (whatever ()) ) then 'whatever' can be just java method and never functions?
19:58Chousukeand further (-> foo (.bar zonk) clojurefn) becomes (-> (.bar foo zonk) clojurefn)
19:58Chousukeyeah
19:58Chousuke-> is a more general macro that just accidentally happens to do what .. does if you use it with the ".method" method notation
20:00criosok, thank you, I'm still reading the book and have not yet seen -> (I hope it will be explained)
20:02Chousukein short, -> does the following: 1) if the second argument is a symbol, wrap it in a list. otherwise, do nothing 2) take the first argument and insert it after the head of whatever results from step 1. 3) if there are more arguments, call -> on the result of step 2 and the remaining arguments; otherwise, the code generated is what step 2 produced.
20:03Chousukeit sounds complicated no matter how you explain it but if you try and experiment a bit you should see it's pretty useful
20:03Chousukeand rather simple, in the end :)
20:03crios(I'm copying you description, to study it carefully :)
20:04crioshere where the author uses clojure.xml/parse: http://pastebin.com/dcf15462
20:06crioscoming from java, it is a sort of challenge read a source code as a parser/tokenizer would do, in a lexical way
20:06criosin java you have just packages, and simple import stastement
20:08crios-> is a reader macro? should it be here :http://clojure.org/reader ?
20:08Chousukenah, it's just a macro.
20:09Chousuke(doc ->)
20:09clojurebot"([x form] [x form & more]); Threads the expr through the forms. Inserts x as the second item in the first form, making a list of it if it is not a list already. If there are more forms, inserts the first form as the second item in second form, etc."
20:11criosalso here http://clojure.org/API#toc35
20:11Chousukethe thing to remember with macros is that their arguments are not your program's values, but literally code.
20:13Chousukeso if you do (def foo (new SomeJavaClass)) and then do (-> foo .method .method2) you're not calling -> with the instance of SomeJavaClass as its parameter --- the parameter is the symbol foo
20:14Chousukesimilarly, the .method and .method2 are also only symbols
20:15Chousukethe macro then does whatever it wants with these symbols, and outputs a data structure that (hopefully) is valid clojure code
20:15Chousukeand then the compiler compiles it.
20:17Chousukethis is one more thing that takes a while to sink in, but until it does you're free to consider macros magical. :P I know I used to.
20:18crios:)
20:19criosah another question: what is the difference between (var and (resolve ?
20:19criosboth return Var , if I understood correctly
20:20Chousuke,(var +)
20:20clojurebot#'clojure.core/+
20:20Chousuke,(resolve '+)
20:20clojurebot#'clojure.core/+
20:20Chousuke,(resolve 'foo)
20:20clojurebotnil
20:20Chousuke,(var foo)
20:20clojurebotjava.lang.Exception: Unable to resolve var: foo in this context
20:20Chousukevar is also a special form
20:21crios,(var 'foo)
20:21Chousukealso hm
20:21clojurebotjava.lang.ClassCastException: clojure.lang.Cons cannot be cast to clojure.lang.Symbol
20:22Chousukeheh, weird error messages
20:22criosquoting the symbol
20:22hiredman,(macroexpand 'foo)
20:22clojurebotfoo
20:22hiredmanbah
20:22hiredmanvar sees (quote foo)
20:22Chousukecrios: var doesn't evaluate its argument (it's a special form) so it doesn't need to be quoted
20:23hiredman,(macroexpand-1 'foo)
20:23clojurebotfoo
20:23Chousukecrios: in fact, if you quote it, var sees the list (quote foo)
20:23Chousuke(macroexpand ''foo)
20:23Chousuke,(macroexpand ''foo)
20:23clojurebot(quote foo)
20:23Chousuke(macroexpand is not a macro)
20:23crios,(var (quote foo))
20:23clojurebotjava.lang.ClassCastException: clojure.lang.PersistentList cannot be cast to clojure.lang.Symbol
20:24Chousukehm.
20:24Chousukedetails leaking out
20:24Chousukeapparently 'foo is not strictly equivalent to (quote foo)
20:25Chousukeit is as far as semantics are concerned though so never mind that
20:25criosanyway , the difference between (var and (resolve is just the error handling (exception versus nil) ?
20:25Chousukewell, resolve is a function
20:25Chousukewhich is why you need to quote the argument, as it wants a symbol as a parameter
20:26Chousuke,(resolve (symbol "+")); or you can do this
20:26clojurebot#'clojure.core/+
20:26Chousukealso hm
20:26Chousuke,(resolve 'String)
20:26clojurebotjava.lang.String
20:26Chousuke,(var String)
20:26clojurebotjava.lang.Exception: Expecting var, but String is mapped to class java.lang.String
20:28criosit seems (var expects a real Var, while resolve a symbol ?
20:30Chousukenah, Var works with symbols too
20:31ChousukeI can't actually tell the primary motivation for it though :/
20:31ChousukeI suppose resolve is runtime and var, being a special form, is compile-time?
20:31crioswho knows :)
20:31Chousukerhickey would :P
20:32Chousukeoh well, read the docs for the special forms
20:32hiredman~def resolve
20:32ChousukeI'll get some sleep.
20:34crios2here I am
20:34crios2after a firefox crash
20:34Chousuke:/
20:35crios2here don't see the history
20:35crios2you was giving me the link http://github.com/richhickey/clojure/blob/e35c4688f30a542d3585e72cfe9bc66936ca5afe/src/clj/clojure/core.clj#L2629
20:35Chousukenothing of value was said after that
20:36crios2ok
20:37crios2mm still don't see any real difference between var and resolve...
20:38crios2at last at 2:40 a.m. ! :D
20:39Chousukewell the fundamental difference still is that var is a special form and resolve is not.
20:40crios2ok
20:41crios2see you, good night and thank you
20:41crios2ciao
21:04manic12how do I get enclojure project repl to require my libs when it starts?
21:41JAS415what type of stuff do people use as database backends with clojure?
21:58ChouserJAS415: rhickey's working hard to get RDF triple stores to behave well in that capacity.
22:04JAS415cool
22:04JAS415now i just have to figure out what rdf triple is
22:05JAS415oo
22:06JAS415is like graph theory
22:06Chouserotherwise, regular java stuff -- jdbc sql, tokyo cabinet, etc.
22:08JAS415for anyone else for whom that went whoosh http://www.robertprice.co.uk/robblog/archive/2004/10/What_Is_An_RDF_Triple_.shtml
22:10hiredman~google rdf prolog
22:10clojurebotFirst, out of 29700 results is:
22:10clojurebotXML.com: An Introduction to Prolog and RDF
22:10clojurebothttp://www.xml.com/pub/a/2001/04/25/prologrdf/index.html
22:10JAS415if I use tokyo cabinet in a desktop application (presumably by using the java library) will i have to GPL (LGPL?) the entire project?
22:10hiredmankind of a neat idea
22:16JAS415prolog is a pretty nice query language
22:16JAS415my minimal experience with sql involves headache
22:22manic12is there a way to import all the class names from a java package?
22:32JAS415i think there isn't
22:40manic12I must be trying to swim against the current
22:42ambientautoimports might be a cool IDE feature, because nothing seems to start with a capital letter in clojure :)
22:44hiredmaneh? what does that have to do with aynthing?
22:46ambientyou could type class names and automatically import them if they were found in the libs because they're capitalized