#clojure logs

2008-11-20

00:01Chouserwell, I think this is right, because I can compile, and then run from the Repl without the .clj files in the path (just the compiled .class files)
00:02Chouserwhen I try to use the -main fn in my compiled class straight from the command line, I get: java.lang.IllegalStateException: Var null/null is unbound
00:02ChouserBut I think that must be a separate bug
00:04Chouserbah! yes, it's in fact a bug in my own source code.
00:05Chouserhm... or maybe not. I mean, i had a bug, but it doesn't seem to be causing that exception.
00:09Chouserok, ClojureScript must not be calling Compiler/analyze correctly when running from -main
00:09ChouserMust be some var I'm supposed to bind.
00:17mmcgranawell i gtg, good luck on figuring that out, sorry i couldn't really help
00:18Chousernp, thanks for poking at it with me
00:18mmcgranayep
00:20yangsx hi, can I tell slime to use the latest version after clojure.jar is updated?
00:22_Jordan_I don't suppose there's already a built-in "index-of" function I'm overlooking? Something like: http://gist.github.com/26947
00:27Chouser_Jordan_: I don't know of any.
00:28_Jordan_Thanks
00:29Chouser(count (take-while (complement #{'x}) '[z y x w]))
00:29Chouserbut that doesn't give you nil on failure
00:30ChouserI guess I don't use indexes into seqs much. You're sure you need it?
00:35_Jordan_no, I probably don't. Hold on, let me figure out what your snippet does :)
00:36hiredmanany progress on that pretty printer?
00:37Chousernope, gave it up since steven_h appears to be working on it
01:09larrytheliquidwhen you import functions into a namespace (in order to not fully qualify them) with "(use some-namespace", i get a filenotfound error due to the classpath
01:09larrytheliquiddoes that mean you cannot "use" functions from dynamically created namespaces?
01:16larrytheliquidnm, refer does the trick
02:29thearthurwhat is the proper way to nest a fn inside another?
02:29thearthur(def bla4 (let [baz (fn [x y] (when (pos? y) (lazy-cons x (baz x (dec y)))))]))
02:30thearthurthis gets me a null pointer exception in compilation (sometimes)
02:31hoeckthearthur: (fn bar [x y] ...)
02:31hoeckyou can name the anonymous function, so that it references to itself
02:32hoeck(let [foo (fn this [] this)] (= foo (foo))) -> true
02:33thearthurare you saying the function has 2 names, one for recuring and another by which it is referenced?
02:35hoeckwell, it has the name to where you bound it in the (let [ ..]) and the name you give it internally
02:36hoeckthe function itself doesn't see the let-bound one
02:38thearthuris this a reserved word?
02:38hoeckno
02:39hoeckbut "this" is used in the proxy-macro
02:40thearthuri c
02:40thearthurthanks so very much
02:40hoecknp
03:43_deepfireslyrus_, did anybody mention shadowing-import-from?
05:14blarfi want a function : (defn prolog []
05:14blarf (ref state {:rules {} :facts {}})
05:14blarfbut it returns the ref when i eval it
05:15blarfi want it do that obv when i call (prolog) only
05:15blarfi could ofc make a pure fucntiont hat doesnt use refs at all
05:15blarfbut i ind of want to
05:24hoeckblarf: there is a paren missing ath the end of (ref .. )
05:27blarflol thanks
05:32hoeckthanks going to xemacs expression-highlighting :)
05:33blarfah, i use normal emacs
05:35hoeckactually the same as emacs, just with an "x" on the front
05:58blarfhmm, im doing prolog and picking up my old OO-for-clojure-mini-project. im thinking, should i make classes immutable or mutable? im using refs so they are transaction-secure but perhaps i should only have function for creating a class with desired functionality and then let it be immutable?
05:59blarfhmm, if soemone even understand what im saying there :)
06:00tWipdo you mean should it be possible to "add" methods/properties to classes after definition?
06:01blarfso each update to an instance of a clas returns a new instance rather than using refs and manipluating them
06:01Chousukeblarf: return new instances
06:03blarftwip: well that is possible by default i guess, its dynamic.
06:03blarfChou: ok ill experiment with both and seee
06:04Chousukebut OO shouldn't be that difficult in clojure. You'll need some metadata-based system for tagging types and then you can use maps to represent your instances and the multimethod system for methods.
06:05tWipindeed, I think clojure already has what is needed for OO
06:05Chousukeactually you don't even need a system for tagging types, but I'm assuming you want some kind of rigid hierarchical OO model?
06:06ChousuketWip: clojure can do OO better than java if you ask me.
06:06tWipfor some value of OO
06:07ChousukeWell, you always have access to the java system
06:07tWipthere are so many aspects to it and different groups use different definitions
06:07Chousukeand then multimethods on top of that.
06:07Chousukegen-class is evil though.
06:07tWipnever used it
06:07ChousukeMe neither. I tried, but it's evil :(
06:09hoeckChousuke: you mean gen-class for making classes that are only accessed by clojure code?
06:10Chousukeno. that wouldn't make sense :/
06:10Chousukegen-class is java interop.
06:13blarfi have a half-functioning kind of not so beautiful OO-system already but my main problem was how to define emthods and eval them.
06:13Chousukeuse the multimethod system? :/
06:15tWipblarf: are you using maps for instances?
06:15blarfi want to be able to do mor epython-like OO. i want and kind of have: (def-class rectangle) (def-attr :width 10) (def-attr :length 20) (def-method area :width :length)
06:15Chousukestruct-maps and multimethods give you all that
06:16tWiphow would one implement encapsulation/information hiding when using maps?
06:17tWipI'm not saying that is necessary, just that it is a feature commonly in OO systems
06:17ChousuketWip: you wouldn't, really.
06:17Chousukejust like in python they don't.
06:18Chousukeit's just declared as off-limits and you're supposed to obey that. :P
06:18blarftWip: in Python you dont really have that, i ifnd it neat
06:18tWipI suppose it's more important in the state gathering mess of Java-style OO :P
06:19Chousukelanguages that implement data encapsulation and hiding can only prevent accidents.
06:19Chousukethey can't prevent actual access.
06:19Chousukeas long as the data is there, there exists a way to get to it :P
06:25hoecktwip: regarding encapsulation, you could do this with closures, by closing over a hashmap and allowing only access to specific keys for example
06:26tWipyou'd have to ref that, because you couldn't modify the closed over map
06:27tWipbut yes, that's a possible way to do it
06:28Chousukehmm, right.
06:29Chousukedefine a function lets a bunch of refs and returns a bunch of accessor functions :P
06:29Chousukeinstant instances
06:30Chousukeperhaps not optimal though.
06:30Chousukealso, +that
06:31Chousukewould be rather ugly and nonidiomatic though. :/
06:35blarfwhat is JAVA under the hood? a symbol-table-hack? written in C++?
07:15blackdog(find-doc) returns documentation on private functions
07:18blackdogI'm using slurp at the moment to load a file but how do i load a file relative to classpath
07:18blackdognot code any old file
07:21blackdoggetResourceasStream then?
07:22blackdogmaybe it would be good to have a function in core like loadResourceScript but for anything?
07:33Chousukephew. wrote a bunch of stuff about macros to the groups.
07:33ChousukeExplaining things to others really helps me in understanding them myself :)
07:35Chousukehm, maybe I should put that in the wiki :/
08:04hoeckwhat's the preferred way of implementing a java interface now, plain old proxy or :gen-class?
08:05rhickeyhoeck: :gen-class is about creating a named class for the Java world
08:06rhickeyso, for handlers etc stick with proxy
08:09hoeckaha, btw, am i allowed to use the proxy facilities directly?
08:09hoecki expanded the proxy macro once and built a function which takes a map of fn-name fn pairs and creates the proxy
08:10hoeckcreates the proxy directly, i mean
08:10rhickeyhoeck: other than proxy itself, I wouldn't rely on the support fns just yet, only because I'm looking at adding AOT support for proxy
08:11rhickeyit might end up the same or very similar
08:12rhickey2 objectives are to precompile the proxy classes themselves, and get rid of reflective construction
08:16hoeckI'm just playing around with the iris reasoner, and don't want to rewrite all the interface-gluecode once proxy-AOT works
08:16hoeckso I rather ask :)
08:17rhickeyhoeck: can you post your function, so I can see how you are using the underlying proxy API? It might help inform my decisions
08:17rhickeypaste
08:19hoeckrhickey: http://paste.lisp.org/display/70751
08:20rhickeyhoeck: thanks
08:22hoecki once discovered that there is just a hashmap and found that more convenient/functional/clojure-like than the proxy macro whith the aliased "this"
08:23hoeckand it makes it possible to pass something like identity function to proxy
08:23rhickeyhoeck: yes, it's just sugar. I'll probably try to get proxy macro off of calling construct-proxy (that's reflective) but can leave it in for usages like yours
08:24rhickeythe fundamental hash-map approach will stay the same
08:26hoeckrhickey: fine, thanks
08:39blackdogis there a clojure way of loading any resource from the classpath?
08:45duck1123any clojure resource?
08:45duck1123(doc load)
08:45blackdogany resource, not just a script
08:45blarfis this now allowed: (for [[x y] (zip a b)]
08:46duck1123(doc slurp)
08:46blackdogthat's from the file system
08:46blackdognot from the classpath
08:46blackdogi can get baseLoader() from RT so i guess i can do it using that
08:46duck1123hmm...
08:49duck1123I'm getting a strange error today: No matching method found: .start for class java.lang.Thread
08:50rhickeyduck1123: paset?
08:50rhickeypaste?
08:50duck1123I wish I knew where it was being called from
08:50duck1123that's just when I start up clojure/compojure
08:50duck1123I'm thinking it might be from the compojure side
09:00rhickeyI've updated http://clojure.org/java_interop to emphasize the member access sugar, is it clear?
09:01blackdogshould the doto example have .puts?
09:01rhickeyblackdog: just fixed :)
09:01blackdogk
09:02duck1123rhickey: would it make sense to put (Classname-symbol. args*) above the (new Classname-symbol args*) line to make that one clear?
09:06rhickeyduck1123: done
09:07duck1123thanks
09:08rhickeyI mean especially the new bit at the top - if you were just coming to Clojure and knew Java, would you be feel confident about how to call Java after the first section, without reading about the dot operator?
09:08duck1123I think it looks pretty clear
09:14duck1123rhickey: you might want to think about changing the "Dynamic Compilation" section of the dynamic page now that we have AOT
09:15rhickeyyeah, there's a lot to do in the docs, not going there now
09:17vdrabHi #clojure. could some kind soul tell me whether this screencast is still up to date, or whether I'm just doing something wrong? http://blip.tv/file/1045010/
09:18vdrabI defined the ~/bin/clj script to load the clojure repl, and it seems to work fine. I just can't seem to associate the inferior-lisp-program with it...
09:19vdrabin Aquamacs, that is
09:21wlrrhickey: a non-trivial number of newbies seem to start with releases. you might consider 1 more release before 1.0 to shake out functionality and official docs. just a thought.
09:22rhickeywlr: I might, yes, a release candidate release
09:22wlryep
09:22duck1123will java follow symlinks when looking for jars?
09:25duck1123I found my problem wrt .start and Thread
09:25Chouser_awayduck1123: yes, symlinks are ok
09:25duck1123I was using the latest version of swank, but a older version of clojure
09:26duck1123Chouser: for some reason it didn't work. I just replaced it with the actual file
09:27Chouserrhickey: I got clojurescript working from a self-contained pre-compiled .jar. (yay!) But I had to patch Compiler.java so I could bind LOADER
09:27Chouserduck1123: well, I tested a symlink just now and it worked, so... *shrug*
09:28rhickeyChouser: bind loader where?
09:28blarfi have a big O-analysis question, 2* O(n) vs O(n) + O(1), is there any practical difference? is it worth optimizing something like that ever?
09:29duck1123Chouser: did you link to a folder, or a jar?
09:29Chousukeblarf: depends
09:29ChouserIf I used Compiler/analyze, I would get an error because of LOADER being unbound (normally it's bound inside eval)
09:30Chousukeblarf: how big is the constant in the first O(n) and the latter O(n)? :P
09:30ChouserSo I exposed LOADER as clojure.core/*loader* and used (binding ...) around my call to Compiler/analyze
09:30Chouserthis also allows me to call analyze from other threads now, which is handy.
09:30rhickey2*O(n) == O(n), O(n) + O(1) == O(n), that's not to say one won't be faster than the other
09:33rhickeyChouser: I'm confused, when does analyze care about LOADER?
09:33philscottedOnce again, extremely impressive language here, and I'm currently using it for trying out a few ideas in my work (as opposed to getting frustrated with Ocaml). One question: similar to the arithmetic operators, I expected union and intersection to act like the identity on sets when given one argument. Is there a reason why this is a bad idea?
09:34rhickeyphilscotted: not a bad idea at all
09:37philscottedGreat. In that case, we could also have union accepting zero arguments and returning the empty set.
09:39rhickeyphilscotted: yes, there's a lot of todo on the set stuff, esp re: uniform treatment and return of empty sets
09:43lisppaste8Chouser pasted "unbound LOADER exception" at http://paste.lisp.org/display/70755
09:46rhickeyChouser: is *compile-files* not set?
09:46Chouserno, I wouldn't think so, since this is at runtime.
09:48Chouserah, but if I bind that and *compile-path* myself, it seems to work.
09:48Chouserbut it also creates a bunch of .class files
09:49blarfis it possible to ahve a macro X that does infix-macroing?
09:50Chousukeinfix?
09:50blarflike: (action X stuff) ->
09:50Chousukeno.
09:50Chouserblarf: you could write a macro X that could be called like (X 5 + (10 / 2))
09:50blarf(+ 3 2) <- prefix
09:50blarf(3 + 2) <- infix
09:50rhickeyChouser: the problem may be the getCompiledClass call on line 3139, would like to do without that
09:50blarfyes i dont want infix for that though
09:51blarfit is mostly a very lazy ,acro
09:51blarf a macro i need because im sooo lazy
09:51Chouserrhickey: yeah, I spent 5 minutes trying to figure out exactly what compiled class it was getting and why before giving up. :-)
09:51Chousukeblarf: lisp is always in prefix form
09:51blarf(defmacro def-to-self [pre post]
09:52Chousukeblarf: infix is either a reader macro that transforms into a prefix form, or some prefix macro that takes an infix form.
09:52blarf(def (first pre) (rest pre) post))
09:52Chouserrhickey: you probably know this already, but I was getting the same error pre-AOT when trying to run analyze from an agent
09:55ChouserChousuke: you're Jarkko on the google group?
09:55Chousukeyeah
09:56ChouserChousuke: nice treatment of syntax-quote
09:57Chousukeheh.
09:57ChousukeI wrote it to explain it to myself as well.
09:58ChouserChousuke: :-) I understand.
09:58rhickeyChouser: try 1117
10:00leafwis there any up-do-date guide on AOT compilation, how to set it up, how to expose methods for other java .jars to see them, etc?
10:01Chouserleafw: there's a chat log and a pasted example. If you haven't seen them, I can dig them up for you.
10:01mehrheitis each different keyword internally stored as
10:02leafwChouser: would appreciate a lot
10:02mehrheita single instance of Keyword?
10:03rhickeyuser=> (identical? (keyword "fred") (keyword "fred"))
10:03rhickeytrue
10:03rhickeyuser=> (identical? (symbol "fred") (symbol "fred"))
10:03rhickeyfalse
10:04Chouserleafw: AOT/gen-class syntax: http://paste.lisp.org/display/70665
10:04mehrheitrhickey: ok, thank you
10:06leafwthanks Chouser
10:06leafwwow, a namespace extends a class? That is bizarre
10:07rhickeya namespace is a class
10:07Chouserleafw: the "announcement" starts here: http://clojure-log.n01se.net/date/2008-11-18.html#14:19
10:07rhickeywhen compiled
10:07ChouserI'm having trouble getting a clean build of 1117
10:08Chouserkeep getting stack traces pointing to a commented-out line.
10:08cooldude127rhickey: that would be nice, i still don't get it after the 1110 change
10:08leafwrhickey: I'd say a class is a namespace, but the other wa around.
10:09rhickeyChouser: you've cleaned?
10:10Chouserant clean, rm -rf classes/*, rm clojure.jar, in several different orders several times. :-P
10:10leafw1116 compiles fine.
10:11Chouseroh, 1117 compiles, but my analyze call still throws an exception, and the exception names a comment line.
10:11Chouserclearly I'm being dumb, but *how* exactly is the question...
10:12leafwrhickey: just an extended version of that paste with explanations as comments would go a long way. For example, is -main a convention? Somehow it's not "exposed" anywhere
10:12rhickeyChouser: oh, I thought you meant 1117 didn't build
10:12leafwnad :init init is calling -init, with a minus sign?
10:13leafware minus signs not part of the name of a function when present in the first character of the name?
10:13Chouserah, here we go. getCompiledClass elsewhere...
10:14rhickeyleafw: (doc ns) (doc gen-class) does have the details
10:14lisppaste8Chouser annotated #70755 with "getCompiledClass during analyze, rev 1117" at http://paste.lisp.org/display/70755#1
10:16Chouserrhickey: I could give you a .jar that runs my test case, if you want.
10:18rhickeyChouser: no, I see from the trace you have a function that calls def with a fn
10:21rhickeyChouser: you should stick with your binding then
10:21Chouserok -- exposing LOADER as *loader* isn't too terrible?
10:23rhickeyChouser: how about *private-compiler-loader*
10:23Chousersure
10:23Chouseryou want a patch, or should I roll it into my general clojurescript patch?
10:25rhickeyChouser: I'll take a patch if it makes it easier for you
10:28ChouserI think it's necessary for me, even more so than core.clj/RT.java changes are. But I'm maintaining a branch of clojure to support clojurescript anyway, so I don't need to bother you with this particular one now.
10:29ChouserWhenever you choose to take all the pending cljs changes will be fine.
10:29MarkVolkmannI saw this syntax on the mailing list. (.setTitle frame# ~title) What do the # and ~ mean in this context?
10:30ChouserMarkVolkmann: they both only work inside a ` block.
10:30MarkVolkmannOkay. If there are inside a ` block, what do they mean?
10:31ChousukeMarkVolkmann: your paste was missing the ` character
10:31Chouserinside ` most words are unevaluated, passed stright through, so .setTitle comes out with just some namespace resolution: user\.setTitle
10:32Chousera trailing # means a gensym -- a new guaranteed-unique name: frame__49
10:32Chousera leading ~ means the following expression *will* be evaluated, so whatever title is bound to will be inserted there.
10:32ChousukeMarkVolkmann: did you see my writeup? it goes through a few examples.
10:33MarkVolkmannNo. What's the URL?
10:33Chousukethough I didn't explain ~ very well :/
10:33Chouseruser=> (let [title '(str "I'm a" "title")] `(.setTitle frame# ~title))
10:33Chouser(user/.setTitle frame__58 (str "I'm a" "title"))
10:34ChousukeMarkVolkmann: http://groups.google.com/group/clojure/browse_thread/thread/27912d9dcaec2f24 the fifth post (the long one :P)
10:34MarkVolkmannThanks!
10:40duck1123Chouser: I really like your show fn
10:41Chouserduck1123: thanks. the numbered-method thing seems kinda cheesy, but I haven't thought of a better way
10:41Chouseralso the sort order could use a bit more work.
11:13blarfis there a way to read symbols? i want do differ ?x from x.
11:15Chouser(pr ~foo) ==> java.lang.RuntimeException: java.lang.IllegalArgumentException: No method for dispatch value: class clojure.lang.LispReader$Unquote
11:15Chouserblarf: I don't know what you mean by ?x
11:15philscottedCan I just implement variadic union in the obvious way, or is it more subtle than this?
11:16Chouserphilscotted: might depend on what you think is obvious, but I don't think set.clj is particularly tricky -- just gets the job done.
11:17rhickeyphilscotted: there's a patch for this floating around on the group I think
11:17philscottedWell, I just map an empty argument list to #{}, a singleton arg-list to the single arg, keep the existing definition with two args, and for more I have written ([xset yset & more] (reduce union (union xset yset) more))
11:18Chousersounds pretty sensible.
11:19Chousukeblarf: you can convert to string and use java stream readers
11:25blarfChou: aj
11:25blarfah
11:27blarfhow do i def a var? (def a 10), a isnt a var.
11:28rhickeyblarf: a is a var, but saying a means get the value of the var a, to get the var itself, say (var a)
11:28tomhickeytrying to understand ::keywords, why does the later resolve to clojure ns and not user? user=> ::rect
11:28tomhickey:user/rect
11:28tomhickeyuser=> ::test
11:28tomhickey:clojure/test
11:29tomhickeyoops, sorry for multi-liner
11:30rhickeytomhickey: ::test looks broken, will look into that
11:32blarfi cant do var and get info
11:32blarfuser=> str
11:32blarfclojure.str__112@af914c
11:32blarf(doc str)
11:32blarfbut not (doc var)
11:33Chousukevar is a special form. it's documented on the web page.
11:34blarfaha
11:35rhickeyblarf: what version are you using?
11:35rhickeyuser=> (doc var)
11:35rhickey-------------------------
11:35rhickeyvar
11:35rhickeySpecial Form
11:35rhickey Please see http://clojure.org/special_forms#var
11:35Chouseris Unquote not expected to work with pr?
11:36rhickeyChouser: what do you mean?
11:36Chouser(pr ~foo) throws an exception
11:37rhickeyChouser: you can't unquote outside of syntax-quote
11:39blarf(ensure ref)
11:39blarfMust be called in a transaction
11:39blarfwhat does must mean there? do i have to follow a dosync-alter with ensure?
11:39blarfrhickey 20080916
11:40Chousukeblarf: use a newer version :)
11:41Chousukeblarf: it means that ensure can only be called in a transaction
11:41Chousukethe wording is a bit ambiguous I guess.
11:51Chouserheh, like core.clj line 3111
11:52Chouser'~'clojure.core outside of `
11:55rhickeyaargh
11:55rhickeyshould just be '
11:58blarfcan i do (del a) or soemthing? delte a variab�e
11:59Chouseryep, with that change I can compile core.clj to js again. :-)
11:59Chouserblarf: you want to remove 'a' from a particular namespace, or do something to the object stored in 'a'?
12:00rhickeyChouser: rev 1119 has the fix
12:01rhickeyalso fix for Wodin
12:04Chouserthanks!
12:13dfg59can anyone help me with a problem i'm having using JLine with the clojure repl on os x?
12:13danlarkinwe can try
12:16dfg59danlarkin: i'm using this script http://pastie.org/319767
12:16dfg59it works fine without the jline extras
12:16dfg59but errors with them
12:17dfg59this is the error: http://pastie.org/319769
12:23danlarkindfg59: tricky
12:32dfg59danlarkin: tricky?
12:32dfg59any ideas why it's erroring?
12:35danlarkinnope :-/
12:35danlarkinI use rlwrap myself though
12:36Chouserme too
12:36Chousernot to say it doesn't occasionally go wonkey itself...
12:37duck1123does anyone here know how to set paredit-mode when Slime begins?
12:37Chousukeslime probably has hooks.
12:38dfg59danlarkin: k, i'll check out rlwrap, hoping there's a port
12:39danlarkinfink has it, if you use that
12:39danlarkinports probably does too
12:54askentaskenanyone good with emacs-modes? im tryong to edit clojure.el to add more syntax-hightlighitn. there are a lot of key-words already defined so i can just add to aht list to make them purple. but lets say i want osme other colors as well, i dont see how to create that. for example id want yellow for the stuff in my user.clj-file. anyone know how to fix that?
13:02duck1123askentasken: I tried looking into that the other day, I don't think it's going to be that easy
13:25pissed-at-glocala
13:26pissed-at-glocalanyone using magit on windows?
13:35dfg59anyone out there using clojure with vim?
13:35Chouserme
13:35dfg59Chouser: is syntax highlighting working for you?
13:36dfg59everything works for me except syntax highlighting. completion/paren matching, etc
13:36ChouserI had to grab a syntax file, but yes.
13:36dfg59i have the syntax file as well
13:36dfg59and the filetype is being recognized
13:37dfg59i'm using the extension .clj on my files, is this correct?
13:37Chouserthat's what I use
13:38dfg59hrm, k
13:38rzezeskiasking the obvious, do you have "syntax on" in your .vimrc
13:38Chouserbut even without that, I can just type :setfiletype clojure and it lights up
13:39dfg59Chouser, let me try that
13:39dfg59rzezeski, yep
13:39dfg59parans are highlighted for me, but not keywords
13:39dfg59or anything else, for that matter
13:40rzezeskireaching in the dark...did you try setting another colortheme
13:41dfg59rzezeki, let me try
13:41dfg59nothing there. all i get highlighting for is () and []
13:41sjbachdfg59, what version of vim? Have you tried sourcing the syntax file explicitly and reloading a .clj?
13:41rzezeskicolorscheme I should say ":colorscheme ..."
13:42dfg59sjbach: 7.2
13:42dfg59sjbach: i'll try sourcing it explicitly
13:42dfg59still nothing
13:43rzezeskias a sanity check, does pretty printing work for other types of files like .java or .c?
13:43dfg59everything looks good in my ruby files
13:47dfg59i'm going to try a fresh install
13:47sjbachdfg59, you may want to try paring down your .vim and .vimrc to something minimal to see if that helps
13:47dfg59i've removed everything
13:47rhickeytomhickey: ::test fixed
13:48Chouserdfg59: if you do :syntax do you see a bunch of clojure things, like a big clojureFunc section?
13:50nsinghalHow can we get the current classpaths in clojure?
13:50Chousuke(System/getProperty "java.class.path")
13:51dfg59Chouser: one sec, reinstalling plugin
13:51dfg59Chouser: what's the best way to install the vim plugin, to overly my existing dir structure
13:51nsinghalThank you Chousuke
13:52tomhickeyrhickey: thanks!
13:53rzezeskidfg59, you should be able to just do a "cp -r"
13:53dfg59rzezeski
13:53dfg59rzezeski including bin?
13:54rzezeskidfg59, something like this: "cp -r ~/Downloads/vimclojure-1.2.1/ftplugin ~/.vimrc"
13:54rzezeskiwhoops
13:54rzezeski~/.vim
13:55dfg59right, that's what i did, but not just ftplugin, everything else as well
13:55dfg59including syntax
13:55dfg59etc
13:56dfg59Chouse: btw, i see a bunch of things when i type :syntax
13:56rzezeskiwhoops, ok I meant "cp -r ~/vim-clojure/* ~/.vim"
13:57dfg59rzezeski: yep, that's what I did...but do I need the bin directory there? i'm assuming that's just a script to recreate the completions file
13:57rzezeskiyea I don't think you need it there, I have it there and it's not hurting anything
13:58dfg59so i guess my question is, should i see defn as syntax highlighted?
13:58dfg59if so, i'm still not seeing it, which is strange
13:59rzezeskidefn is not highlighted for me either
13:59dfg59ah... :) maybe i do have it working then
13:59dfg59what is an example of something i should see highlighted
14:00abrooksdefn :keyword
14:01dfg59abrooks: ok, defn is not highlighted but :keyword is. hope this is what is expected.
14:01Chouserhttp://chouser.n01se.net/misc/vimclojure.png
14:02dfg59Chouser: yeah, i'm not seeing that
14:02dfg59rm
14:02dfg59hrm
14:02rzezeskidfg59, you and I both
14:03Chouserheh, great, I'm making it worse.
14:03dfg59heh, no, this is good to know that other's aren't seeing
14:03dfg59Chouser: what's your OS?
14:03Chouserubuntu
14:04dfg59rzezeski: are you on osx?
14:04rzezeskiyep
14:04rzezeskiI think I'm missing something from my .vimrc, that's my guess
14:04dfg59ah, as am i
14:05dfg59i mean, should need anything other than filetype on and syntax on
14:05dfg59both of which i ahve
14:05dfg59*have
14:09dfg59Chouser: did you use the plugin from http://kotka.de/projects/clojure/vimclojure.html
14:09abrooksdfg59: That's the plugin that I use. It works fine.
14:10rzezeskiI think it has something to do with setting clj_highlight_builtins
14:11abrooksrzezeski's probably right. I have "let g:clj_highlight_builtins=1"
14:11abrooksdfg59: --^
14:12rzezeskiabrooks, yep that did it for me
14:12rzezeskiwhat is the difference between set and let in vim?
14:13rzezeskiI kept trying to set it
14:13rzezeskiOn the VimClojure site is says "You may set clj_highlight_builtins in ..."
14:13abrooksrzezeski: "let" sets internal variables. See "help let" vs. "help set"
14:16dfg59awesome
14:16rzezeskialso, taking a look at the docs, it seems you can set varying levels of parenthesis to different colors via "g:clj_paren_rainbow"...pretty cool
14:16dfg59sweet :)
14:16dfg59thanks guys
14:16rzezeskithe things you learn when you actually take the time to read
14:16dfg59ugh, no kidding
14:26danlarkinlooking at my code in jrat tells me nothing... as far as I can tell :-/
14:28danlarkinclojure.lang.Var.get() and clojure.lang.LispReader.read(..) take up 24% and 22% of the "method time %"
14:35dfg59interestingly enough, if i try to do the let command as an autocmd for the filetype, it doesnt work
14:36Chouseryou can just set it all the time, can't you?
14:36dfg59Chouser: sure, and it works, was just trying to make it a bit smarter
14:38rzezeskithe "g:" prefix stands for global, so I don't know if it even makes sense to do it per filetype
14:38dfg59rzezeski: good point. i have some similar settings for ruby, so i was giving it a shot.
14:56gnuvincerhickey: would you mind if I translated the Clojure rationale to French and posted it on my blog for the French-speaking developers interested in Clojure? I would of course mention that you are the original author and include a link to the original.
14:56rhickeygnuvince: sure
14:57gnuvincerhickey: thank you.
15:10askentask(contains? [1 '?x] '?x) -> false, why?
15:11Chousukeaskentask: (doc contains?)
15:11Chouseraskentask: contains? works on keys not vals
15:11Chouserthe keys of your vector are 0 and 1
15:30rhickeyJVM Summit talk: http://www.infoq.com/presentations/hickey-clojure;jsessionid=2826B81451C4EBFB6F676A26DC937E34
15:30hiredmanooo
15:35rhickeyClojure in 1/2 hour
15:38AWizzArdah nice, a new vid :-)
15:38rhickeyIt's kind of like the trailer for Clojure
15:40danleihow would i do http://rpdillon.googlepages.com/creatingexecutablejarswithclojure with the new syntax? i tried: ns org.etherplex.example.jarexample
15:40danlei (:gen-class
15:40danlei :main true))
15:40danlei
15:40danlei(defn- -main [& args]
15:40danlei (println "hello"))
15:40danlei
15:40Chouserdanlei: no need for :gen-class or :main if all you want is a main fn.
15:40danleihm
15:40Chouserjust (defn -main ...) is sufficient.
15:41danleiaah
15:41danleithank you
15:41Chouseryou're welcome.
15:42AWizzArdi must think about using this vid for a presentation in my company
15:42kib2Hi! Nothing to do with Clojure, but that may interest some of you. You can get a new css book for free here (only during 12 days) : http://twitaway.aws.sitepoint.com/
15:43rzezeskiOh I just heard the mock object joke, good one
15:46dfg59rzezeski: what mock object joke?
15:48rzezeskiin the video rhickey just linked
15:48dfg59ah
15:48rzezeskithey are "mocking you"
15:49dfg59heh
16:35djpowellcan anyone explain :gen-class - i haven't seen any docs for it yet
16:37ChouserAOT/gen-class syntax example: http://paste.lisp.org/display/70665
16:37Chouserthe "announcement" starts here: http://clojure-log.n01se.net/date/2008-11-18.html#14:19
16:40danleii'm having trouble in getting an "executeable" jar-file. if i do (ns org.etherplex.example.JarExample)
16:40danlei(defn -main [& args]
16:40danlei (println "hello"))
16:40danlei
16:40danlei
16:41danleithen gen-class will produce classes/JarExample.class and classes/JarExample$_main__2623.class
16:42danleibut if i try to run the jar, it gives me a class not found exception: org.etherplex.example.JarExample__init
16:44danleimaybe i'll just have to learn java :)
16:46danlei... or revert to r1109, with gen-and-save-class, i had no problems
16:47Chouseryou don't run anything called 'gen-class' do you?
16:47danleii do
16:47Chouseroh, don't do that.
16:48danleiwhat should i use instead?
16:48Chousertry (compile 'org.etherplex.example.JarExample)
16:49danleiChouser: thanks. now it doesn't find the class
16:49Chouserwhat doesn't find what class?
16:49danleijava.lang.RuntimeException: java.lang.ClassNotFoundException: org.etherplex.example.JarExample$_main__2620 (NO_SOURCE_FILE:0)
16:49danlei
16:50danleiif i do (compile 'org. ...
16:50Chousermake sure you have "./classes" in your classpath
16:51Chouseror whatever you have *compile-path* set to
16:52danleichouser ah, thanks
16:54askentaskis ~ ina macro the same as , in cl?
16:54danleiChouser: ah, it finally works. all that java stuff still confuses me to death. thank you very much.
16:55Chouseraskentask: yes it's about the same (maybe exactly). And it only has to be in a ` not necessarily a macro.
16:55Chouserdanlei: great! I just worked through this myself last night.
16:56danleiChouser: :)
17:11cooldude127hey guys!
17:17lisppaste8asken pasted "while-macro" at http://paste.lisp.org/display/70789
17:18askentaskhttp://paste.lisp.org/display/70789
17:18askentaskcan someone point me to what missing in my while-macro? im trying to learn macros and have successfully created soem simple ones but is hard to learn themmincrementally.
17:19Chousertry macroexpand on that, and look carefully at the results
17:23MarkVolkmannWhat is the purpose of the ~ character in Clojure? Maybe if I can find out what its function is called then I can google some documentation on it.
17:23danleiit unquotes inside a quasiquotation, like ',' in cl
17:24AWizzArdMarkVolkmann: read this chapter: http://www.gigamonkeys.com/book/practical-building-a-unit-test-framework.html
17:24AWizzArdno, this one I mean: http://www.gigamonkeys.com/book/macros-defining-your-own.html
17:25AWizzArdabout in the middle of that page you find "Generating the Expansion"
17:25Chouser`(foo map (+ 1 2) ~(+ 1 2))
17:25AWizzArdin Common Lisp they usey a comma instead of ~
17:25Chouserlook at how the two different + expressions are handled
17:25cooldude127hey has anybody been implementing On Lisp in clojure? specifically the choose macro and all the non-determinism stuff?
17:25Chousercooldude127: I believe someone started, not sure how far they got.
17:26cooldude127man, if i have the time i might try it. see if i can. i love that macro
17:27Chousercooldude127: starts here: http://blog.fogus.me/2008/09/26/on-lisp-clojure-chapter-2/
17:28cooldude127cool, i'll look. he probably didn't, it's late in the book
17:28Chouserlooks like he's up through chapter 5
17:28cooldude127yeah the stuff i want is in the late teens or early twenties
17:29cooldude127i think
17:29Chouseryou could start at the end of the book and work backwards until it gets boring or you meet up with Fogus, whichever comes first.
17:29cooldude127that might be a good choice if some of them didn't use stuff from before
17:29Chouserah, good point
17:29cooldude127i'm almost positive that a good portion actually use macros from earlier chapters
17:29cooldude127cool progression actually
17:30cooldude127but annoying for this purpose lol
17:30cooldude127i'll have to do the less fun way (the CL way as opposed to the scheme way) due to clojure not having continuations
17:31askentaskChouser: ok so i got it to print results endlessly when true and once when false if given (while (z 5 10)
17:32askentask(while (> x 0) (dec x) (pr x))) or (while (< x 0) (dec x) (pr x)))
17:33Chouserbut (dec x) doesn't modify x, it just returns a new value
17:33Chouserthis 'while' macro is inherently imperative
17:33askentaskweeee!
17:33Chouser:-)
17:33cooldude127while is a tough sell in clojure
17:34askentaskyes i used (def x (dec x)) and it worked
17:34cooldude127EWWWW
17:34Chouserew
17:34cooldude127lol
17:34cooldude127it feels so dirty
17:34askentaskis it possible to do without using def or or refs?
17:34Chouseraskentask: but you got your macro working, so congrats on that.
17:35danleiwon't work with a non-special var (one bound in let)
17:35cooldude127askentask: this is what we usually do with recursion i believe
17:35cooldude127loop and recur
17:35cooldude127just don't use mutation
17:36Chouseryou might be able to do something a bit like C's for loop without being quite so dirty
17:36ChouserI still doubt its usefulness, but you could try it.
17:36MarkVolkmannLet me make sure I've got this right. ~ is used inside quoted lists to force evaluation of a sublist. Right?
17:36cooldude127but really it needs a change in mindset
17:36ChouserMarkVolkmann: back-quoted lists, yes.
17:36cooldude127MarkVolkmann: yeah i guess so
17:37cooldude127it substitutes the value of the expression in, instead of just putting it in literally
17:37Chouseraskentask: (c-for [i 0 (< i 10) (inc i)] (prn i))
17:37cooldude127yeah that could be done rather functionally i think
17:37askentaskcooldude127: i know about loop-recur and i dont need while really. im just asking is it possibkle to use my macro without the ugly (def x (dec x)) ?
17:38MarkVolkmannI don't comprehend the difference between substituting the value and putting it in literally.
17:38cooldude127MarkVolkmann: let's try some examples
17:38cooldude127hold on
17:38danleiMarkVolkmann: `((+ 1 2) ~(+ 1 2))
17:38cooldude127yeah that
17:38cooldude127danlei: i wanted the glory!
17:38cooldude127lol
17:39danleicooldude127: sorry
17:39Chouseraskentask: no, by having your macro recur with no changed locals means the only way to break out of the loop is to test for some side-effect.
17:39cooldude127user> `((+ 1 2) ~(+ 1 2))
17:39cooldude127((clojure.core/+ 1 2) 3)
17:39MarkVolkmannRight. I see that it makes a list containing the unevaluated (+ 1 2) and the evaluated (+ 1 2) or 3.
17:39cooldude127(literal substituted)
17:39danleiMarkVolkmann: exactly
17:40MarkVolkmannBut what's the distinction between "substitute" and "putting in literally"
17:40cooldude127MarkVolkmann: my terminology might not be too clear
17:40Chouseraskentask: which implies that the body of the while loop have some kind of side-effect, which in clojure means: set or re-def a Var, update a Ref, send to an Agent, or change some mutable state in a Java object.
17:40cooldude127by literally i mean it's put in as you see it
17:40MarkVolkmannOh, okay. Thanks!
17:40cooldude127no prob
17:40danleiMarkVolkmann: anything inside a backquote is just data, only things that are unquoted (~) are evaluated
17:41MarkVolkmannWhat's the difference between a backquoted list and quoted list?
17:41danleiMarkVolkmann: you can't unquote inside a quoted list
17:41MarkVolkmannAh!
17:41cooldude127that's not the only difference
17:41cooldude127user> '(+ 1 2)
17:41cooldude127(+ 1 2)
17:41cooldude127user> `(+ 1 2)
17:41cooldude127(clojure.core/+ 1 2)
17:41cooldude127user>
17:41cooldude127sorry about that
17:41cooldude127prolly should have pasted it
17:42Chousersymbols in backquoted lists are "resolved" based on namespace, in regular-quote they're left unqualified
17:42cooldude127back-quote resolves symbols to their namespaces
17:42Chousukethis is the key difference with CL backquote.
17:42cooldude127why does everyone beat me to my explanations!?
17:42MarkVolkmannThanks!
17:43Chousukein CL, '(+ 1 2) *is* equal to `(+ 1 2) :)
17:43cooldude127yeah, i like the distinction in clojure
17:44Chouseryes, it makes clojure macros a bit safer, without removing the ability to capture names if needed.
17:44cooldude127yummy
17:44Chouserquite a bit safer, really.
17:44cooldude127it's similar to hygienic macros without the suck
17:44Chouserexactly.
17:45Chousuke:)
17:45cooldude127i'm surprised it wasn't done before
17:45cooldude127makes so much sense
17:47Chouseryet another little piece of Clojure synergy -- namespaces and backquote working together to make macros better.
17:49Chousukeanyone able to summarise how macros in scheme work btw? never had time to figure out, but they seem to have some weird facilities for it
17:54cooldude127yeah i never could grasp it
17:54cooldude127in fact i'm almost certain i never successfully wrote a macro in scheme
18:04powr-tocI'm pretty new to clojure and trying to understand lazy-cons... Are there any simple examples of it's use anywhere?
18:04cooldude127it's used in a lot of functions in clojure itself
18:04cooldude127example: map is lazy
18:07powr-tocI'm looking at it right now, but it's still perhaps a little much... are there any oneliners which illustrate its use?
18:08duck1123where's that project euler wiki again
18:08Chouseryeah, map is a bit much. look at 'take'
18:08hiredmanlisppaste8: url
18:08lisppaste8To use the lisppaste bot, visit http://paste.lisp.org/new/clojure and enter your paste.
18:08duck1123I'm sure that's full of uses
18:08Chouserpowr-toc: 'take-while'
18:09cooldude127(do (def x (lazy-cons 1 (lazy-cons (println "x") nil))) nil)
18:09Chouserpowr-toc: 'repeat' 'iterate' 'line-seq' I guess I'd recommend searching for lazy-cons in core.clj and trying the understand the ones that look sufficiently simple to you
18:10powr-toccheers guys :-)
18:10cooldude127powr-toc: run that in a repl and see how "x" is not printed
18:10cooldude127then type x and hit enter
18:10cooldude127and you'll see it printed
18:10lisppaste8hiredman pasted "lazy-cons example" at http://paste.lisp.org/display/70799
18:13askentask=> java.lang.IllegalStateException: No transaction running
18:15duck1123askentask: what did you do to get that?
18:17askentasksorry i had deleted drscheme so i dont have them. but u use (define-syntax ...
18:19lisppaste8asken pasted "ref-problem" at http://paste.lisp.org/display/70801
18:20hiredmanwell, uh
18:20hiredmanthe ref-set needs to be in a dosync
18:20hiredmanor some kind of transaction
18:21hiredmansee (doc ref-set)
18:21Chousukethat's a very ugly way to do a loop though. :P
18:21askentask:)
18:22hiredmannasty in deed
18:22askentaskwhy is the dosync alter not working?
18:22Chousukeaskentask: ref-set needs to be in a dosync
18:23askentaskwell, (map pr coll) is too easy ;)
18:23askentaskyes
18:23Chousukeyeah, it wouldn't work :)
18:23askentaskbut alter?
18:23Chousukeyou need (dorun (map pr coll))
18:23askentask(map pr [1 2 3])
18:23askentask(1nil 2nil 3nil)
18:23Chousukeit works in the repl because the repl prints the result
18:23hiredmanheh
18:24hiredmanoh the hilarity of (1nil 2nil 3nil)
18:24cooldude127lol
18:24Chousukemap is lazy, if you want side-effects to work, you *have* to use 'dorun
18:24Chousukeotherwise, you will eventually hit a bug.
18:25askentaskhow do i compile to a standalone program?
18:25danleiaskentask: which revision?
18:26danleiaskentask: http://rpdillon.googlepages.com/creatingexecutablejarswithclojure helped me very much, but it'll just work <= r1109
18:26powr-toccan I get function docs in the repl?
18:26Chousuke(doc fn)
18:26danleipowr-toc: (doc fun)
18:26powr-tocsweet/
18:27Chousukeaskentask: (compile 'your.namespace)
18:27Chousukeaskentask: will create a bunch of classes
18:28Chousukeaskentask: if you have a -main method defined, then you should be abble to add those classes to your classpath and run java your.namespace ... IIRC
18:28Chousukeyou'll need a very recent revision for that though.
18:30powr-tocis seq implemented in java or clojure?
18:31cooldude127Chousuke: 1110 or higher to be exact
18:31danleipowr-toc: the link i posted worked for me (r1119) too, if you use (ns something.MyClass), then your program with a (defn -main ... and compile it with the correct classpath and *compile-path*
18:31Chousukepowr-toc: java
18:31Chousuke seq (fn seq [coll] (. clojure.lang.RT (seq coll))))
18:32sohailhow would you implement Python's with statement in clojure?
18:32sohailspecifically I am referring to the extensibility of it
18:32Chousukehmmh
18:32cooldude127sohail that shit up
18:32Chousukeextensibility?
18:32cooldude127*macro that shit up
18:32sohailcooldude127, huh?
18:32cooldude127sorry i get ahead of myself and skip words
18:33powr-tocChousuke: I take it seq is primarily just to raise java collections etc... into clojure sequences?
18:33Chousukesohail: see the implementation of with-open
18:33sohailChousuke, yeah but how would you make with general
18:33Chousukepowr-toc: or maps or vectors.
18:33Chousukesohail: what do you mean "general"?
18:33sohailfor example, you could do (with mutex ...) or (with network-connection ...)
18:33cooldude127sohail: probably a combination of multimethods and macros
18:33Chousukesohail: with-open already works with anything that's closeable.
18:33powr-tocChousuke: cool
18:33sohailChousuke, hm, I will look at it then
18:34Chousukesohail: including files, database connections and whatnot
18:34Chousukeprobably not locks, as those are not .close()'d
18:34Chousukewith-open is very simple :/
18:34sohailChousuke, I see so it has to be a java object
18:34sohailjava class I mean
18:34Chousukesohail: well, yes.
18:35sohailso how would you do it in pure clojure
18:35Chousukesohail: you could make a with macro based on a multimethod.
18:35cooldude127yay what i said
18:35Chousukethat calls a multimethod on its argument to close it.
18:35sohailonly thing I can think of is with an extra tag in your StructMaps
18:35danleisohail: what exacty do you mean? you can whip up your own with-macros for anything you can imagine
18:35Chousukewhy structmaps? :/
18:36sohailChouser, maybe just structs?
18:36cooldude127maybe just maps?
18:36sohaildanlei, mental exercise
18:36Chousukeyeah
18:36sohailok just maps
18:36ChousukestructMaps are just maps
18:36Chousukethe struct part in them is just an optimisation.
18:36sohailyeah but I was explicitly saying StructMaps for some reason which escapes me now
18:36Chousukemaybe you're thinking of them as classes or something.
18:36Chousukeor C structs.
18:36sohailmaybe
18:37sohailwell anyway, so you'd have to add ane xtra tag
18:37sohailso how do you prevent keys from colliding
18:37sohailcan you have qualified keys?
18:37cooldude127yeah something that identifies what it is so that you can do different stuff with different closeable things
18:37sohaillike :mywith.close-tag
18:38cooldude127sohail: mywith-close-tag?
18:38cooldude127keywords don't have namespaces
18:38sohailI guess that's the way to do it
18:38sohailand then you'd do a multimethod which uses :mywith-close-tag as the discriminating (I made that up) function?
18:39cooldude127yeah, and you would call it a dispatch function
18:39cooldude127:)
18:39sohailyeah dispatch function!
18:39sohailsorry, I've been out of clojure for like 2 weeks now but it is in the back of my mind churning away at all these types of things
18:40cooldude127lol
18:41sohailI guess I'll write a with macro in clojure today... if I can get post-AOT to run that is
18:41askentask(for [x (split \n (slurp file))] (println x))
18:43Chousuke(defmacro with [binding & body] `(let ~binding (with* ~(first binding) (fn [] ~@body))) (defn with* [bound-thing fn] (try (fn) (catch ...) (finally (whatever bound-thing)))) or something?
18:43Chousukedisclaimer: it's almost 2 AM here.
18:43sohailhey screw you man
18:43sohailI was gonna do it :P
18:43sohail(I'm kidding!)
18:43Chousukesohail: you can fix the bugs in that one.
18:44sohailthat's pretty much it
18:45powr-tocI've been following clojure online for a while... and it seems that die hard lispers hope it'll bring lisp to the masses... Whilst many java programmers like it too... Does anyone know what the Erlangers are saying about it?
18:45sohailthey prefer Python
18:45Chousukesohail: figure out how to make that work with multimethods in a sane way
18:45Chousukeor a useful way :P
18:45sohail:-)
18:46powr-tocsohail: they do?
18:47danleii guess, if clojure doesn't bring lisp to the masses, nothing will do.
18:48powr-tocdanlei: That's the impression I'm getting... not that I've ever really been a lisper, before... I've read lots about it for years, but have never quite got round to using it... till clojure
18:49hiredman "the masses"
18:49cooldude127i've used the other lisps, CL, scheme, and arc, but clojure is the only one i think i could actually use in a real app
18:50danleicooldude127: well, have you tried something like allegro or lispworks?
18:50hiredmanclojure has screwed be over for other languages, because now I never remember to put in commas
18:50hiredmanme
18:50danlarkinhiredman: me too!
18:50cooldude127not much, gave a very brief look at lispworks
18:51cooldude127i'm one of those snobby os x users who hates everything that doesn't feel right on the mac
18:51danlei =)
18:51cooldude127and lispworks felt unwelcome
18:51askentaskcan i recur in macros?
18:51danleiso ... anything not written in cocoa =)
18:51sohaillispworks on Linux must be the ugliest application ever written
18:51danlei*using cocoa
18:51cooldude127danlei: almost
18:51sohailaskentask, you should be able to I hope
18:51danleicooldude127: i know that feeling ;)
18:52cooldude127yeah i was never this picky on windows
18:52askentaskcooldude: same feeling, common lisp and scheme wre both nice but lacks the practicality of modern languages, i mean im so productiv ein python.
18:53cooldude127they lack libraries
18:53Chousukeaskentask: macros are secretly functions
18:53lisppaste8asken pasted "for-macro" at http://paste.lisp.org/display/70803
18:53cooldude127askentask: clojure is productive partly because you don't have to write everything yourself because you can call into java
18:53askentask^^ trying to implement clojures for, not working
18:54askentaskexactly
18:54danleicommon lisp is a nice language, if you can afford a proper, modern implementation. but then, you're bound to them. portable gui apps, for example. i wrote my first (little) one in clojure right the first day. things like that are hard in cl.
18:54askentasklibs+awesome language
18:54hiredmanuh
18:55hiredmanaskentask: anything preceded by a ~ should have a ` somewhere before it
18:56hiredmanaskentask: that macro is very broken
18:56askentask:)
18:56hiredman~ is unquote
18:57powr-tocI can see clojure being a relatively easy sell at work... Yet I'd never be able to sell lisp.
18:57hiredmanpowr-toc: sell a java library that is so powerful it has implemented its own lisp
18:58cooldude127clojure can integrate into existing java infrastructure = easy sell
18:58powr-tocthe JVM, and Java eco-system make it possible
18:58powr-toccooldude127: exactly
18:59hiredmanaskentask: I am still trying to figure how exactly you think this macro should work :P
18:59powr-tocplus, when talking libraries - I guess it'd be relatively easy to keep quite about implementing in clojure, and ship java class-files, with a thin java interface wrapper around what we do... our customers need never know it was anything else...
19:00cooldude127yeah, that's what's cool
19:00cooldude127do clojure under the table
19:00cooldude127no one has to know
19:00cooldude127it'll be our little secret
19:00cooldude127;)
19:00askentaskhiredman: take one elem at a time, do body, when there is no more elems, quit
19:01askentask(for-x [1 2 3] (pr 10)) -> 10 10 10 nil
19:01hiredmanjust use map
19:01askentaskyes
19:01hiredman(map (fn [_] (pr 10)) [1 2 4])
19:02askentaskbut the point is to learn macros
19:02cooldude127also the built-in for can do that almost
19:02cooldude127learn useful macros
19:02hiredmanaskentask: make a macro that uses map
19:02cooldude127find a necessary abstraction
19:02cooldude127look for repetition in your code and macro it away
19:03askentaskwhere is "for" in the clojure-source-code? in boot.clj?
19:03cooldude127probably
19:03hiredmanthe clojure for is not what you just described, I believe
19:04cooldude127not exactly, but it can do that kind-of
19:05Chouserno, map is lazy -- no good for side-effects.
19:05hiredmanoh
19:05hiredmanyeah
19:05hiredmandamn it
19:05cooldude127so it for
19:05cooldude127*so is for
19:05cooldude127both need a (doall ...)
19:05cooldude127around them
19:06hiredmanthey don't if you aren't trying to translate a C for loop into clojure :P
19:06Chouser(defmacro for-x [seq & body] `(dotimes [x# (count ~seq)] ~@body)) ; untested
19:06cooldude127that looks pretty nice
19:07Chouserseems odd to take a seq and only use it's length, but whatever...
19:12ChousukeI think map is just fine for side-effects
19:12Chousukeyou just need to remember the 'dorun (or 'doall)
19:14powr-tocIs there a way to format output in a printf style (%s etc...) in clojure?
19:15danleiformat
19:15blackdogprintf
19:16Chousukepowr-toc: the format function uses java.util.Formatter format strings.
19:16askentaskhow would i make a while that doesnt need refs or def?
19:17askentaskmacros are so hyped up but i never neeed them, a normal function pretty much always does it...
19:17powr-toccool
19:17Chousukeaskentask: consider yourself lucky then :)
19:18Chousukedoes a while loop make sense in clojure? :/
19:18danleihm
19:18Chousukemaybe *if* you're using refs
19:18danleihas someone tried to implement cl's format for clojure?
19:19hiredmanI think in clojure alot of loops naturaly unroll into seqs
19:19Chousukeaskentask: a while would only make sense if it were called like (while (< 1 @x) dostuff)
19:20Chousukeaskentask: so you can write your while assuming that the test contains a var
19:20Chousukeer, ref*
19:21Chousukeit's not too difficult. you need loop, if and recur.
20:14askentaskfuck a guy killed himself liv eon justin.tv
20:14askentaskpretty horrible
20:14askentaskread it on hacker news