#clojure log - Nov 20 2008

The Joy of Clojure
Main Clojure site
Google Group
List of all logged dates

0:01 Chouser: well, 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)

0:02 when 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

0:02 But I think that must be a separate bug

0:04 bah! yes, it's in fact a bug in my own source code.

0:05 hm... or maybe not. I mean, i had a bug, but it doesn't seem to be causing that exception.

0:09 ok, ClojureScript must not be calling Compiler/analyze correctly when running from -main

0:09 Must be some var I'm supposed to bind.

0:17 mmcgrana: well i gtg, good luck on figuring that out, sorry i couldn't really help

0:18 Chouser: np, thanks for poking at it with me

0:18 mmcgrana: yep

0:20 yangsx: hi, can I tell slime to use the latest version after clojure.jar is updated?

0: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

0:27 Chouser: _Jordan_: I don't know of any.

0:28 _Jordan_: Thanks

0:29 Chouser: (count (take-while (complement #{'x}) '[z y x w]))

0:29 but that doesn't give you nil on failure

0:30 I guess I don't use indexes into seqs much. You're sure you need it?

0:35 _Jordan_: no, I probably don't. Hold on, let me figure out what your snippet does :)

0:36 hiredman: any progress on that pretty printer?

0:37 Chouser: nope, gave it up since steven_h appears to be working on it

1:09 larrytheliquid: when 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

1:09 does that mean you cannot "use" functions from dynamically created namespaces?

1:16 nm, refer does the trick

2:29 thearthur: what is the proper way to nest a fn inside another?

2:29 (def bla4 (let [baz (fn [x y] (when (pos? y) (lazy-cons x (baz x (dec y)))))]))

2:30 this gets me a null pointer exception in compilation (sometimes)

2:31 hoeck: thearthur: (fn bar [x y] ...)

2:31 you can name the anonymous function, so that it references to itself

2:32 (let [foo (fn this [] this)] (= foo (foo))) -> true

2:33 thearthur: are you saying the function has 2 names, one for recuring and another by which it is referenced?

2:35 hoeck: well, it has the name to where you bound it in the (let [ ..]) and the name you give it internally

2:36 the function itself doesn't see the let-bound one

2:38 thearthur: is this a reserved word?

2:38 hoeck: no

2:39 but "this" is used in the proxy-macro

2:40 thearthur: i c

2:40 thanks so very much

2:40 hoeck: np

3:43 _deepfire: slyrus_, did anybody mention shadowing-import-from?

5:14 blarf: i want a function : (defn prolog []

5:14 (ref state {:rules {} :facts {}})

5:14 but it returns the ref when i eval it

5:15 i want it do that obv when i call (prolog) only

5:15 i could ofc make a pure fucntiont hat doesnt use refs at all

5:15 but i ind of want to

5:24 hoeck: blarf: there is a paren missing ath the end of (ref .. )

5:27 blarf: lol thanks

5:32 hoeck: thanks going to xemacs expression-highlighting :)

5:33 blarf: ah, i use normal emacs

5:35 hoeck: actually the same as emacs, just with an "x" on the front

5:58 blarf: hmm, 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?

5:59 hmm, if soemone even understand what im saying there :)

6:00 tWip: do you mean should it be possible to "add" methods/properties to classes after definition?

6:01 blarf: so each update to an instance of a clas returns a new instance rather than using refs and manipluating them

6:01 Chousuke: blarf: return new instances

6:03 blarf: twip: well that is possible by default i guess, its dynamic.

6:03 Chou: ok ill experiment with both and seee

6:04 Chousuke: but 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.

6:05 tWip: indeed, I think clojure already has what is needed for OO

6:05 Chousuke: actually you don't even need a system for tagging types, but I'm assuming you want some kind of rigid hierarchical OO model?

6:06 tWip: clojure can do OO better than java if you ask me.

6:06 tWip: for some value of OO

6:07 Chousuke: Well, you always have access to the java system

6:07 tWip: there are so many aspects to it and different groups use different definitions

6:07 Chousuke: and then multimethods on top of that.

6:07 gen-class is evil though.

6:07 tWip: never used it

6:07 Chousuke: Me neither. I tried, but it's evil :(

6:09 hoeck: Chousuke: you mean gen-class for making classes that are only accessed by clojure code?

6:10 Chousuke: no. that wouldn't make sense :/

6:10 gen-class is java interop.

6:13 blarf: i have a half-functioning kind of not so beautiful OO-system already but my main problem was how to define emthods and eval them.

6:13 Chousuke: use the multimethod system? :/

6:15 tWip: blarf: are you using maps for instances?

6:15 blarf: i 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)

6:15 Chousuke: struct-maps and multimethods give you all that

6:16 tWip: how would one implement encapsulation/information hiding when using maps?

6:17 I'm not saying that is necessary, just that it is a feature commonly in OO systems

6:17 Chousuke: tWip: you wouldn't, really.

6:17 just like in python they don't.

6:18 it's just declared as off-limits and you're supposed to obey that. :P

6:18 blarf: tWip: in Python you dont really have that, i ifnd it neat

6:18 tWip: I suppose it's more important in the state gathering mess of Java-style OO :P

6:19 Chousuke: languages that implement data encapsulation and hiding can only prevent accidents.

6:19 they can't prevent actual access.

6:19 as long as the data is there, there exists a way to get to it :P

6:25 hoeck: twip: regarding encapsulation, you could do this with closures, by closing over a hashmap and allowing only access to specific keys for example

6:26 tWip: you'd have to ref that, because you couldn't modify the closed over map

6:27 but yes, that's a possible way to do it

6:28 Chousuke: hmm, right.

6:29 define a function lets a bunch of refs and returns a bunch of accessor functions :P

6:29 instant instances

6:30 perhaps not optimal though.

6:30 also, +that

6:31 would be rather ugly and nonidiomatic though. :/

6:35 blarf: what is JAVA under the hood? a symbol-table-hack? written in C++?

7:15 blackdog: (find-doc) returns documentation on private functions

7:18 I'm using slurp at the moment to load a file but how do i load a file relative to classpath

7:18 not code any old file

7:21 getResourceasStream then?

7:22 maybe it would be good to have a function in core like loadResourceScript but for anything?

7:33 Chousuke: phew. wrote a bunch of stuff about macros to the groups.

7:33 Explaining things to others really helps me in understanding them myself :)

