#clojure logs

2009-06-20

00:45blbrown_win2_if you do a compile, is gen-class really needed?
00:51replacablbrown_win2_: only if you want to create a named Java class
00:54blbrown_win2_replaca, what is a named Java class, one that doesn't use some non standard naming convention
00:55blbrown_win2_http://clojure.org/compilation well I guess it is in the docs
00:57replacablbrown_win2_: no, any class with methods that can be called from java in the normal way
00:57replacablbrown_win2_: are you a java guy?
00:57hiredmanblbrown_win2_: the classes generated by clojure have some gensym'ed name, so it is hard to new them up, because you need to know the name for new to work
00:57blbrown_win2_replaca, yea
00:57hiredmanwith gne-class you can specify a name
00:57blbrown_win2_sounds like it is not required and like you said, useful for using clojure from java
00:58replacaso if you want to create a class that you could easily use 'v = new MyClass()', b.bar(), etc. then you need gen-class
00:58replacabut usually when you're just writing clojure code, gen-class is not only unnecessary, but bad form
00:59replacabut if you need it, you need it
01:03replacain other news, I *hate* classpaths!
01:05blbrown_win2_what is wrong with classpath
01:06blbrown_win2_seems pretty simple you have a list of jars, you list them
01:07replacait's just a pain to track everything
01:08replacaplus, what i'm doing doing, i'm building jars while I'm using them so I have to munge it on the fly
01:08replacacompared to python, ruby, .net, etc. it just seems to get in the way more
01:09replaca(though .net has some huge nastiness when you try to get tricky)
01:09blbrown_win2_I wish you could track which jar a class was loaded from
01:10blbrown_win2_seem like that would be an issue thing to do, with the jar command, java should inject some kind of filepath signature from where the jar was built or something
01:10replacait's just one of those things I seem to spend an inordinate amount of time worrying about and I never really think about it in any other language I use
01:10replacablbrown_win2_: yeah, that would be a nice feature
01:11samuels`hey d00ds
01:11blbrown_win2_there are a couple of things I like about it. For example, with my application now, I wrote a custom class loader. Where i click on one jar and it (the java code) automatically finds the jars needed. Kind of like maven but working off the filesystem
01:11blbrown_win2_replaca, people seem to have classpath issues if they use the default global classpath
01:14tgevaertquit
01:15tgevaertheh
01:15tgevaert /quit
01:15replacablbrown_win2_: yeah, it can be powerful in cases like that, no doubt. I always make a custom one, cause there seems to be no useful default one. But I still seem to spend an unusual amount of time mucking with it.
01:16replacahey samuels`
01:16replacawelcome
01:17blbrown_win2_replaca, yea. actually there was one issue where I had a classnotdeferror and for the life of me couldn't figure it out
01:17samuels`replaca: what shall we talk about
01:17blbrown_win2_wtf is the difference between classnotfound and classnotdef...never did figure that one
01:18replacasamuels`: I don't know. I'm hacking up the new autodoc robot for clojure-contrib
01:18replacablbrown_win2_: I don't want to figure things like that out either! :-)
01:19samuels`replaca: have you seen "the hangover" ?
01:19replacasamuels`: not yet. heard it was good though
01:20replacait kind of scares me!
01:20samuels`why?
01:21samuels`out of interest
01:21blbrown_win2_guess it depends if you are a drinker or not...im a drinker, except for tonight
01:21samuels`where does the 'j' in clojure come from?
01:21samuels`java?
01:21replacaI get a wicked headache just thinking about the premise. A few too many mornings like that
01:21samuels`hehehe
01:21replacajava and a pun on the zh sound in closure
01:21samuels`ah ok
01:22samuels`btw is TCO slated for the jvm any time soon?
01:23replacasamuels`: not too soon it seems. Rumors keep starting, but not substantiated. Rich didn't sound too optimistic in the short-term lasd I heard
01:23replaca*last
01:24samuels`ok thx
01:24replacadon't find it bothers me too much, though, in practice
01:25replaca(not that I wouldn't like to have it)
01:25slashus2recur works fine
01:26replacayeah, not a purdy, but that doesn't bother me much
01:26replaca*not as
01:27slashus2I like explicit.
01:28replacaI get that argument
02:22blbrown_win2_In the clojure code, what is a call to Var.deref? Is that when you reference a variable not a local variable . E.g. (def abc 1) (println abc)
02:27replacablbrown_win2_: I don't think I understand the question
02:28replacaActually, reading more closely, the answer is yes
02:28blbrown_win2_http://gnuvince.wordpress.com/2009/05/11/clojure-performance-tips/ I was reading this blog and he mentions deref. When is the jvm Var.deref called
02:29replacaahh, yes. That's when Var.deref is called.
02:29blbrown_win2_(let [abc 1] (println abc) . is jvm: Var.deref called here
02:30replacablbrown_win2_: no, abc is not a Var in that case
02:30replacavars are always created with def or one of its derivitives
02:31replacaand can then be bound with binding
02:31blbrown_win2_like in the blog, I wonder why there is a penalty for using deref as opposed to local variables
02:35replacabecause they are bound thread locally and the language needs to do a lookup through a special per thread structure
02:36replacamy battery just died, which means it's time to crash for me, too!
02:36replacagood night all!
02:51blbrown_win2_replaca, still there? wanna see something cool
03:01blbrown_win2_http://spreadsheets.google.com/pub?key=rNB3pttScIyEdLM_kp2rejg&gid=4
03:16cp2neat
03:20blbrown_win2_here is the app I was testing. http://code.google.com/p/lighttexteditor/ code is not idiomatic which is probably why I am seeing issues
09:04Chouserthere was talk of writing up a style guide -- that hasn't happened, right?
09:14rhickeyChouser: right
09:22StartsWithKhi
09:22StartsWithKcan someone explain what does this http://www.assembla.com/wiki/show/clojure/Getting_Tests_Into_Clojure mean
09:23StartsWithKis clojure including test-is, templates and java-utis in core distribution?
09:24rhickeyStartsWithK: we're working out how to get tests into clojure, seeing what would need to move over etc
09:24rhickeytrying to avoid template, actually
09:25StartsWithKand test-is? will that make it official clojure testing library?
09:25rhickeyStartsWithK: not so much official, just the one Clojure uses to test itself
09:26rhickeywill not be called test-is
09:26StartsWithKif so, is it to late to ask that clj-unit could be used in consideration
09:26rhickeyStartsWithK: you need to convince people to write their tests with it, test-is is being used by many in contrib
09:27StartsWithKand for java-utils, will it go full, or will thigs like with-system-properties, and as-file as-str be stripped from it
09:27StartsWithKi think that with-system-properties even has a race condition
10:07ChouserStartsWithK: I think it's mostly about getting the clojure tests into the clojure project. Currently the clojure tests use test-is, so it has to come along too.
10:09StartsWithKChouser: so, test framework dosn't need to be a part of clojure.jar distribution? something like that
10:22Chouserwell, if it's included in the clojure repo, it would seem a shame to make it unavailable to users of the jar, don't you think?
10:25StartsWithKin such a situation it will become a official testing framework for clojure, and as such, i don't see it as a good option
10:26StartsWithKofficial more by convinience than anything else
10:29StartsWithKnot saying that is a bad thing that clojure gets one, but it will affect a lot of people, so maybe evaluation of other testing frameworks shoud be done
10:30ChouserI guess my point is it's not a matter of evalutation, it's a matter of the actual clojure tests that have been written
10:30Chouser160 tests containing 2953 assertions.
10:30rhickeyStartsWithK: the tests for clojure are written in test-is, there's nothing to evaluate bout that. This isn't a declaration of merit as much as a recognition of use (not that it doesn't have merit)
10:32StartsWithKrhickey: i get that, but if included in core, and with current lack of infrastructure for package and distribute clojure libraries to other users, using test-is derivative in core will be the first choice for many
10:33rhickeyStartsWithK: true
10:33StartsWithK(package and distribuate in automated way)
10:33rhickeybut making clojure dependent on some other package has its own problems
10:33StartsWithKthat is the catch 22 for both sides
10:34rhickeyclojure's lack of deps has served it well, IMO
10:34rhickeyStartsWithK: only if you think there is harm to test-is, I don't
10:35StartsWithKrhickey: compared to clj-unit that uses only functions and one macro (for exception handling), test-is has magic symbols (_1 _2) and requires a full tree walker to execute its tests
10:36rhickeyStartsWithK: that part of test-is is being reconsidered right now
10:36StartsWithKthere was even a talk about 'compatibility' layer so it can be used with some other contrib library
10:36Chouserrhickey: is there any chance Gashinsky's first name has a typo on http://clojure.org/contributing
10:37StartsWithKrhickey: thats good to hear
10:37rhickeyChouser: yup
10:37rhickeywill fix
10:38Chouserthanks
10:39bpattisonI'm looking for a function that applies a fn to every item in a list -- I know its clojure core somewhere -- any anyone help me out
10:41Chouserbpattison: 'map'?
10:42Chouser,(map #(* % %) (range 10))
10:42clojurebot(0 1 4 9 16 25 36 49 64 81)
10:43bpattisonI tried that once, but I try it again -- I must have confused myself
10:43bpattisonthanks!
10:43Chousersure! So you haven't given up entirely on clojure yet?
10:44bpattisonoh. no. clojure's great! -- I just can't find the time to work on it -- but my little parser project is sputtering along
10:50bpattisonany fustration comes from thinking in OO where data comes first, then find the function to work on the data -- so its easy to say find methods that work on strings or files, or whatever -- where in clojure your looking for functions that match a algorithmic pattern -- so 1) its harder to conceptualize and 2) its harder to find functions that already exists because you can't base your searches on "strings", "file", etc.
10:56blbrown_win2general question. map is call to a sequence and returns a new sequence. What is a function like haskells _Map. Where you iterate over a sequence but DONT return the sequence
10:57Chouserblbrown_win2: for side effects? or what is returned?
11:03Chouserblbrown_win2: anyway, you might want 'doseq'
11:16blbrown_win2Chouser, I was looking at trying to speed up some code, thought a map variant might help. I have another question. I know we should use (SomeClass. or .someMethod) but with the older form (. someMethod sdfs) is the call to '.' an actually function?
11:17blbrown_win2I wonder if I should get rid of that call to '.'
11:31dreishblbrown_win2: (.method o) is converted to (. o method) at macro expansion time.
11:31dreish,(macroexpand '(.method o))
11:31clojurebot(. o method)
11:32bpattisonI have (map str '(a b c)) --> ("a", "b", "c") -- but I want to get it to ("abc") -- any ideas?
11:32dreishapply str
11:32bpattisonperfect -- thanks
11:33dreishreduce str if the seq might get long.
12:16lenstwhy is length an issue?
12:22mattreplthink it has to do with maximum arity of Java methods
12:27lenst,(apply + (range 1 1000000))
12:27clojurebot499999500000
12:27lenstis there such a limit?
12:28mattreplthought there was to Methods
12:31mattreplinteresting, looks like I was mistaken
12:31lenst,(apply (fn [& xs] (if (and (seq xs) (< (first xs) 1000)) (recur (rest xs)) 17)) (iterate inc 0))
12:31clojurebot17
12:32mattrepllooking at AFn, it just converts the extra args to an array
12:35lenstRestFn is also interesting
12:38Chouserdreish: actually, apply str is better regardless of the length of the string.
12:39dreishWhy is that? I wasn't watching this window, but my reason was that apply holds the head, and reduce doesn't.
12:39Chouserthere's a limit on the number of individual args to a fn, but no limit on the size of the 'rest args' seq
12:40dreishWhy is that an advantage for apply? Seems like that would be equivalent.
12:40mattreplright, which is 21, including the rest seq that gets converted to an array
12:40Chouserdreish: hm, that's an interesting point.
12:41mattreplwas that number arbitrary?
12:41Chouserwell, I don't think it's always convert to an array
12:42mattreplwell it's defined using varargs (i.e., type is Object...)
12:44lenstlook at RestFn not AFn
12:45lenst,(parents (class (fn [& xs])))
12:45clojurebot#{clojure.lang.RestFn}
12:47Chouser,(parents (class (fn [x])))
12:47clojurebot#{clojure.lang.AFunction}
12:49rhickeychunked range rocks!
12:50mattreplso for RestFn, the last argument could be the rest of the seq, not necessarily an array, but eventually it's converted to an array when IFn#invoke is called
12:51dreishrhickey: Is it in the master branch?
12:51rhickeydreish: not yet
12:51rhickeywill push to chunks branch in a seq
12:51lenstmattrepl: don't think so, last arg will be the rest sequence. See applyTo method in RestFn
12:54Chouserheh. in a "sec"?
12:55Chouserthe rest arg can be infinite.
12:55mattrepllenst: that calls doInvoke, which I would imagine calls IFn#invoke, but I suppose it doesn't have to
12:55dmosah, just checking, what is the current state of maven2 for building clojure? The pom at http://github.com/richhickey/clojure seems to be not functional (including the generated version), and also differs slightly from the last committed on trunk in svn...
12:57lenstmattrepl: that would be bad because RestFn.invoke calls doInvoke
12:57Chouser,(take 20 (apply (fn [& xs] (filter even? xs)) (iterate inc 0)))
12:57clojurebot(0 2 4 6 8 10 12 14 16 18 20 22 24 26 28 30 32 34 36 38)
12:57Chouserso that's a fn that just took an infinite number of args and returned a lazy seq.
12:57Chouserreturned an infinite lazy seq.
12:57dreishImpossible! Magic!
12:58ChouserI know, fantastic, isn't it?
12:58cp2this _must_ be the work of the devil
12:58dreish(apply + (range 1000000)) is usually one of the first things I show people.
12:59Chouserrhickey: are you actively seeking help on the checked seq fns?
12:59dreishThey think it's going to crash the repl, and it comes back with the answer in a fraction of a second.
12:59Chouseriterate could be chunked, I would think.
13:00mattreplgreat, now I'm going to have to examine bytecode to be satisfied... =)
13:04rhickeyChouser: I am now, just wanted to do the basics - map/reduce/filter/range myself to sanity check the ideas. all pushed to chunks branch now
13:06rhickeyeveryone please try the chunks branch when you have time on your own code - I want to make sure the chunked versions are fully compatible with existing code - so far I haven't touched any client code, just swapped out chunked versions under the hood - quite thrilling
13:07dnolendmos: some people are it seems.
13:08dmosMmh, but clojure itself is not buildable with maven, is it?
13:10quidnuncAnybody have an example of using zip-select in enlive?
13:29jtalis there a way to walk through a large file without a loop?
13:30drewrjtal: map/filter over line-seq? Depends on what kind of data is in there.
13:30jtaljust plain text but very large
13:31jtalwill map use the same piece of memory for each iteration?
13:32jtalthat is, for each line
13:32dreishWhy would that matter?
13:32drewrjtal: It won't retain the head of the seq, if that's what you mean.
13:32jtalmemory used wont grow right?
13:32drewrRight.
13:33jtaland the whole file doesnt have to go into memory initally?
13:33dreishjtal: The GC will clean up as you progress through the file.
13:33jtalawesome
13:34jtalI'm using java.io.BufferedReader btw just in case thats not the cool thing to use :>
13:34clojurebot
13:34jtal<-- new to java and clojure
13:34Chouserjtal: sounds right
13:34dreishIsn't there something like (line-seq (reader filename))?
13:35jtalah you're right
13:35Chouserthere's clojure.contrib.duck-streams/reader
13:35dreishThanks I just shut down my emacs in preparation for a reboot, or I'd have checked.
13:36dreishI wrote an auto-closing line-seq, but I can't remember where I put it.
13:37dreishI think it's at the office.
13:38Chouserduck-stream/read-lines does that
13:38jtalare you guys using lojure at work?
13:38jtalc
13:38dreishI have, a little.
13:39quidnunc,seen cgrand
13:39clojurebotjava.lang.Exception: Unable to resolve symbol: seen in this context
13:40quidnunc,last cgrand
13:40clojurebot#<core$last__3771 clojure.core$last__3771@1509f8b>
13:40dreishclojurebot: seen cgrand
13:40clojurebotcgrand was last seen quiting IRC, 226 minutes ago
13:40Chouser~seen cgrand
13:40clojurebotcgrand was last seen quiting IRC, 227 minutes ago
16:50slashus2I was playing with the new chunked seqs branch. I was excited to test the performance of it, but it seems something like (reduce + (range 1000000)) is a lot slower.
17:09slashus2I think it is range that has slowed down on the sequence generation.
17:20slashus2I guess there is a lot more going on inside of range now.
18:30blbrown_win2gnuvince_, hey, I liked your clojure performance article
18:30blbrown_win2Ive been using it all weekend diagnosis problems
18:31gnuvince_blbrown_win2: thanks; just some things I found out and decided to write.
18:37JetienHi can somebody tell me the difference between the two calls "java -cp #jars clojure.lang.Script #script" and "java -cp #jars clojure.lang.Script #script --"? The first one doesn't one doesn't show JFrame calls, but the second does.
18:38hiredman-- tells java to stop expecting arguments?
18:39hiredmanI am not sure if that is correct though
18:39hiredmanalso, use clojure.main instead of clojure.lang.Script
18:39Jetienyes, but since there are no arguments after -- what difference does it make?
18:40Jetienok
18:41hiredmanwhat is the context?
18:41JetienI'm trying to run http://java.ociweb.com/mark/programming/ClojureSnake.html and one call succeeds and the other doesn't
18:42hiredmanso you are using a shell script launcher thing?
18:42Jetienyes
18:42hiredmanwell, pastbin that
18:42hiredmanlisppaste8: url?
18:42lisppaste8To use the lisppaste bot, visit http://paste.lisp.org/new/clojure and enter your paste.
18:43hiredmanas far as I know there is no official shell script launcher
18:43lisppaste8Jetien pasted "clj script" at http://paste.lisp.org/display/82197
18:44hiredmanah, well, there you go $*
18:44Jetienok, i need to clarify
18:44Jetieni was entering the commands manually in the console without the $*
18:44hiredmanoh
18:45hiredmanick
18:45Jetienthe reason i'm trying to find out why the version with "--" works and the other doesn't is this:
18:45hiredmanscriptname=$1 then $* is a bad idea
18:45hiredmanJetien: "doesn't" means you get some kind of exception, or what?
18:46Jetienno it just runs silently
18:46Jetienno swing gui is opened at all
18:46hiredmanuh
18:46Jetienim using vimclojure and there's the same problem, that's why i'm trying to figure this out
18:47hiredmanvimclojure is odd, I would not trust it to indicate a problem
18:47hiredmanas in, any issues you have while using vimcloure are just as likely to be vimclojure's as they are something else's
18:48Jetienbut the behaviour is the very same
18:48Jetieni call (com.ociweb.snake/main) - no errors, but silent
18:48hiredman2 + 3 = 5 and so does 1 + 4
18:49hiredman(if *command-line-args* (main))
18:49Jetienyes i admit you're right but it's a possibility
18:49hiredmanat the bottom of the snake code
18:49Jetienyes, that's why i start main manually
18:49arbscht*command-line-args* is (--) when you pass --
18:50hiredmanJetien: ok, so, to start clojure, what exactly are you typing?
18:51Jetienum..that's strange...it's working now - not in vimclojure though
18:52Jetieni guess it was the *command-line-args* guard after all
18:52Jetienbut this still doesn't explain why it's not working in the repl of vimclojure
20:30krumholt_what is the equivalent to funcall in clojure?
20:31slashus2I don't think you need it.
20:31RaynesWhat is funcall? >_>
20:32krumholt_(def a (fn [] (+ 3 4)) now i want to call the function in a
20:32Anniepoo(a)
20:32Anniepoo??
20:32Raynes^
20:33krumholt_yes (a). ok another example. (defn foo () "bar") (def a 'foo)
20:34RaynesI think you mean (defn foo [] "bar")?
20:34krumholt_yes
20:34krumholt_sry
20:34slashus2Why did you quote the foo before you assigned it to a?
20:35Raynes(def a (foo))
20:35slashus2Raynes: I think he wants to assign foo to a, not the result of it.
20:35Chouseror (def a foo) depending on what you mean
20:35cemerickkrumholt_: there is no funcall -- there's apply. Clojure is a lisp-1.
20:35krumholt_ok i got it thanks
20:35krumholt_so i cannot assign a value and a function to a symbol
20:36Chouserwell, you can't assign to a "symbol" anyway, but what you mean is correct
20:36krumholt_yes bind
20:36krumholt_ok thanks
20:36Chouserthere are not separate namespaces for values vs. functions.
20:36bpattison(defmulti concat_fruit :kind)
20:36bpattison(defmethod concat_fruit :apple [a b] (str a b "apple"))
20:36bpattison(defmethod concat_fruit :oragne [a b] (str a b "orange"))
20:36bpattison(concat_fruit {:kind :apple} "b")
20:36bpattison"{:kind :apple}bapple"
20:36bpattison(defmethod concat_fruit :lemon [a b c] (str a b c "lemon"))
20:36bpattison(concat_fruit {:kind :lemon} "b" "c")
20:36bpattisonjava.lang.IllegalArgumentException: Wrong number of args passed to keyword: :kind (NO_SOURCE_FILE:0)
20:36bpattisonCan anyone tell me why or how to work around multi-methods not accepting 3 arguments?
20:37krumholt_Chouser, ok thanks. i was used to that from cl and got confused.
20:37krumholt_thanks everyone
20:37Chouserbpattison: the problem is that your dispatch "function" :kind doesn't take 3 args.
20:38Chouserbpattison: you want to dispatch on the :kind of the first arg?
20:38bpattisonthat's correct -- the first arg
20:38Chouserkrumholt_: I was meant to be pedantic about your use of "symbol" not your use of "assign"
20:38bpattisonso I need to define a dispatch function that takes 3 args?
20:39Chouserkrumholt_: symbols in clojure do not hold values (or functions)
20:39Chouserbpattison: yes. probably something like (defmulti concat_fruit (fn [a & args] (:kind a)))
20:39Chouserbpattison: and next time please use paste
20:40Chouserlisppaste8: url?
20:40lisppaste8To use the lisppaste bot, visit http://paste.lisp.org/new/clojure and enter your paste.
20:40Anniepoocan somebody explain 'state' as it's used in http://clojure.org/state
20:41Chouserkrumholt_: I'm not sure exactly how CL works, but in Clojure a literal symbol in your code may refer to a local or to a Var. Those are what are bound to values.
20:41bpattisonI will try
20:42bpattisonchouser -- that worked like a champ -- so how did it know how to handle 2 args?
20:43Chouserthe "& args" part means take any number of remaining args and put them in a seq bound to "args"
20:43krumholt_Chouser, hm not exactly sure i get it. i will experiment a little more
20:43clojurebotWho??
20:44Chouserkrumholt_: it's a pretty subtle point. it may not matter to you.
20:44ChouserAnniepoo: "state" is any variable or object data member that hangs around getting its value changed from time to time
20:44ChouserA
20:45krumholt_Chouser, i think i get it the symbol binds to a var. i can get the the var with #'foo
20:45Anniepoook
20:45Anniepoohow is that not an identity?
20:45ChouserAnniepoo: for example the session values for a web app would be one kind of state
20:45Anniepoook
20:45Anniepooyes, I was thinking of the entries in an LDAP
20:46Anniepooas identities.
20:46cemerickkrumholt_: I've long since forgotten the finer points of CL, but clojure's model is definitely simpler around symbols, etc. It'll click for you. Internalizing this is critical: http://clojure.org/vars
20:46krumholt_cemerick, thanks
20:47Anniepooidentity "the port we're listening on" - which is buried, assuming we're an app level programmer, in some library after we open the serversocket
20:48Anniepooso the :state entry in a :gen-class is a symbol bound to something that hangs around?
20:48Anniepooon a per object level?
20:48ChouserAnniepoo: yes
20:48Anniepoothanks., I get that
20:48Chouserbut clojure is careful to make sure these identities control how their state changes
20:49Anniepoonow I'm confused what the exact syntax of :state is in :gen-class
20:49Chouserthe simplest being an atom -- it only ever has one value. The only ways to change it require that they happen in order
20:50Anniepooright. Hence the odd constructs like let
20:50Chouserthis is how it's different from java, for example, where you could have a static class member foo with data members bar and baz. Threads go read, write, and generally mess around with bar and baz uncontrolled.
20:51Anniepooright
20:51Chouserso you have a question about gen-class syntax?
20:51Anniepoowell, as I understand it in Clojure you can't mess around with bar and baz if they're not static either???
20:52Chouserwell, if they're actually java data members, you can still do what you want :-P
20:52Anniepooyah, suppose I have a simple case - I want to subclass some java class and attach some data to it
20:53Chouserbut you wouldn't do that. you would make bar and baz be, say, refs: (def foo {:bar (ref 0), :baz (ref 0)})
20:53AnniepooI want to make a JButton, when you click it it changes from whatever's in the text to "HI"
20:53Anniepooand when you click again it changes back - so I need to keep the old value
20:54Chousera jbutton has a hold wad of state inside it.
20:54quidnunccgrand: Is the definition of text-node correct? zip-pred tests z/branch? but that will be false for a string node I think.
20:54Anniepoosure, of course
20:55ChouserAnniepoo: but yes, it would be sensible to try to ignore that and store your old value in a nice clean clojure reference object.
20:55Anniepooyes
20:57Anniepooyah, my real example is too complex to ask about, so I'm making up an example
20:57Chouser:-)
20:57Anniepoobut just trying to understand how I glue some extra data to a java object when subclassing
20:58Anniepooin effect getting a member variable
20:58Chouserah, yes.
20:58Chouserdo you need to add methods, or is proxy sufficient?
20:59AnniepooI need to store additional state
20:59AnniepooI'm making a clojure editor, the 'button' is a panel that maps to a clojure form, I need to attach it to the model
20:59Chouseryes, but you can do that via closures with proxy.
21:00ChouserI mean, a proxy can close over additional state.
21:00Anniepoo??
21:02Chouser(def obj (let [v (atom 0)] (proxy [Object] [] (toString [] (str (swap! v inc))))))
21:03Chouserthat creates a proxy that closes over v, and stores the proxy object in obj
21:03samuelsChouser: dont you think that let should just be replaced by let* (and called simply 'let') so that it's easier for noobs
21:04Chousernow each time you call (.toString obj) or just print it at the repl, it'll inc v and return a string with the new value of that state
21:04Chousersamuels: already is.
21:04samuelsreally?
21:04samuelsah ok, i just remember seeing a let* in the 'programming clojure' book
21:04Anniepoofar out!
21:07Anniepoothat's why the (atom 0)
21:08Anniepoothis language will either save my soul or damn me to heck
21:08Anniepoodarn me to heck?
21:11Anniepoothanks!- I'll go stick head back in clojure book
21:13ChouserAnniepoo: right. without atom you could still close over a value, but you couldn't change it.
21:17AnniepooI keep wanting my OOP.
21:17ChouserAnniepoo: you'll get over it. :-)
21:19Chouserwell, I'm still working to get there. the more stateful the task at hand, the harder I'm pulled toward OO concepts.
21:19AnniepooI feel like I'm a novice in a religious order... yes teacher, I will get used to sleeping on the floor and eating only a handful of rice each day
21:20Anniepooisn't it appropriate to have OO concepts some times?
21:20Anniepoosuppose you're doing something that would be well handled in an OOP language
21:21Anniepooa game with pieces with varying capabilities perhaps
21:21Chouseryes
21:21Chouserhave you looked at multimethods?
21:22AnniepooI've been programming since before OOP came along, so it's not totally foreign
21:22Anniepoodon't multimethods end up distributing the code that handles a class all over?
21:22AnniepooI mean, I remember structured programmers resistant to OOP who would put case statements everywhere
21:23Chouseryou can distribute the code however you want -- group the methods by dispatch object or by method, your choice.
21:24Anniepooah, cool, I didn't know that
21:24krumholt_can i change a var in a let form? i want to do (let [a 1] (???set??? a 2)(print a))
21:26Chouserkrumholt_: vars generally should only be changed within a thread-local binding. Is that what you want?
21:26krumholt_yes
21:26Chouseroh, wait.
21:26Chouserthat's not a var
21:26slashus2You can't do that with a local.
21:27Chouserwhat slashus2 said.
21:27slashus2You can create an atom or a ref and change them sort of.
21:27Chouserkrumholt_: you can do (let [a 1, a 2] (print a))
21:27slashus2(let [a (atom 1)] (reset! a 2))
21:28krumholt_slashus2, that seems to be what i want
21:28Chouserkrumholt_: we probably need to know more about what you're really trying to do.
21:28Anniepoo(let [a (atom 1)] (swap! a 2) (print a)) Is that what he's trying to do? Or am I bogus?
21:29krumholt_something like: (let [counter 0] (defn inccount [] (incf counter)) (defn show [] counter))
21:29Chouserit's rarely necessary or idiomatic to use an atom or other reference type within a purely local scope.
21:30Anniepoo(let [a 1] (let [b (inc a)] (print b))) is that the idiomatic way?
21:31ChouserAnniepoo: sure, that's better than using atom.
21:31Anniepoo (let [a 1] ...bunch of stuff...(let [b (inc a)] ... bunch more stuff... (print b)))
21:35krumholt_ok thanks. it is not exactly what i want, but than again i shouldn't be doing that anyway. i am just trying to get a feeling of what i can and cant do with clojure
21:46Anniepoo (let [a (atom 1)] (swap! a 2) (print @a)) did I need this?
21:46Anniepoo(@ sign)
21:47gnuvince_Anniepoo: @x is syntax for (deref x)
21:47Anniepooyes
21:48Anniepoobut I have to deref here?
21:48gnuvince_so x is the ref and @x is the actual value, so you need the @a depending on what you want to display
21:48slashus2For atoms and refs, yes.
22:12Anniepoois there a way to ifdef out code in Clojure?
22:13AnniepooI'm in the frustrating noobie situation that I changed a working program and broke it, now I can't get back to where I was
22:13duck1123there's if
22:13Anniepookk
22:13duck1123what exactly are you wanting to do?
22:16Chouseryou can "comment out" a s-expr using #_
22:16Anniepoothanks
22:16Chouser,(+ 4 #_ (garbage i don't want) 5)
22:16clojurebot9
22:17duck1123Chouser: I didn't know about that one. does that remove it completely, or return nil
22:18duck1123I've run into issues with (comment) changing my return value
22:19duck1123,(do 1 #_ (+ 1 1))
22:19clojurebot1
22:21Chouserduck1123: right, removes it at read time. Does not insert (or return) nil.
22:21slashus2#| |# will come later?
22:22Chouserwhat is that? block comment?
22:22slashus2That removes it at read time.
22:23Chouserdunno.
22:23Chousershould it nest?
22:24duck1123I still say that XQuery has the friendliest commenting system
22:24duck1123(: this is a comment :)
22:24arbschtha
22:26Anniepoostrange. I've got a window that was working fine. I messed with the stuff I asked about earlier, tried runnign it, and the window gets no repaint event
22:26Anniepoobreaking in with the debugger always stops with, of all things, somewhere in file input operations
22:28slashus2Anniepoo paste it in http://paste.lisp.org/
22:28Anniepookk
22:29Anniepoolisppaste8: /url?
22:29lisppaste8To use the lisppaste bot, visit http://paste.lisp.org/new/clojure and enter your paste.
22:30lisppaste8Anniepoo pasted "wont redraw" at http://paste.lisp.org/display/82208
22:30Anniepoosorry to ask for help with what should be a simple case of going back to what I had before
22:33duck1123odd that you're not using the ns macro
22:34AnniepooI'm a total noob
22:34AnniepooI'm lucky I haven't shot myself with this thing yet
22:34Chouserwhat's the problem?
22:34ChouserI get a window with 2 sets of 3 labels
22:35Anniepoomouse over it
22:35Anniepoosometimes it redraws, sometimes not
22:35Anniepoosometimes it comes up, draws the frame, never draws the content area
22:36Anniepooswing threading weirdness?
22:36Anniepoohard to believe - It worked consistently before
22:36Chousermaybe need to flush stdout?
22:36AnniepooI've noticed that print doesn't give me output, just println
22:37Anniepoowonder why it started this
22:37Chouserprint doesn't flush the output
22:37Chouserdunno why you wouldn't have had that problem before.
22:38Anniepoobecause every mouse action must end with an up and that's println
22:38Chouserif I sprinkle in (flush) after every (print ...) I seem to get good output
22:38Anniepookk
22:41Anniepoostrange
22:41AnniepooI did that, didn't help
22:41Anniepoolisppaste8: url?
22:41lisppaste8To use the lisppaste bot, visit http://paste.lisp.org/new/clojure and enter your paste.
22:42lisppaste8Anniepoo annotated #82208 "untitled" at http://paste.lisp.org/display/82208#1
22:42Anniepoook, there's my version
22:42AnniepooI tried restarting my ide
22:43ChouserI guess I'm not quite sure what you're wanting.
22:43AnniepooI'd like the window to repaint and not hang
22:43Anniepooit's not reliably repainting on my system
22:44lisppaste8Chouser annotated #82208 "my flushes" at http://paste.lisp.org/display/82208#2
22:44ChouserI don't know what you mean by "repaint" you're expecting the boxes to draw differently somehow?
22:45AnniepooI'm expecting them to draw
22:45AnniepooI see the corner of my IDE inside, on about 50% of the runs
22:46Anniepooon the other 50% I get the initial draw
22:46Anniepoobut then when I move the mouse over the windo it gives me a wait cursor
22:46ChouserI can resize and move around the window and it still looks good.
22:46Anniepooand nothing else happens
22:46Anniepoo!!!!
22:47Anniepoocan you move your mouse over the windo? It should print some commas and []
22:47AnniepooI never get that output
22:47Chouseryes, I get commas and []
22:48Chouserand dots
22:48ChouserAnniepoo: what's your ide?
22:48AnniepooIntelliJ
22:48Anniepooyah, it's working for you
22:48Anniepoohmm... I think I installed the old CloJet at one point and borked my install somehow
22:49AnniepooI get an ide error complaining that it's already got a language called Clojure
22:49Anniepoobut the odd part is, I didn't mess with the IDE at all
22:49AnniepooI was working fine
22:49Anniepooasked you the question earlier
22:49Anniepooabout how to keep state
22:50Anniepooadded a toy demo of it and tried to run, It did this
22:50Chouserjava -cp clojure.jar:clojure-contrib.jar clojure.main -i yourcode.clj
22:50Chouserthat's how I'm running it.
22:50Anniepoolet me try it from the cmd line
23:00lisppaste8Anniepoo annotated #82208 "untitled" at http://paste.lisp.org/display/82208#3
23:00Anniepooyah, I always get this when I start intellij
23:02Anniepoook, I'm going to do a hard reboot
23:18Anniepoook, that's maximally strange
23:18AnniepooI rebooted the machine and that fixed it
23:22Chouserwow
23:22Chouseryummy
23:24Anniepoothere's a race condition between two plugins apparently
23:25Chousernice
23:25Chouserwell, glad you found a way forward. Sorry it was a random bug absorbing your time :-/
23:25Anniepoowhat's the status of clo-jet?
23:25ChouserI'm off to bed.
23:26Anniepooyah, sorry to take your time with this noob stuff
23:26AnniepooI appreciate it