7:35 hm, maybe I should put that in the wiki :/

8:04 hoeck: what's the preferred way of implementing a java interface now, plain old proxy or :gen-class?

8:05 rhickey: hoeck: :gen-class is about creating a named class for the Java world

8:06 so, for handlers etc stick with proxy

8:09 hoeck: aha, btw, am i allowed to use the proxy facilities directly?

8:09 i expanded the proxy macro once and built a function which takes a map of fn-name fn pairs and creates the proxy

8:10 creates the proxy directly, i mean

8:10 rhickey: hoeck: 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

8:11 it might end up the same or very similar

8:12 2 objectives are to precompile the proxy classes themselves, and get rid of reflective construction

8:16 hoeck: I'm just playing around with the iris reasoner, and don't want to rewrite all the interface-gluecode once proxy-AOT works

8:16 so I rather ask :)

8:17 rhickey: hoeck: can you post your function, so I can see how you are using the underlying proxy API? It might help inform my decisions

8:17 paste

8:19 hoeck: rhickey: http://paste.lisp.org/display/70751

8:20 rhickey: hoeck: thanks

8:22 hoeck: i once discovered that there is just a hashmap and found that more convenient/functional/clojure-like than the proxy macro whith the aliased "this"

8:23 and it makes it possible to pass something like identity function to proxy

8:23 rhickey: hoeck: 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

8:24 the fundamental hash-map approach will stay the same

8:26 hoeck: rhickey: fine, thanks

8:39 blackdog: is there a clojure way of loading any resource from the classpath?

8:45 duck1123: any clojure resource?

8:45 (doc load)

8:45 blackdog: any resource, not just a script

8:45 blarf: is this now allowed: (for [[x y] (zip a b)]

8:46 duck1123: (doc slurp)

8:46 blackdog: that's from the file system

8:46 not from the classpath

8:46 i can get baseLoader() from RT so i guess i can do it using that

8:46 duck1123: hmm...

8:49 I'm getting a strange error today: No matching method found: .start for class java.lang.Thread

8:50 rhickey: duck1123: paset?

8:50 paste?

8:50 duck1123: I wish I knew where it was being called from

8:50 that's just when I start up clojure/compojure

8:50 I'm thinking it might be from the compojure side

9:00 rhickey: I've updated http://clojure.org/java_interop to emphasize the member access sugar, is it clear?

9:01 blackdog: should the doto example have .puts?

9:01 rhickey: blackdog: just fixed :)

9:01 blackdog: k

9:02 duck1123: rhickey: would it make sense to put (Classname-symbol. args*) above the (new Classname-symbol args*) line to make that one clear?

9:06 rhickey: duck1123: done

9:07 duck1123: thanks

9:08 rhickey: I 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?

9:08 duck1123: I think it looks pretty clear

9:14 rhickey: you might want to think about changing the "Dynamic Compilation" section of the dynamic page now that we have AOT

9:15 rhickey: yeah, there's a lot to do in the docs, not going there now

9:17 vdrab: Hi #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/

9:18 I 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...

9:19 in Aquamacs, that is

9:21 wlr: rhickey: 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.

9:22 rhickey: wlr: I might, yes, a release candidate release

9:22 wlr: yep

9:22 duck1123: will java follow symlinks when looking for jars?

9:25 I found my problem wrt .start and Thread

9:25 Chouser_away: duck1123: yes, symlinks are ok

9:25 duck1123: I was using the latest version of swank, but a older version of clojure

9:26 Chouser: for some reason it didn't work. I just replaced it with the actual file

9:27 Chouser: rhickey: I got clojurescript working from a self-contained pre-compiled .jar. (yay!) But I had to patch Compiler.java so I could bind LOADER

9:27 duck1123: well, I tested a symlink just now and it worked, so... *shrug*

9:28 rhickey: Chouser: bind loader where?

9:28 blarf: i 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?

9:29 duck1123: Chouser: did you link to a folder, or a jar?

9:29 Chousuke: blarf: depends

9:29 Chouser: If I used Compiler/analyze, I would get an error because of LOADER being unbound (normally it's bound inside eval)

9:30 Chousuke: blarf: how big is the constant in the first O(n) and the latter O(n)? :P

9:30 Chouser: So I exposed LOADER as clojure.core/*loader* and used (binding ...) around my call to Compiler/analyze

9:30 this also allows me to call analyze from other threads now, which is handy.

9:30 rhickey: 2*O(n) == O(n), O(n) + O(1) == O(n), that's not to say one won't be faster than the other

9:33 Chouser: I'm confused, when does analyze care about LOADER?

9:33 philscotted: Once 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?

9:34 rhickey: philscotted: not a bad idea at all

9:37 philscotted: Great. In that case, we could also have union accepting zero arguments and returning the empty set.

9:39 rhickey: philscotted: yes, there's a lot of todo on the set stuff, esp re: uniform treatment and return of empty sets

9:43 lisppaste8: Chouser pasted "unbound LOADER exception" at http://paste.lisp.org/display/70755

9:46 rhickey: Chouser: is *compile-files* not set?

9:46 Chouser: no, I wouldn't think so, since this is at runtime.

9:48 ah, but if I bind that and *compile-path* myself, it seems to work.

9:48 but it also creates a bunch of .class files

9:49 blarf: is it possible to ahve a macro X that does infix-macroing?

9:50 Chousuke: infix?

9:50 blarf: like: (action X stuff) ->

9:50 Chousuke: no.

9:50 Chouser: blarf: you could write a macro X that could be called like (X 5 + (10 / 2))

9:50 blarf: (+ 3 2) <- prefix

9:50 (3 + 2) <- infix

9:50 rhickey: Chouser: the problem may be the getCompiledClass call on line 3139, would like to do without that

9:50 blarf: yes i dont want infix for that though

9:51 it is mostly a very lazy ,acro

9:51 a macro i need because im sooo lazy

9:51 Chouser: rhickey: yeah, I spent 5 minutes trying to figure out exactly what compiled class it was getting and why before giving up. :-)

9:51 Chousuke: blarf: lisp is always in prefix form

9:51 blarf: (defmacro def-to-self [pre post]

9:52 Chousuke: blarf: infix is either a reader macro that transforms into a prefix form, or some prefix macro that takes an infix form.

9:52 blarf: (def (first pre) (rest pre) post))

9:52 Chouser: rhickey: you probably know this already, but I was getting the same error pre-AOT when trying to run analyze from an agent

9:55 Chousuke: you're Jarkko on the google group?

9:55 Chousuke: yeah

9:56 Chouser: Chousuke: nice treatment of syntax-quote

9:57 Chousuke: heh.

9:57 I wrote it to explain it to myself as well.

9:58 Chouser: Chousuke: :-) I understand.

9:58 rhickey: Chouser: try 1117

10:00 leafw: is 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:01 Chouser: leafw: there's a chat log and a pasted example. If you haven't seen them, I can dig them up for you.

10:01 mehrheit: is each different keyword internally stored as

10:02 leafw: Chouser: would appreciate a lot

10:02 mehrheit: a single instance of Keyword?

10:03 rhickey: user=> (identical? (keyword "fred") (keyword "fred"))

10:03 true

10:03 user=> (identical? (symbol "fred") (symbol "fred"))

10:03 false

10:04 Chouser: leafw: AOT/gen-class syntax: http://paste.lisp.org/display/70665

10:04 mehrheit: rhickey: ok, thank you

10:06 leafw: thanks Chouser

10:06 wow, a namespace extends a class? That is bizarre

10:07 rhickey: a namespace is a class

10:07 Chouser: leafw: the "announcement" starts here: http://clojure-log.n01se.net/date/2008-11-18.html#14:19

10:07 rhickey: when compiled

10:07 * rhickey needs to write up gen-class/AOT

10:07 Chouser: I'm having trouble getting a clean build of 1117

10:08 keep getting stack traces pointing to a commented-out line.

10:08 cooldude127: rhickey: that would be nice, i still don't get it after the 1110 change

10:08 leafw: rhickey: I'd say a class is a namespace, but the other wa around.

10:09 rhickey: Chouser: you've cleaned?

10:10 Chouser: ant clean, rm -rf classes/*, rm clojure.jar, in several different orders several times. :-P

10:10 leafw: 1116 compiles fine.

10:11 Chouser: oh, 1117 compiles, but my analyze call still throws an exception, and the exception names a comment line.

10:11 clearly I'm being dumb, but *how* exactly is the question...

10:12 leafw: rhickey: 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:12 rhickey: Chouser: oh, I thought you meant 1117 didn't build

10:12 leafw: nad :init init is calling -init, with a minus sign?

10:13 are minus signs not part of the name of a function when present in the first character of the name?

10:13 Chouser: ah, here we go. getCompiledClass elsewhere...

10:14 rhickey: leafw: (doc ns) (doc gen-class) does have the details

10:14 lisppaste8: Chouser annotated #70755 with "getCompiledClass during analyze, rev 1117" at http://paste.lisp.org/display/70755#1

10:16 Chouser: rhickey: I could give you a .jar that runs my test case, if you want.

10:18 rhickey: Chouser: no, I see from the trace you have a function that calls def with a fn

10:21 Chouser: you should stick with your binding then

10:21 Chouser: ok -- exposing LOADER as *loader* isn't too terrible?

10:23 rhickey: Chouser: how about *private-compiler-loader*

10:23 Chouser: sure

10:23 you want a patch, or should I roll it into my general clojurescript patch?

10:25 rhickey: Chouser: I'll take a patch if it makes it easier for you

10:28 Chouser: I 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:29 Whenever you choose to take all the pending cljs changes will be fine.

10:29 MarkVolkmann: I saw this syntax on the mailing list. (.setTitle frame# ~title) What do the # and ~ mean in this context?

10:30 Chouser: MarkVolkmann: they both only work inside a ` block.

10:30 MarkVolkmann: Okay. If there are inside a ` block, what do they mean?

10:31 Chousuke: MarkVolkmann: your paste was missing the ` character

10:31 Chouser: inside ` most words are unevaluated, passed stright through, so .setTitle comes out with just some namespace resolution: user\.setTitle

10:32 a trailing # means a gensym -- a new guaranteed-unique name: frame__49

10:32 a leading ~ means the following expression *will* be evaluated, so whatever title is bound to will be inserted there.

10:32 Chousuke: MarkVolkmann: did you see my writeup? it goes through a few examples.

10:33 MarkVolkmann: No. What's the URL?

10:33 Chousuke: though I didn't explain ~ very well :/

10:33 Chouser: user=> (let [title '(str "I'm a" "title")] `(.setTitle frame# ~title))

10:33 (user/.setTitle frame__58 (str "I'm a" "title"))

10:34 Chousuke: MarkVolkmann: http://groups.google.com/group/clojure/browse_thread/thread/27912d9dcaec2f24 the fifth post (the long one :P)

10:34 MarkVolkmann: Thanks!

10:40 duck1123: Chouser: I really like your show fn

10:41 Chouser: duck1123: thanks. the numbered-method thing seems kinda cheesy, but I haven't thought of a better way

10:41 also the sort order could use a bit more work.

11:13 blarf: is there a way to read symbols? i want do differ ?x from x.

11:15 Chouser: (pr ~foo) ==> java.lang.RuntimeException: java.lang.IllegalArgumentException: No method for dispatch value: class clojure.lang.LispReader$Unquote

11:15 blarf: I don't know what you mean by ?x

11:15 philscotted: Can I just implement variadic union in the obvious way, or is it more subtle than this?

11:16 Chouser: philscotted: might depend on what you think is obvious, but I don't think set.clj is particularly tricky -- just gets the job done.

11:17 rhickey: philscotted: there's a patch for this floating around on the group I think

11:17 philscotted: Well, 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:18 Chouser: sounds pretty sensible.

11:19 Chousuke: blarf: you can convert to string and use java stream readers

11:25 blarf: Chou: aj

11:25 ah

11:27 how do i def a var? (def a 10), a isnt a var.

11:28 rhickey: blarf: a is a var, but saying a means get the value of the var a, to get the var itself, say (var a)

11:28 tomhickey: trying to understand ::keywords, why does the later resolve to clojure ns and not user? user=> ::rect

11:28 :user/rect

11:28 user=> ::test

11:28 :clojure/test

11:29 oops, sorry for multi-liner

11:30 rhickey: tomhickey: ::test looks broken, will look into that

11:32 blarf: i cant do var and get info

11:32 user=> str

11:32 clojure.str__112@af914c

11:32 (doc str)

11:32 but not (doc var)

11:33 Chousuke: var is a special form. it's documented on the web page.

11:34 blarf: aha

11:35 rhickey: blarf: what version are you using?

11:35 user=> (doc var)

11:35 -------------------------

11:35 var

11:35 Special Form

11:35 Please see http://clojure.org/special_forms#var

11:35 Chouser: is Unquote not expected to work with pr?

11:36 rhickey: Chouser: what do you mean?

11:36 Chouser: (pr ~foo) throws an exception

11:37 rhickey: Chouser: you can't unquote outside of syntax-quote

11:39 blarf: (ensure ref)

11:39 Must be called in a transaction

11:39 what does must mean there? do i have to follow a dosync-alter with ensure?

11:39 rhickey 20080916

11:40 Chousuke: blarf: use a newer version :)

11:41 blarf: it means that ensure can only be called in a transaction

11:41 the wording is a bit ambiguous I guess.

11:51 Chouser: heh, like core.clj line 3111

11:52 '~'clojure.core outside of `

11:55 rhickey: aargh

11:55 should just be '

11:58 blarf: can i do (del a) or soemthing? delte a variab�e

11:59 Chouser: yep, with that change I can compile core.clj to js again. :-)

11:59 blarf: you want to remove 'a' from a particular namespace, or do something to the object stored in 'a'?

12:00 rhickey: Chouser: rev 1119 has the fix

12:01 also fix for Wodin

12:04 Chouser: thanks!

12:13 dfg59: can anyone help me with a problem i'm having using JLine with the clojure repl on os x?

12:13 danlarkin: we can try

12:16 dfg59: danlarkin: i'm using this script http://pastie.org/319767

12:16 it works fine without the jline extras

12:16 but errors with them

12:17 this is the error: http://pastie.org/319769

12:23 danlarkin: dfg59: tricky

12:32 dfg59: danlarkin: tricky?

12:32 any ideas why it's erroring?

12:35 danlarkin: nope :-/

12:35 I use rlwrap myself though

12:36 Chouser: me too

12:36 not to say it doesn't occasionally go wonkey itself...

12:37 duck1123: does anyone here know how to set paredit-mode when Slime begins?

12:37 Chousuke: slime probably has hooks.

12:38 dfg59: danlarkin: k, i'll check out rlwrap, hoping there's a port

12:39 danlarkin: fink has it, if you use that

12:39 ports probably does too

12:54 askentasken: anyone 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:02 duck1123: askentasken: I tried looking into that the other day, I don't think it's going to be that easy

13:25 pissed-at-glocal: a

13:26 anyone using magit on windows?

13:35 dfg59: anyone out there using clojure with vim?

13:35 Chouser: me

13:35 dfg59: Chouser: is syntax highlighting working for you?

13:36 everything works for me except syntax highlighting. completion/paren matching, etc

13:36 Chouser: I had to grab a syntax file, but yes.

13:36 dfg59: i have the syntax file as well

13:36 and the filetype is being recognized

13:37 i'm using the extension .clj on my files, is this correct?

13:37 Chouser: that's what I use

13:38 dfg59: hrm, k

13:38 rzezeski: asking the obvious, do you have "syntax on" in your .vimrc

13:38 Chouser: but even without that, I can just type :setfiletype clojure and it lights up

13:39 dfg59: Chouser, let me try that

13:39 rzezeski, yep

13:39 parans are highlighted for me, but not keywords

13:39 or anything else, for that matter

13:40 rzezeski: reaching in the dark...did you try setting another colortheme

13:41 dfg59: rzezeki, let me try

13:41 nothing there. all i get highlighting for is () and []

13:41 sjbach: dfg59, what version of vim? Have you tried sourcing the syntax file explicitly and reloading a .clj?

13:41 rzezeski: colorscheme I should say ":colorscheme ..."

13:42 dfg59: sjbach: 7.2

13:42 sjbach: i'll try sourcing it explicitly

13:42 still nothing

13:43 rzezeski: as a sanity check, does pretty printing work for other types of files like .java or .c?

13:43 dfg59: everything looks good in my ruby files

13:47 i'm going to try a fresh install

13:47 sjbach: dfg59, you may want to try paring down your .vim and .vimrc to something minimal to see if that helps

13:47 dfg59: i've removed everything

13:47 rhickey: tomhickey: ::test fixed

13:48 Chouser: dfg59: if you do :syntax do you see a bunch of clojure things, like a big clojureFunc section?

13:50 nsinghal: How can we get the current classpaths in clojure?

13:50 Chousuke: (System/getProperty "java.class.path")

13:51 dfg59: Chouser: one sec, reinstalling plugin

13:51 Chouser: what's the best way to install the vim plugin, to overly my existing dir structure

13:51 nsinghal: Thank you Chousuke

13:52 tomhickey: rhickey: thanks!

13:53 rzezeski: dfg59, you should be able to just do a "cp -r"

13:53 dfg59: rzezeski

13:53 rzezeski including bin?

13:54 rzezeski: dfg59, something like this: "cp -r ~/Downloads/vimclojure-1.2.1/ftplugin ~/.vimrc"

13:54 whoops

13:54 ~/.vim

13:55 dfg59: right, that's what i did, but not just ftplugin, everything else as well

13:55 including syntax

13:55 etc

13:56 Chouse: btw, i see a bunch of things when i type :syntax

13:56 rzezeski: whoops, ok I meant "cp -r ~/vim-clojure/* ~/.vim"

13:57 dfg59: rzezeski: 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:57 rzezeski: yea I don't think you need it there, I have it there and it's not hurting anything

13:58 dfg59: so i guess my question is, should i see defn as syntax highlighted?

13:58 if so, i'm still not seeing it, which is strange

13:59 rzezeski: defn is not highlighted for me either

13:59 dfg59: ah... :) maybe i do have it working then

13:59 what is an example of something i should see highlighted

14:00 abrooks: defn :keyword

14:01 dfg59: abrooks: ok, defn is not highlighted but :keyword is. hope this is what is expected.

14:01 Chouser: http://chouser.n01se.net/misc/vimclojure.png

14:02 dfg59: Chouser: yeah, i'm not seeing that

14:02 rm

14:02 hrm

14:02 rzezeski: dfg59, you and I both

14:03 Chouser: heh, great, I'm making it worse.

14:03 dfg59: heh, no, this is good to know that other's aren't seeing

14:03 Chouser: what's your OS?

14:03 Chouser: ubuntu

14:04 dfg59: rzezeski: are you on osx?

14:04 rzezeski: yep

14:04 I think I'm missing something from my .vimrc, that's my guess

14:04 dfg59: ah, as am i

14:05 i mean, should need anything other than filetype on and syntax on

14:05 both of which i ahve

14:05 *have

14:09 Chouser: did you use the plugin from http://kotka.de/projects/clojure/vimclojure.html

14:09 abrooks: dfg59: That's the plugin that I use. It works fine.

14:10 rzezeski: I think it has something to do with setting clj_highlight_builtins

14:11 abrooks: rzezeski's probably right. I have "let g:clj_highlight_builtins=1"

14:11 dfg59: --^

14:12 rzezeski: abrooks, yep that did it for me

14:12 what is the difference between set and let in vim?

14:13 I kept trying to set it

14:13 On the VimClojure site is says "You may set clj_highlight_builtins in ..."

14:13 abrooks: rzezeski: "let" sets internal variables. See "help let" vs. "help set"

14:16 dfg59: awesome

14:16 rzezeski: also, 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:16 dfg59: sweet :)

14:16 thanks guys

14:16 rzezeski: the things you learn when you actually take the time to read

14:16 dfg59: ugh, no kidding

14:26 danlarkin: looking at my code in jrat tells me nothing... as far as I can tell :-/

14:28 clojure.lang.Var.get() and clojure.lang.LispReader.read(..) take up 24% and 22% of the "method time %"

14:35 dfg59: interestingly enough, if i try to do the let command as an autocmd for the filetype, it doesnt work

14:36 Chouser: you can just set it all the time, can't you?

14:36 dfg59: Chouser: sure, and it works, was just trying to make it a bit smarter

14:36 * Chouser nods

14:38 rzezeski: the "g:" prefix stands for global, so I don't know if it even makes sense to do it per filetype

14:38 dfg59: rzezeski: good point. i have some similar settings for ruby, so i was giving it a shot.

14:56 gnuvince: rhickey: 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:56 rhickey: gnuvince: sure

14:57 gnuvince: rhickey: thank you.

15:10 askentask: (contains? [1 '?x] '?x) -> false, why?

15:11 Chousuke: askentask: (doc contains?)

15:11 Chouser: askentask: contains? works on keys not vals

15:11 the keys of your vector are 0 and 1

15:30 rhickey: JVM Summit talk: http://www.infoq.com/presentations/hickey-clojure;jsessionid=2826B81451C4EBFB6F676A26DC937E34

15:30 hiredman: ooo

15:35 rhickey: Clojure in 1/2 hour

15:35 * rzezeski grabs popcorn

15:38 AWizzArd: ah nice, a new vid :-)

15:38 rhickey: It's kind of like the trailer for Clojure

15:40 danlei: how would i do http://rpdillon.googlepages.com/creatingexecutablejarswithclojure with the new syntax? i tried: ns org.etherplex.example.jarexample

15:40 (:gen-class

15:40 :main true))


15:40 (defn- -main [& args]

15:40 (println "hello"))


15:40 Chouser: danlei: no need for :gen-class or :main if all you want is a main fn.

15:40 danlei: hm

15:40 Chouser: just (defn -main ...) is sufficient.

15:41 danlei: aah

15:41 thank you

15:41 Chouser: you're welcome.

15:42 AWizzArd: i must think about using this vid for a presentation in my company

15:42 kib2: Hi! 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:43 rzezeski: Oh I just heard the mock object joke, good one

15:46 dfg59: rzezeski: what mock object joke?

15:48 rzezeski: in the video rhickey just linked

15:48 dfg59: ah

15:48 rzezeski: they are "mocking you"

15:49 dfg59: heh

16:35 djpowell: can anyone explain :gen-class - i haven't seen any docs for it yet

16:37 Chouser: AOT/gen-class syntax example: http://paste.lisp.org/display/70665

16:37 the "announcement" starts here: http://clojure-log.n01se.net/date/2008-11-18.html#14:19

16:40 danlei: i'm having trouble in getting an "executeable" jar-file. if i do (ns org.etherplex.example.JarExample)

16:40 (defn -main [& args]

16:40 (println "hello"))



16:41 then gen-class will produce classes/JarExample.class and classes/JarExample$_main__2623.class

16:42 but if i try to run the jar, it gives me a class not found exception: org.etherplex.example.JarExample__init

16:44 maybe i'll just have to learn java :)

16:46 ... or revert to r1109, with gen-and-save-class, i had no problems

16:47 Chouser: you don't run anything called 'gen-class' do you?

16:47 danlei: i do

16:47 Chouser: oh, don't do that.

16:48 danlei: what should i use instead?

16:48 Chouser: try (compile 'org.etherplex.example.JarExample)

16:49 danlei: Chouser: thanks. now it doesn't find the class

16:49 Chouser: what doesn't find what class?

16:49 danlei: java.lang.RuntimeException: java.lang.ClassNotFoundException: org.etherplex.example.JarExample$_main__2620 (NO_SOURCE_FILE:0)


16:50 if i do (compile 'org. ...

16:50 Chouser: make sure you have "./classes" in your classpath

16:51 or whatever you have *compile-path* set to

16:52 danlei: chouser ah, thanks

16:54 askentask: is ~ ina macro the same as , in cl?

16:54 danlei: Chouser: ah, it finally works. all that java stuff still confuses me to death. thank you very much.

16:55 Chouser: askentask: yes it's about the same (maybe exactly). And it only has to be in a ` not necessarily a macro.

16:55 danlei: great! I just worked through this myself last night.

16:56 danlei: Chouser: :)

17:11 cooldude127: hey guys!

17:17 lisppaste8: asken pasted "while-macro" at http://paste.lisp.org/display/70789

17:18 askentask: http://paste.lisp.org/display/70789

17:18 can 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:19 Chouser: try macroexpand on that, and look carefully at the results

17:23 MarkVolkmann: What 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:23 danlei: it unquotes inside a quasiquotation, like ',' in cl

17:24 AWizzArd: MarkVolkmann: read this chapter: http://www.gigamonkeys.com/book/practical-building-a-unit-test-framework.html

17:24 no, this one I mean: http://www.gigamonkeys.com/book/macros-defining-your-own.html

17:25 about in the middle of that page you find "Generating the Expansion"

17:25 Chouser: `(foo map (+ 1 2) ~(+ 1 2))

17:25 AWizzArd: in Common Lisp they usey a comma instead of ~

17:25 Chouser: look at how the two different + expressions are handled

17:25 cooldude127: hey has anybody been implementing On Lisp in clojure? specifically the choose macro and all the non-determinism stuff?

17:25 Chouser: cooldude127: I believe someone started, not sure how far they got.

17:26 cooldude127: man, if i have the time i might try it. see if i can. i love that macro

17:27 Chouser: cooldude127: starts here: http://blog.fogus.me/2008/09/26/on-lisp-clojure-chapter-2/

17:28 cooldude127: cool, i'll look. he probably didn't, it's late in the book

17:28 Chouser: looks like he's up through chapter 5

17:28 cooldude127: yeah the stuff i want is in the late teens or early twenties

17:29 i think

17:29 Chouser: you 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:29 cooldude127: that might be a good choice if some of them didn't use stuff from before

17:29 Chouser: ah, good point

17:29 cooldude127: i'm almost positive that a good portion actually use macros from earlier chapters

17:29 cool progression actually

17:30 but annoying for this purpose lol

17:30 i'll have to do the less fun way (the CL way as opposed to the scheme way) due to clojure not having continuations

17:31 askentask: Chouser: ok so i got it to print results endlessly when true and once when false if given (while (z 5 10)

17:32 (while (> x 0) (dec x) (pr x))) or (while (< x 0) (dec x) (pr x)))

17:33 Chouser: but (dec x) doesn't modify x, it just returns a new value

17:33 this 'while' macro is inherently imperative

17:33 askentask: weeee!

17:33 Chouser: :-)

17:33 cooldude127: while is a tough sell in clojure

17:34 askentask: yes i used (def x (dec x)) and it worked

17:34 cooldude127: EWWWW

17:34 Chouser: ew

17:34 cooldude127: lol

17:34 it feels so dirty

17:34 askentask: is it possible to do without using def or or refs?

17:34 Chouser: askentask: but you got your macro working, so congrats on that.

17:35 danlei: won't work with a non-special var (one bound in let)

17:35 cooldude127: askentask: this is what we usually do with recursion i believe

17:35 loop and recur

17:35 just don't use mutation

17:36 Chouser: you might be able to do something a bit like C's for loop without being quite so dirty

17:36 I still doubt its usefulness, but you could try it.

17:36 MarkVolkmann: Let me make sure I've got this right. ~ is used inside quoted lists to force evaluation of a sublist. Right?

17:36 cooldude127: but really it needs a change in mindset

17:36 Chouser: MarkVolkmann: back-quoted lists, yes.

17:36 cooldude127: MarkVolkmann: yeah i guess so

17:37 it substitutes the value of the expression in, instead of just putting it in literally

17:37 Chouser: askentask: (c-for [i 0 (< i 10) (inc i)] (prn i))

17:37 cooldude127: yeah that could be done rather functionally i think

17:37 askentask: cooldude127: 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:38 MarkVolkmann: I don't comprehend the difference between substituting the value and putting it in literally.

17:38 cooldude127: MarkVolkmann: let's try some examples

17:38 hold on

17:38 danlei: MarkVolkmann: `((+ 1 2) ~(+ 1 2))

17:38 cooldude127: yeah that

17:38 danlei: i wanted the glory!

17:38 lol

17:39 danlei: cooldude127: sorry

17:39 Chouser: askentask: 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:39 cooldude127: user> `((+ 1 2) ~(+ 1 2))

17:39 ((clojure.core/+ 1 2) 3)

17:39 MarkVolkmann: Right. I see that it makes a list containing the unevaluated (+ 1 2) and the evaluated (+ 1 2) or 3.

17:39 cooldude127: (literal substituted)

17:39 danlei: MarkVolkmann: exactly

17:40 MarkVolkmann: But what's the distinction between "substitute" and "putting in literally"

17:40 cooldude127: MarkVolkmann: my terminology might not be too clear

17:40 Chouser: askentask: 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:40 cooldude127: by literally i mean it's put in as you see it

17:40 MarkVolkmann: Oh, okay. Thanks!

17:40 cooldude127: no prob

17:40 danlei: MarkVolkmann: anything inside a backquote is just data, only things that are unquoted (~) are evaluated

17:41 MarkVolkmann: What's the difference between a backquoted list and quoted list?

17:41 danlei: MarkVolkmann: you can't unquote inside a quoted list

17:41 MarkVolkmann: Ah!

17:41 cooldude127: that's not the only difference

17:41 user> '(+ 1 2)

17:41 (+ 1 2)

17:41 user> `(+ 1 2)

17:41 (clojure.core/+ 1 2)

17:41 user>

17:41 sorry about that

17:41 prolly should have pasted it

17:42 Chouser: symbols in backquoted lists are "resolved" based on namespace, in regular-quote they're left unqualified

17:42 cooldude127: back-quote resolves symbols to their namespaces

17:42 Chousuke: this is the key difference with CL backquote.

17:42 cooldude127: why does everyone beat me to my explanations!?

17:42 MarkVolkmann: Thanks!

17:43 Chousuke: in CL, '(+ 1 2) *is* equal to `(+ 1 2) :)

17:43 cooldude127: yeah, i like the distinction in clojure

17:44 Chouser: yes, it makes clojure macros a bit safer, without removing the ability to capture names if needed.

17:44 cooldude127: yummy

17:44 Chouser: quite a bit safer, really.

17:44 cooldude127: it's similar to hygienic macros without the suck

17:44 Chouser: exactly.

17:45 Chousuke: :)

17:45 cooldude127: i'm surprised it wasn't done before

17:45 makes so much sense

17:47 Chouser: yet another little piece of Clojure synergy -- namespaces and backquote working together to make macros better.

17:49 Chousuke: anyone 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:54 cooldude127: yeah i never could grasp it

17:54 in fact i'm almost certain i never successfully wrote a macro in scheme

18:04 powr-toc: I'm pretty new to clojure and trying to understand lazy-cons... Are there any simple examples of it's use anywhere?

18:04 cooldude127: it's used in a lot of functions in clojure itself

18:04 example: map is lazy

18:07 powr-toc: I'm looking at it right now, but it's still perhaps a little much... are there any oneliners which illustrate its use?

18:08 duck1123: where's that project euler wiki again

18:08 Chouser: yeah, map is a bit much. look at 'take'

18:08 hiredman: lisppaste8: url

18:08 lisppaste8: To use the lisppaste bot, visit http://paste.lisp.org/new/clojure and enter your paste.

18:08 duck1123: I'm sure that's full of uses

18:08 Chouser: powr-toc: 'take-while'

18:09 cooldude127: (do (def x (lazy-cons 1 (lazy-cons (println "x") nil))) nil)

18:09 Chouser: powr-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:10 powr-toc: cheers guys :-)

18:10 cooldude127: powr-toc: run that in a repl and see how "x" is not printed

18:10 then type x and hit enter

18:10 and you'll see it printed

18:10 lisppaste8: hiredman pasted "lazy-cons example" at http://paste.lisp.org/display/70799

18:13 askentask: => java.lang.IllegalStateException: No transaction running

18:15 duck1123: askentask: what did you do to get that?

18:17 askentask: sorry i had deleted drscheme so i dont have them. but u use (define-syntax ...

18:19 lisppaste8: asken pasted "ref-problem" at http://paste.lisp.org/display/70801

18:20 hiredman: well, uh

18:20 the ref-set needs to be in a dosync

18:20 or some kind of transaction

18:21 see (doc ref-set)

18:21 Chousuke: that's a very ugly way to do a loop though. :P

18:21 askentask: :)

18:22 hiredman: nasty in deed

18:22 askentask: why is the dosync alter not working?

18:22 Chousuke: askentask: ref-set needs to be in a dosync

18:23 askentask: well, (map pr coll) is too easy ;)

18:23 yes

18:23 Chousuke: yeah, it wouldn't work :)

18:23 askentask: but alter?

18:23 Chousuke: you need (dorun (map pr coll))

18:23 askentask: (map pr [1 2 3])

18:23 (1nil 2nil 3nil)

18:23 Chousuke: it works in the repl because the repl prints the result

18:23 hiredman: heh

18:24 oh the hilarity of (1nil 2nil 3nil)

18:24 cooldude127: lol

18:24 Chousuke: map is lazy, if you want side-effects to work, you *have* to use 'dorun

18:24 otherwise, you will eventually hit a bug.

18:25 askentask: how do i compile to a standalone program?

18:25 danlei: askentask: which revision?

18:26 askentask: http://rpdillon.googlepages.com/creatingexecutablejarswithclojure helped me very much, but it'll just work <= r1109

18:26 powr-toc: can I get function docs in the repl?

18:26 Chousuke: (doc fn)

18:26 danlei: powr-toc: (doc fun)

18:26 powr-toc: sweet/

18:27 Chousuke: askentask: (compile 'your.namespace)

18:27 askentask: will create a bunch of classes

18:28 askentask: 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:28 you'll need a very recent revision for that though.

18:30 powr-toc: is seq implemented in java or clojure?

18:31 cooldude127: Chousuke: 1110 or higher to be exact

18:31 danlei: powr-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:31 Chousuke: powr-toc: java

18:31 seq (fn seq [coll] (. clojure.lang.RT (seq coll))))

18:32 sohail: how would you implement Python's with statement in clojure?

18:32 specifically I am referring to the extensibility of it

18:32 Chousuke: hmmh

18:32 cooldude127: sohail that shit up

18:32 Chousuke: extensibility?

18:32 cooldude127: *macro that shit up

18:32 sohail: cooldude127, huh?

18:32 cooldude127: sorry i get ahead of myself and skip words

18:33 powr-toc: Chousuke: I take it seq is primarily just to raise java collections etc... into clojure sequences?

18:33 Chousuke: sohail: see the implementation of with-open

18:33 sohail: Chousuke, yeah but how would you make with general

18:33 Chousuke: powr-toc: or maps or vectors.

18:33 sohail: what do you mean "general"?

18:33 sohail: for example, you could do (with mutex ...) or (with network-connection ...)

18:33 cooldude127: sohail: probably a combination of multimethods and macros

18:33 Chousuke: sohail: with-open already works with anything that's closeable.

18:33 powr-toc: Chousuke: cool

18:33 sohail: Chousuke, hm, I will look at it then

18:34 Chousuke: sohail: including files, database connections and whatnot

18:34 probably not locks, as those are not .close()'d

18:34 with-open is very simple :/

18:34 sohail: Chousuke, I see so it has to be a java object

18:34 java class I mean

18:34 Chousuke: sohail: well, yes.

18:35 sohail: so how would you do it in pure clojure

18:35 Chousuke: sohail: you could make a with macro based on a multimethod.

18:35 cooldude127: yay what i said

18:35 Chousuke: that calls a multimethod on its argument to close it.

18:35 sohail: only thing I can think of is with an extra tag in your StructMaps

18:35 danlei: sohail: what exacty do you mean? you can whip up your own with-macros for anything you can imagine

18:35 Chousuke: why structmaps? :/

18:36 sohail: Chouser, maybe just structs?

18:36 cooldude127: maybe just maps?

18:36 sohail: danlei, mental exercise

18:36 Chousuke: yeah

18:36 sohail: ok just maps

18:36 Chousuke: structMaps are just maps

18:36 the struct part in them is just an optimisation.

18:36 sohail: yeah but I was explicitly saying StructMaps for some reason which escapes me now

18:36 Chousuke: maybe you're thinking of them as classes or something.

18:36 or C structs.

18:36 sohail: maybe

18:37 well anyway, so you'd have to add ane xtra tag

18:37 so how do you prevent keys from colliding

18:37 can you have qualified keys?

18:37 cooldude127: yeah something that identifies what it is so that you can do different stuff with different closeable things

18:37 sohail: like :mywith.close-tag

18:38 cooldude127: sohail: mywith-close-tag?

18:38 keywords don't have namespaces

18:38 sohail: I guess that's the way to do it

18:38 and then you'd do a multimethod which uses :mywith-close-tag as the discriminating (I made that up) function?

18:39 cooldude127: yeah, and you would call it a dispatch function

18:39 :)

18:39 sohail: yeah dispatch function!

18:39 sorry, 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:40 cooldude127: lol

18:41 sohail: I guess I'll write a with macro in clojure today... if I can get post-AOT to run that is

18:41 askentask: (for [x (split \n (slurp file))] (println x))

18:43 Chousuke: (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:43 disclaimer: it's almost 2 AM here.

18:43 sohail: hey screw you man

18:43 I was gonna do it :P

18:43 (I'm kidding!)

18:43 Chousuke: sohail: you can fix the bugs in that one.

18:44 sohail: that's pretty much it

18:45 powr-toc: I'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:45 sohail: they prefer Python

18:45 Chousuke: sohail: figure out how to make that work with multimethods in a sane way

18:45 or a useful way :P

18:45 sohail: :-)

18:46 powr-toc: sohail: they do?

18:47 danlei: i guess, if clojure doesn't bring lisp to the masses, nothing will do.

18:48 powr-toc: danlei: 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:49 hiredman: "the masses"

18:49 cooldude127: i'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:50 danlei: cooldude127: well, have you tried something like allegro or lispworks?

18:50 hiredman: clojure has screwed be over for other languages, because now I never remember to put in commas

18:50 me

18:50 danlarkin: hiredman: me too!

18:50 cooldude127: not much, gave a very brief look at lispworks

18:51 i'm one of those snobby os x users who hates everything that doesn't feel right on the mac

18:51 danlei: =)

18:51 cooldude127: and lispworks felt unwelcome

18:51 askentask: can i recur in macros?

18:51 danlei: so ... anything not written in cocoa =)

18:51 sohail: lispworks on Linux must be the ugliest application ever written

18:51 danlei: *using cocoa

18:51 cooldude127: danlei: almost

18:51 sohail: askentask, you should be able to I hope

18:51 danlei: cooldude127: i know that feeling ;)

18:52 cooldude127: yeah i was never this picky on windows

18:52 * danlei nods

18:52 askentask: cooldude: same feeling, common lisp and scheme wre both nice but lacks the practicality of modern languages, i mean im so productiv ein python.

18:53 cooldude127: they lack libraries

18:53 Chousuke: askentask: macros are secretly functions

18:53 lisppaste8: asken pasted "for-macro" at http://paste.lisp.org/display/70803

18:53 cooldude127: askentask: clojure is productive partly because you don't have to write everything yourself because you can call into java

18:53 askentask: ^^ trying to implement clojures for, not working

18:54 exactly

18:54 danlei: common 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:54 askentask: libs+awesome language

18:54 hiredman: uh

18:55 askentask: anything preceded by a ~ should have a ` somewhere before it

18:56 askentask: that macro is very broken

18:56 askentask: :)

18:56 hiredman: ~ is unquote

18:57 powr-toc: I can see clojure being a relatively easy sell at work... Yet I'd never be able to sell lisp.

18:57 hiredman: powr-toc: sell a java library that is so powerful it has implemented its own lisp

18:58 cooldude127: clojure can integrate into existing java infrastructure = easy sell

18:58 powr-toc: the JVM, and Java eco-system make it possible

18:58 cooldude127: exactly

18:59 hiredman: askentask: I am still trying to figure how exactly you think this macro should work :P

18:59 powr-toc: plus, 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:00 cooldude127: yeah, that's what's cool

19:00 do clojure under the table

19:00 no one has to know

19:00 it'll be our little secret

19:00 ;)

19:00 askentask: hiredman: take one elem at a time, do body, when there is no more elems, quit

19:01 (for-x [1 2 3] (pr 10)) -> 10 10 10 nil

19:01 hiredman: just use map

19:01 askentask: yes

19:01 hiredman: (map (fn [_] (pr 10)) [1 2 4])

19:02 askentask: but the point is to learn macros

19:02 cooldude127: also the built-in for can do that almost

19:02 learn useful macros

19:02 hiredman: askentask: make a macro that uses map

19:02 cooldude127: find a necessary abstraction

19:02 look for repetition in your code and macro it away

19:03 askentask: where is "for" in the clojure-source-code? in boot.clj?

19:03 cooldude127: probably

19:03 hiredman: the clojure for is not what you just described, I believe

19:04 cooldude127: not exactly, but it can do that kind-of

19:05 Chouser: no, map is lazy -- no good for side-effects.

19:05 hiredman: oh

19:05 yeah

19:05 damn it

19:05 cooldude127: so it for

19:05 *so is for

19:05 both need a (doall ...)

19:05 around them

19:06 hiredman: they don't if you aren't trying to translate a C for loop into clojure :P

19:06 Chouser: (defmacro for-x [seq & body] `(dotimes [x# (count ~seq)] ~@body)) ; untested

19:06 cooldude127: that looks pretty nice

19:07 Chouser: seems odd to take a seq and only use it's length, but whatever...

19:12 Chousuke: I think map is just fine for side-effects

19:12 you just need to remember the 'dorun (or 'doall)

19:14 powr-toc: Is there a way to format output in a printf style (%s etc...) in clojure?

19:15 danlei: format

19:15 blackdog: printf

19:16 Chousuke: powr-toc: the format function uses java.util.Formatter format strings.

19:16 askentask: how would i make a while that doesnt need refs or def?

19:17 macros are so hyped up but i never neeed them, a normal function pretty much always does it...

19:17 powr-toc: cool

19:17 Chousuke: askentask: consider yourself lucky then :)

19:18 does a while loop make sense in clojure? :/

19:18 danlei: hm

19:18 Chousuke: maybe *if* you're using refs

19:18 danlei: has someone tried to implement cl's format for clojure?

19:19 hiredman: I think in clojure alot of loops naturaly unroll into seqs

19:19 Chousuke: askentask: a while would only make sense if it were called like (while (< 1 @x) dostuff)

19:20 askentask: so you can write your while assuming that the test contains a var

19:20 er, ref*

19:21 it's not too difficult. you need loop, if and recur.

20:14 askentask: fuck a guy killed himself liv eon justin.tv

20:14 pretty horrible

20:14 read it on hacker news

Logging service provided by n01se.net