#clojure logs

2010-06-02

00:45axiso.. when using gen-class.. only functions listed for :init and :methods belong to the class? nothing else in the file?
00:47cemerickaxi: and those methods inherited by superclasses or defined by implemented interfaces
00:48hiredmanok
00:48axiso.. how would I declare class-level variables like in java?
00:48hiredman(a double boating accident)
00:49hiredmandamn it
00:49hiredmantrying out split window irssi
00:50axiin one of the functions listed under :gen-class's :methods
00:50axiI have code like "(def text (new JTextArea))"
00:51axiand i'd like to be able to (. instance text append "bla") etc..
00:51axibut that doesn't work, because it looks like it gets destroyed when the function exits..
00:51axiso.. I need to give it class scope
00:51axibut clojure has no facility for that?
00:51cemerickdefinitions should (almost) never go within fns
00:51cemerickThat's defining a new top-level var
00:51axiI can't find any examples for what I want to do..
00:52cemerickaxi: you want to add all of the "class level variables" to a clojure map, and return that as the :state value from the :init fn
00:52axiwhat exactly should be in the init function?
00:53axiI see no documentation for it..
00:53cemericklook at the docs for gen-class
00:53axiI read it 20 times
00:54axiMust return [ [superclass-constructor-args] state]
00:54cemerick":init - If supplied, names a function that will be called with the arguments to the constructor. Must return [ [superclass-constructor-args] state]"
00:54axiRight now it's (defn -init [] [[] (atom [])])
00:54axiwhat do you propse I add to it?
00:55cemerickI don't know what your end goal is, but you can return [[] {:text (JTextArea.))]
00:55cemerickThen you can access the text area with (-> instance .state :text)
00:56axihow woudl I access it from an instance of the class?
00:56axi(. instance state :text)?
00:56cemerickjust what I said
00:56axioh, sorry
00:56cemerickno, (:text (.state instance))
00:57cemerickwhich is equivalent to (-> instance .state :text)
00:57cemerickhave you gone through the examples @ http://clojure.org/compilation
00:57cemerick?
00:57axihrm
00:57axijava.lang.ExceptionInInitializerError
00:58axilooks like (defn -init [] [[] {:text (JTextArea.))]) doesn't work
00:58cemerickwhat's the base cause of the exception?
01:01axiother than the missing } and ) in wrong place.. idk
01:01cemerickare you subclassing something in the :gen-class?
01:02axino
01:03cemerickpaste your entire file somewhere, please
01:04KirinDaveHey folks
01:04KirinDaveIf I define a deftype in a given namespace, how do I make it from another namespace?
01:04KirinDaveI go testspace/my-type and it doesn't find anything.
01:05cemerick(your.namespace.TypeName. a b)
01:05axiyay
01:05KirinDaveAhh
01:05KirinDavecemerick: Weird I am doing that
01:05cemerickaxi: progress?
01:05axicemerick, it works
01:05axity :-)
01:05cemericknice :-)
01:06axiit looks like I have a lot of reading to do now though to understand why it works :P
01:06cemerickaxi: gen-class has a lot of flexibility, but there's complexity that goes along with it. If you can use the newer defrecord/deftype stuff, then do so.
01:06KirinDavecemerick: http://idisk.me.com/dfayram/Public/Pictures/Skitch/blogpost.clj-20100601-220457.png
01:07axik, i'll keep that in mind
01:07KirinDaveAhh
01:07cemerickKirinDave: kooky
01:07KirinDavecemerick: Actually, weird
01:07KirinDaveRemoving the constructor period works.
01:08cemerickKirinDave: you're using an older snapshot
01:08KirinDaveI guess that's the trick.
01:08KirinDavecemerick: Am I?
01:08cemerickIndeed.
01:08KirinDaveDid types get their funcallability removed?
01:08cemerickYes.
01:08cemerick~3 weeks ago :-)
01:08clojurebotexcusez-moi
01:08KirinDaveAh!
01:08KirinDaveI never check my installed version
01:08KirinDavebecause lein always gives me one sealed for freshness
01:09cemerickheh
01:09cemerickKirinDave: I'll walk you through maven someday, if you haven't been. :-)
01:09KirinDavecemerick: I don't really understand it.
01:09KirinDaveI mean I get the gist
01:09KirinDavebut the specifics are greek
01:10cemerickit's cake, despite the groaning from the peanut gallery
01:11KirinDaveUsually I have to surf maven2 by hand to find out if something is in there
01:11KirinDaveRight there learning how to avoid that would be fantastic
01:12cemerickKirinDave: http://mvnrepository.com/ for starters
01:12KirinDavecemerick: It seems like sometimes I search for project names there and they don't show up, but they are on maven2
01:13cemerickwell, that is a third-party mirror
01:13cemerickhaving a nexus repo (which proxies central and whatever other repos you're interested in) is a good thing
01:13cemerickas is having good tools (i.e. both netbeans and eclipse have in-IDE search that's worked well for me)
01:13KirinDaveI am taught to fear nexuses by my magi overlords.
01:14cemerickBut that's where all the power is... :-)
01:14KirinDaveYeah.
01:14KirinDaveWell, you know how it is. With great power comes great fondness for wavy daggers and making apprentices clean up the laboratory.
01:14cemerickheh, right
01:14KirinDaveAs much as I want to bang out this blog post tonight, I'd better get to the gym.
01:15cemerickbed for me, later :-)
03:04BorkdudeWhat is the best dynamic vs. static typing article out there?
03:04KirinDaveBorkdude: Uh, depends on what you want to justify
03:04KirinDaveBorkdude: Since many of the best languages take hybrid approaches, the issue is somewhat muddy now
03:05BorkdudeKirinDave: let's say, for making clear to someone who always programmed Java and cannot imagina a dynamic language would work for a big project
03:07KirinDaveBorkdude: The most obvious answer is to point to a lot of large projects that use dynamic typing and say, "See?"
03:08bobo_if php works in large projects with its crappy typing, every other type system works in a large project
03:08turbofailfor certain values of "works"
03:08bobo_:-)
03:09Borkdudebobo_, I don't want to mention PHP :)
03:09turbofailthough really, any decently run large project is really a composition of a bunch of smaller projects
03:09Fossiand for certain values of "large" :D
03:09turbofailthus, this whole "size" argument doesn't make a whole lot of sense
03:09sparievturbofail: judging by your inck, you do know what are you speaking about :)
03:10Borkdudewhat I like about Clojure is that you can just pick a small fragment and explore it in the REPL, but that isn't a dynamic typing property
03:10sparievnick*
03:10KirinDaveHmmm.
03:11KirinDaveCan you use protocols to write a custom tostring for an object?
03:11turbofailspariev: all too much
03:13BorkdudeDoes Clojure support pattern matching like: (defn foo ([1] 1) ([2] 2) ([x] (foo (dec x)))? No, but maybe there is smth like this?
03:13KirinDaveWith matchjure
03:13KirinDaveWhich I think is going into contrib, right?
03:14KirinDaveYeah, last week it was announced that there'd be clojure.contrib.match
03:14Borkdudecool :)
03:16KirinDaveYou can get matchure right now tho.
03:16BorkdudeKirinDave: does it support a pattern matched defn like I described?
03:16KirinDaveYes.
03:17KirinDaveBut it's more like plt-scheme's match-lambda stuff.
03:21tomojwhat's the deal with ?foo in matchure?
03:21tomojI can't figure out why it isn't just foo
03:28Borkdudegtg
04:23LauJensenMorning all
04:23sparievmorning
04:30Licenser_aloa
05:42SinDocHow can we make one tail call and one recursive call in the same loop?
05:43opqdonut(defn f [x] (loop ... (f something) ... (recur somethingelse)))
05:46SinDocYeah but what happens to the arguments that loop receives? Loop will be initialized again.
05:47opqdonutyou'll have to pass them in explicitly
05:47SinDocYeah, I guess that will work
05:47opqdonutyou'll probably want to implement it with just plain binary recursion first
05:48SinDocI don't understand why recur complains about a call not being a tail call
05:48opqdonutrecur is a tool for constructing _loops_
05:48opqdonutif you have true recursion, you use the stack
05:48opqdonutas I said, start with binary recursion and loopify if it really is necessary for performance
05:49SinDocI'm porting some algorithms from Scheme
05:50SinDoctrust me, you don't wanna mess with tail-calls there
05:50opqdonutok
05:50SinDocThanks opqdonut I'll give it a try
06:48LauJensenlets celebrate with some xml!
06:48esjits been bloody
08:08Licenser_hmm how is the best weay to go when I need to call super in an object in clojure?
08:08Licenser_do I have to AOT for that? Since proxy does not seem to allow it :)(
08:08chouseryou can use proxy-super
08:08Licenser_ah sneaky thanks!
08:09chousernote that's not thread-safe. :-/
08:09G0SUBchouser: is there an equivalent in terms of reify?
08:09Licenser_chouser: I do swing right now, nothing is thread save
08:10chouserG0SUB: reify doesn't to implementation inheritence, so there's nothing in super to call.
08:10G0SUBchouser: ah, right.
08:10Licenser_neat this woirks :D
08:11Licenser_I have a red swing t ree now!
08:29sparievjust wondering, what exactly is dispatch performance difference between multimethods and deftypes/defrecords ? is it like orders of magnitude ?
08:30Licenser_when I create a new type, can I pass the constructor around as function? or anything else
08:33Licenser_I can't write new MyType
08:33Licenser_neither can I pass MyType.
08:35hoeckLicenser_: you can, but only with reflection
08:36hoeckLicenser_: better wrap your type-ctor in a fn
08:36Licenser_hoeck: okay
08:36Licenser_It didn
08:36Licenser_t work at all for me so I went with a fn already
08:37hoeck(clojure.lang.Reflector/invokeConstructor MyType 'a 'b 'c)
08:38hoeckno, its actually ( .... MyType (into-array Object '[a b c]))
08:39Licenser_yes bit I can
08:39Licenser_'t pass MyType
08:39chousermuch better to write your own ctor fn and pass that around
08:39Licenser_figured that, fixed it to do that
08:39Licenser_making funky swing trees is hard :P
08:42Licenser_hm problem is something else
08:42Licenser_if I 'use' a namespace I don't include the types
08:42Licenser_that is bleh
08:43chouserthe types are classes, thus have to be imported instead
08:43Licenser_yap but I would have expected when using a namespace it automatically does that :P
09:31Licenser_hmm I find the import behaviour of types odd
09:43patrkrisThe nicest way to get all the elements from a vector v specified by the indexes in another vector a?
09:44chouser(map v a)
09:47canderaDefinition: "Clojure Factor" - the ratio of the length of some solution to a problem to the optimum one. Mine stands at something like 5. :)
09:49arkahnlikewise
09:51_fogus_Definition: "Chouser Factor" - see "Clojure Factor"
10:03esjmine often goes infinite as I try to solve problems that don't actually exist.... ah well
10:08rhickeyaargh! test_clojure.clj:87
10:11arkahn(System/exit 0) ?
10:11cemerickrhickey: ?
10:11cemerickis this hunt-for-the-real-line-number time?
10:11rhickeycemerick: yes
10:12cemerickA perennial favorite. I wonder if there's a real solution.
10:13cemerick(beyond clever stack trace analysis/printing)
10:13rhickeycemerick: fix the test library?
10:13cemerickrhickey: well, it's a general problem
10:13rhickeynot really
10:14cemerickI'll show you some stack traces from compojure in conjunction with lazily-produced output sometime.
10:16rhickeya testing framework should be expecting exceptions in tested code
10:17rhickeyit's generating that report, not a stack trace
10:17Licenser_hm hmm is there a way to 'filter' a hashmap?
10:17Licenser_say 'I only want the keys' X Y Z
10:17cemerickLicenser: select-keys
10:18Licenser_cemerick: thank you smart person!
10:19LauJensenHere's a nice idea for any Clojure-driven site: When referral spam or cross-site scripting attempts show up in the access.log, pass the IP tip iptables DROP list - problem solved forever :)
10:19cemerickrhickey: that's just clojure.test you're talking about? I'm seeing pretty good stack traces in a recent failed test. *shrug*
10:20Licenser_LauJensen: jes and no, it has to time out
10:20Licenser_since dynamic IP's might hurt an innocent person
10:20Licenser_I wrote a ruby script for something like that once
10:20Licenser_it blocked SSH brute force people
10:20rhickeycemerick: the stack trace is fine, but the first hing you see is a line from test, which knows the files but always prints the same line from test_clojure.clj - it's just wrong and useless
10:20rhickey [java] ERROR in (defrecord-object-methods-test) (test_clojure.clj:87)
10:21cemerickoh, ok -- yes, clojure-maven-plugin does the same thing
10:25arkahnLauJensen: also, punishes people who all share the same public IP(s). I work at a company of thousands of computers and a single compromised machine could trigger a server response for everyone here. But maybe that's acceptable.
10:27LauJensenarkahn: I trust people to get an email through to me if they get blocked. For certain nations (a certain nation) Im considering a nation-wide ban, and instead of blacklisting, do white-listing
10:31eevar2Licenser_: so you reimplemented fail2ban?
10:32eevar2unless you did it before fail2ban existed, of course
10:32arkahnLauJensen: blocking countries based on geo-location was talked about on Slashdot recently. One conclusion was that is was coarse and ineffective with things like botnets that disregard country boundaries. On the one hand, a person thinks 'well I don't need to receive traffic from X' but then a good blackhat wouldn't always originate from the same country (or their own country at all).
10:33arkahnLauJensen: just a thought
10:33Licenser_eevar2: I have no clue never heared of fail2ban :P
10:33eevar2the main threat is botnets, no?
10:34LauJensenarkahn: I think the good blackhats deserve to give it a go. But periodically I spend too much time blocking spam, in comments, in referrels, in emails, you name it. And if some region, country, useragent, whatever turns out to be 99.999% spam, then I think its a pure timesaver just to cut it
10:35arkahnLauJensen: if one region makes up that much of the bad behavior, I can see it then.
10:35eevar2Licenser_: look it up next time you want to stop ssh brute force attacks, neat software
10:35eevar2i'm sure there are tons of similar apps, tho
10:36LauJenseneevar2: When launching a linode, you get ssh attacks almost immediately, change to an alternate port and something like 80% goes away.
10:37arkahnLauJensen: if enough people did that with their servers, I bet you'd get greater ISP or government pressure to fix their problems from within ; )
10:37Licenser_my latest spam is from china
10:38arkahndoes (send-off *agent* #'fnname) send off an anonymous agent ... or, er, 'agentify' the function call?
10:38LauJensenarkahn: why would you think so ?
10:39eevar2LauJensen: but that's security by obscurity! ;) -- i guess it doesn't really hurt as an additional layer of protection, tho
10:39LauJenseneevar2: right, the second move is to disallow password auth
10:39arkahnLauJensen: if enough servers did that, it would impact business and money, the prime motivator for companies and governments.
10:40LauJensenLicenser_: its mad, I get (got) weekly emails saying "We are a China based" and then whatever they were selling that month. Do they honestly expect me to hire them after sending me 50 or so offers?
10:40LauJensenarkahn: oh ok, thought you were referring to the alternate port - but I hear you
10:40LauJensenI guess we should just get busy and build that 'ring of trust' internet :)
11:19arkahnwill the next release of clojure be 1.1 or 1.2?
11:20cemerick1.2
11:20cemerick1.1 was released on 12/31/2009
11:20arkahncemerick: *palm-on-forehead*, thanks
11:32bartjis there a better way to get the index of a seq which satisfies a function?
11:32bartjthan this:
11:32bartj(defn get-index [f x] (loop [i 0] (if (f (nth x i)) i (recur (inc i)))))
11:33chouserindexes and seqs don't go together very well. Are you sure you need an index?
11:33bartjhmm, I need the index of a seq/collection which satisfies a function
11:33bartjchouser: also, I am curious why you say so
11:34KirinDavebartj: Because seqs can often be infinite
11:34KirinDavebartj: Which sorta defeats the point of an index. ;)
11:34bartjKirinDave: thanks!
11:34TimMcbartj: And return nil if not found, I suppose?
11:35chouseraccessing seqs by index and getting indexes from seqs will always be O(n) -- usually there's a better way.
11:35chouserbartj: what will you use the index for, once you have it?
11:36KirinDavebartj: If you use clojure.contrib.seq-utils, you can use (indexed initial-seq) to lazily annotate every entry with an index. Then you can write your predicate to use the second argument. But listen to chouser, what you're asking might be inherently a bad idea.
11:37bartjKirinDave: point noted
11:38bartjchouser: a function returns a lazy sequence, and I wanted to know the index of the sequence which satisfies a given property
11:39KirinDavebartj: Why is the index relevant?
11:39chouseryes, I understand. once you have this index, what do you intend to do with it?
11:39KirinDaveIs it corespondent to a line number, perhaps?
11:39bartjKirinDave: honestly, this is a programming problem from Project Euler
11:39KirinDaveoh.
11:40KirinDaveHaha, don't publish your times. ;)
11:40KirinDaveI see what you're doing, but don't expect meteoric performance out of it. )
11:40chouserah, well if the index is the final output, then getting it is of course acceptible.
11:40KirinDavechouser: "there was no step 3." :D
11:40chouser:-)
11:41bartjwhat would be the best way possible way then?
11:41chouserin your example, x is a vector?
11:41bartjno, a lazy sequence
11:41chouserah, then (nth x i) is a bad idea. Again, that's O(n)
11:41KirinDavebartj: It's an approximation of some iterative computation that you've broken into steps.
11:42TimMcSo... at each step you are generating the next value, then checking a property of it.
11:42KirinDaveWhich euler project?
11:42chouserand since it's in a loop, O(n^2)
11:42KirinDavechouser: I think he's scanning through linearly as he goes, discarding previous values.
11:42KirinDavechouser: I don't think he'd have to fetch.
11:43KirinDaveOh wait, your code doesn't do that. :D
11:43bartjKirinDave: 25
11:43TimMcSeems to me you're better off with a (loop) that recurs on the index and current value.
11:43chouser(keep-indexed #(when (f %2) %1) x)
11:44bartjTimMc: you mean this: (defn get-index [f x] (loop [i 0] (if (f (nth x i)) i (recur (inc i)))))
11:45KirinDavebartj: Chouser is saying you shouldn't use nth.
11:45KirinDavebartj: And he's right. Do not use nth.
11:45TimMcbartj: Nah, just do your fibonacci calculation in the loop, and your checking.
11:45TimMcNot sure what the point of using a sequence is here.
11:45hugodshould I be able to add a field to a defrecord at the repl by re-evaluating the defrecord?
11:46chouserIt's ok, and probably good, to decouple the different parts. A fibonacci seq is reusable.
11:46TimMcbartj: You can keep your last two fibonacci numbers around as loop parameters (or whatever they're called) as well as the fibonacci index.
11:46chouserhugod: I think so
11:46TimMcchouser: Decoupling... good point.
11:47TimMcbartj: Ignore me, chouser knows hwo to do this in a way more appropriate to clojure. :-P
11:47KirinDavebartj: So what you want is a sequence of numbers from your indexed sequence that meet some predicate.
11:47KirinDavebartj: We can easily add the index with (indexed seq)
11:47KirinDavebartj: We want to filter based on your predicate
11:48chouserhugod: you can, but existing objects of the record type may behave a bit oddly.
11:48KirinDaveSo to start, say that predicate is your predicate and it's (fn [[index val]] ...)
11:48KirinDaveThen you'd say (first (filter predicate (indexed (my-lazy-seq))))
11:48KirinDaveThat'll return you a 2-vector, [index value]
11:48hugodchouser: doesn't seem to work for me on the latest snapshot - the constructor isn't redefined
11:49KirinDaveNote that even if your sequence infinite, first only takes the first value
11:49bartjKirinDave: is the solution to add an index to the seq?
11:49KirinDavebartj: What I described is by far the least code for you to write, and it keeps the O(n) property you wanted.
11:49KirinDaveHonestly that'll actually be faster than 90% of the entries on euler if it involves fibb numbers, most people don't have O(n) implementations of fibb finders.
11:50KirinDaveThere is a reason there isn't the equivalent of ruby/python's collection.find, because lazy collections already solve the problem.
11:50chouserhugod: hm, works here. I'm on 878dea8 from May 28. I'll update
11:51chouserbartj / KirinDave: did you see my keep-indexed solution?
11:51chouserer
11:51chouserhugod: sorry, completely wrong version number.
11:51bartjchouser: I am having difficulty understanding what keep-indexed does
11:52chouserbartj: it takes a fn and a seq, and calls the fn on each item of the seq until the fn returns something truthy. It then returns that truthy thing.
11:52KirinDavechouser: I did. I think the (first (filter ..)) has didactic value here, but yours would be what I use in practice.
11:52hugodchouser: I'm on clojure-1.2.0-master-20100602.140300-81, whatever that translates to...
11:53chousersorry, call the fn with the seq item *and its index*
11:53KirinDavechouser: I try and keep the predicates simple when people are learning about seq munging.
11:53chouserKirinDave: I didn't say anything until you said your solution was least code. :-)
11:53bartjchouser: and also returns the seq item and the index?
11:53KirinDavechouser: I meant less than his. :D
11:54KirinDavebartj: No.
11:54chouserbartj: no, keep-indexed returns just the value the your fn returns.
11:54KirinDavebartj: It returns a lazy sequence. So like filter, you need to handle it with kid gloves.
11:54KirinDaveHaha, just call exit in your predicate ;)
11:54KirinDaveDONE!
11:54chouseroh!
11:54chouseryou're right, I needed (first ...) as well. sorry.
11:55KirinDavechouser: I like the "call exit in your predicate solution"
11:55KirinDaveIt's so very c-ish
11:55chouser:-P
11:55TimMcNaw, you should segfault to stop execution.
11:55KirinDave;)
11:55TimMcEveryone else is doing it!
12:08cemerickhas there ever been a broad survey of from where people came to clojure? I seem to remember chouser doing one some time ago, but can't find it now....
12:17lpetitcemerick: a long time away from coding java in a client ; then discovering new langages (new for me) : SmallTalk, common lisp, scheme, Haskell. Not finding anyone that could be used in practice. Then find clojure. Stop the search. :-)
12:17cemericklpetit: :-)
12:17cemerickI've got a 5-question google form almost done. This'll be interesting.
12:17lpetits/in a client/at a client/ ?
12:17sexpbotlpetit: Format is sed [-<user name>] s/<regexp>/<replacement>/ Try $help sed
12:19TimMc${preposition} a client
12:19sexpbotCommand not found. No entiendo lo que estás diciendo.
12:20lpetitcemerick: one thought out of my mind. I've remarked that I'm not "staying with clojure" for exactly the same reasons I "came to clojure". I discovered that clojure had much to offer than what I thought initially (basically, I thought I had find a way to "rule them all" by having a language with macros. It's only later on I understood the virtues of the way clojure mixes FP and state management)
12:20lpetitcemerick: so maybe you could have a question "wy do you stay with clojure", also ?
12:20cemerickthat's a complicated question, deserving a complicated answer :-)
12:21lpetit:)
12:21_fogus_I would love to see a Clojure-centric "Hammer Principle" site
12:21chouserlpetit: me too. I came here only for macros+interop
12:22_fogus_But that's probably just me
12:23_fogus_cemerick: http://therighttool.hammerprinciple.com/
12:23_fogus_Obviously structured differently
12:23cemerickah
12:23cemerick_fogus_: it's also a martial arts concept, apparently
12:23lpetitchouser: :) . BTW, just bought your ebook today ;)
12:24_fogus_Interestingly, Clojure does very well on the annoying syntax question - http://therighttool.hammerprinciple.com/statements/this-language-has-an-annoying-syntax
12:25technomancy_fogus_: because it's only rated by people who actually know the language. =)
12:25_fogus_technomancy: I suppose there is a flaw in the "choose the languages you know" aspect. :-)
12:31cemerickheh
12:31cemerickit's alphabetized and I can't change the order, so it's done :-P
12:31cemerickwhen I do State of Clojure, Winter 2010, I'll take suggestions
12:33bsteuberdoes anyone know how to write EOF or make (read) stop somehow using slime?
12:49cemerickCan I get a smattering of problem domains to add to the survey? e.g. Math / analytics, gaming, web development, network programming, etc etc
12:51chouserdevice drivers, process scheduling, memory cache hit optimization
12:52chouserer, wait.
12:52cemerickdammit, chouser, do you have a native Clojure backend that you're not sharing? :-P
12:52chouser:-)
12:52chouserp;/-p;/9ik,m786890p-------------------~
12:52cemericksly, cheeky bastard chouser is ;-)
12:53bartj__fogus__: Regarding that link - http://therighttool.hammerprinciple.com/languages/clojure, shouldn't "Ranked highly in" and "Ranked Low in" mean "advantages" / "disadvantages"?
12:54bartj__fogus__: if yes, how come verbosity is shown as a disadvantage!
12:59bartjKirinDave / chouser: thanks for the help before, I had to rush out before...
13:04Licenser_does anyone know how I can force a swing jtree to update a certain path/node or itself entirely?
13:04TimMcbartj: The problem is that not all statements can be classified cleanly as "positive" or "negative".
13:09cemerickOK, any thoughts before I post this?
13:09cemerickhttp://spreadsheets.google.com/embeddedform?formkey=dDVXY0ZfWlNfdXl0TW43S3dJcTFvU1E6MQ
13:11LaPingvinohello
13:12TimMccemerick: "if using at work" needs a third option
13:12cemerickTimMc: which is?
13:12TimMcShould be "Are you using Clojure at work? : No ; Yes, endorsed ; Yes, secretly"
13:12TimMcMost browsers do not let users unclick a radio button set.
13:13cemerickyeah, OK
13:13TimMc(Also, people will abandon a survey if they think they can't answer one of the questions & think it is required.)
13:14cemerickthanks, changed
13:15cemerickany other feedback? Going once, going twice...
13:17TimMchrm
13:17mabescemerick: it might be interesting to take an editor survey as well..
13:17TimMcWording on primary langauge is a little weird.
13:17TimMcPrevious primary, or last language used on a project?
13:20cemerickmabes: yeah, good.
13:20cemerickProbably the last question I'll add. Don't want the thing to fall over.
13:21bartjcemerick: is it possible to have a "grid" of check boxes instead of a very long list for the question - "If Clojure disappeared tomorrow, what would you use as a "replacement"?"
13:21cemerickbartj: I looked, and it doesn't appear to be possible.
13:22cemerickit'll be the last question, so as to not scare people away
13:23mabescemerick: it might be interesting/worthwhile to distinguish web application development from web services development... I'm willing to bet more people use clojure more for APIs than for sites.
13:24bartjcemerick: perhaps include a question on the documentation? not sure what though...since blogs serve as the most important "documentation" right now for me.
13:26cemerickmabes: those are some fine hairs to split, insofar as a lot of people do both
13:27mabesyeah, it is probably fine as is
13:28pedroteixeirahello, anyone knows if there is a version of compojure works with clojure+contrib 1.2-master?
13:28bartjmost of the questions seem inclined towards - "where" are you using Clojure? not sure if the title is apt...
13:29jfieldsif I'm in a function is there a way to print the name of the function that called me? (or the entire call stack?)
13:29cemerickbartj: that's a little bit of the point, no? Where is clojure being used, and where did its users come from, etc.
13:32mabesjfields: perhaps trace could help: http://richhickey.github.com/clojure-contrib/trace-api.html
13:32rhickey, (map str (.getStackTrace (Thread/currentThread)))
13:32clojurebot("java.lang.Thread.getStackTrace(Thread.java:1426)" "sandbox$eval__8474.invoke(NO_SOURCE_FILE:0)" "clojure.lang.Compiler.eval(Compiler.java:5343)" "clojure.lang.Compiler.eval(Compiler.java:5311)" "clojure.core$eval__4350.invoke(core.clj:2364)" "hiredman.sandbox$cond_eval__4040.invoke(sandbox.clj:76)" "hiredman.sandbox$eval_in_box_helper__4065.invoke(sandbox.clj:112)" "hiredman.sandbox$eval_in_box__4070$thunk__4073.invoke(s
13:33mabesor that :)
13:33jfieldsrhickey, mabes: thanks
13:36rhickeyjfields: in nested clojure calls, .getClass of the stack trace element is pretty useful:
13:36rhickey(defn foo [] (map #(.getClassName %) (.getStackTrace (Thread/currentThread))))
13:36rhickey(defn bar [] (foo))
13:36rhickey(defn baz [] (bar))
13:36rhickey(baz)
13:36rhickey ("java.lang.Thread" "user$foo" "user$bar" "user$baz" "user$eval128" ...)
13:37jfieldsrhickey, cool. that was what I was looking for. thanks.
13:38rhickeynp
13:42riddochcrhickey: has my contributor agreement arrived?
13:43rhickeyriddochc: haven't looked at the box in a few days, will soon
13:47bartjcemerick: Tracing your Clojure Beginnings - A Survey
13:49riddochcrhickey: Then it's probably there. Thanks. I look forward to helping out with stuff.
13:53KirinDavepedroteixeira: It doesn't work?
13:57pedroteixeiraKirinDave: thanks.. it is actually congomongo the problem. thought was compojure. testing between over 5 forks out there in clojars now :)
13:57KirinDavepedroteixeira: Just use the main one.
13:58KirinDaveDon't mess around with the forks, they're often weird
13:58jfields(I'm working with some legacy code...) Is there a way to access private fields of a java object instance?
13:59pedroteixeiraKirinDave: my team members (used to java) are finding it difficult to choose which version to pick from clojars. the problem is congomongo and the new contrib json now.
14:00pedroteixeiraKirinDave: the main congomongo does not accept "sort" in the fetch function.. only rads` seem to.
14:00TimMccemerick: Is the survey "public" now?
14:00cemerickTimMc: yes: http://twitter.com/cemerick/statuses/15267220072
14:00cemerickand posted to the google group
14:02hugodcemerick: can we see the results?
14:03cemerickhugod: I figured I'd keep them wrapped until I close the form. Seems like it's just begging for gaming.
14:03hugod:)
14:03cemericklike, all three emacs users writing scripts to drive up the counts! ;-)
14:03cemerick:-D
14:03mabesjfields: I've never needed to do that, but I believe that is what wall-hack-field and wall-hack-method are for: http://richhickey.github.com/clojure-contrib/java-utils-api.html
14:04mabes,(doc wall-hack-field)
14:04clojurebot"clojure.contrib.java-utils/wall-hack-field;[[class-name field-name obj]]; Access to private or protected field."
14:05TimMcAwesome name.
14:07jfieldsmabes: thanks
14:08bartjcemerick: "state of clojure" form duly filled in
14:09cemerickbartj: thanks much :-)
14:10cemerickmabes, jfields: the wall-hack fns there are actually deprecated I believe, moved here: http://richhickey.github.com/clojure-contrib/reflect-api.html
14:11mabesyeah, so depending on what version of clojure you are on.. for 1.1 use java-utils, but for 1.2 use the ones in reflect
14:11mabeswell, version of c..c
14:12jfieldscemerick, mabes: cool, thanks
14:13chouser,(first "\n")
14:13clojurebot\newline
14:13chouser,(second "\newline")
14:13clojurebot\e
14:14chouserriddochc: how about that for "most glaring"? :-)
14:15LauJensencemerick: I think question #3 should be "In which domains are you using Clojure", correct?
14:15riddochcchouser: Yeah, that one's pretty weird.
14:16riddochcBack later. Have fun clojuring.
14:18cemerickLauJensen: Yup, that'd be more correct. Will fix.
14:18rhickeycemerick: where are the results?
14:21cemerickrhickey: I figured I'd keep them closed for a while, anyway -- seems like a starting gun for gaming things
14:21rhickeycemerick: ok
14:23zakwilsonhttp://gist.github.com/418631 <-- I'm having trouble getting full performance out of a quad-core machine. I got some interesting feedback on the google group, but no closer to my code running faster on four cores than two.
14:24bartjis it possible to have some sort of rating system for libraries on clojars like search.cpan.org for perl modules
14:25KirinDavebartj: maven?
14:27bartjKirinDave: eg: http://search.cpan.org/search?q=xml;s=0 (I almost immediately know to use XML::Twig for parsing xml files) based on the rating
14:33zakwilsonI'm not sure how to answer some of these Clojure survey questions when I'm working on something that I intend to make a startup out of, but currently isn't anything that formal.
14:40cemerickzakwilson: yeah, I'd call that "at work", commercial product/service
14:41islonis there raw strings in clojure? or do i have to escape every double quote?
14:44TimMczakwilson: But be honest...
14:46chouserislon: escape all double-quotes, unfortunately
14:46chouseror read it from a file of course
14:47cemerickmmm, a perennial wish-list item
14:47islonok, i'll use a file
14:47TimMcAre there LISPs with heredocs?
14:48islona reader macro would be good
14:58cemerickTimMc: I'm sure there's a CL reader macro somewhere for them. c.c.strint is the closest there is here.
14:59rubydiamondhi guys..
14:59rubydiamondis Clojure, an object oriented programing language
15:00rubydiamondI read Clojure is not Object Oriented ..
15:00ryslol
15:00cemerickrubydiamond: this is a subject of great debate :-)
15:01cemerickyou can create Java objects from clojure, and you can define new Java classes in clojure
15:01rubydiamondcemerick: but that is not clojure right
15:01cemerickrubydiamond: sure, it is
15:01cemerick(defrecord Foo [a b]) defines a new class with two fields
15:02rubydiamondcemerick: but Clojure is functional language right
15:02rysI think the ability to interact with Java doesn't make it an OO language by any means. You could choose never to do so, by design
15:02nDuffrubydiamond, LISPs are traditionally so flexible you can define your choice of object systems within them.
15:02nDuffrubydiamond, ...and this is no different with Clojure.
15:02cemerickrubydiamond: indeed
15:02rubydiamondrys: that's what I meant
15:02cemerickrubydiamond: it's probably most important to not get tied up in the semantics of "object oriented" and "functional", etc.
15:03rubydiamondomg, defrecord for class
15:03cemerickor deftype or gen-class -- each with different capabilities and interop knobs
15:04nDuffrubydiamond, ...see for instance CLOS, the Common LISP Object System. I'd argue that whether the existance of CLOS makes the question of whether Common LISP is object oriented irrelevant; you can write OO code with it, or you can choose not to do so, as appropriate for your situation.
15:05rubydiamondbtw if I know Lisp.. does it mean.. that I can learn Clojure faster
15:06_fogus_Was it chouser who said, "Clojure is not object-oriented, but oriented around objects"?
15:06cemerickthat's nice
15:06cemerickrubydiamond: you'll certainly have a leg up on a lot of concepts
15:06chouseryes, but not enough faster to warrant learning Common Lisp, unless you have some other reason to do so.
15:08rubydiamondchouser: "Clojure is not object-oriented, but oriented around objects" lol
15:17rysI guess it is short sighted to equate OO with imperative programming against mutable state
15:17zakwilsonI'd point everyone toward SICP, which uses Scheme if they haven't already worked through it. Of course, SICP + Clojure will take longer than Clojure by itself.
15:17zakwilsonAllan Kay would consider that a mistake, rys.
15:17rysYeah
15:18rysI hang my head for the 'lol'
15:19mebaran151well OO is usually just about mutable state
15:19zakwilsonHis idea of what OO means has more to do with message passing than anything else. Clojure's reference types support a form of it.
15:19mebaran151at least simula 1 style
15:22zakwilsonNone of this matters much though. Clojure is what it is, regardless of what you call it.
15:22cemerickyeah, like I said, it's probably most important to not get tied up in the semantics
15:45hugodchouser: I found my defrecord problem - an aot class file in the classpath - defrecord silently fails in this case
15:45chouserhm.
15:52islonto the guy who made the clojure.contrib.sql: why not create a "with-query-result" or "with-single-result" to return a single result? its a pretty common pattern
16:14mebaran151Did anyone ever do real OO style programming with just closures in Clojure?
16:15Licensercookies!
16:15mebaran151where instance variables were stored as locals?
16:16mebaran151I played with writing a couple macros, that now seem to have been subsumed into defrecord. Other than Java interop, what would have been the disadvantages of representing as objects in terms of functions?
16:16lancepantzi've seen it done in other lisps, but not clojure
16:17mebaran151that's probably because other lisps didn't have easy built-in hashtables
16:17KirinDavemebaran151: They don't?
16:18mebaran151I'm assuming, because very function compiled to a class, this method probably woudl be just as fast as defrecord and deftype, except with much worse names and therefore worse dispatching
16:18mebaran151not with builtin syntax, like in Clojure
16:18KirinDavemebaran151: The protocol-based dispatch is much faster than the generic dispatch.
16:18KirinDavemebaran151: Yeha, well most code did use that syntax tho
16:19KirinDaveit just wasn't in the standard.
16:19KirinDaveI think nearly everyone did something like: http://frank.kank.net/essays/hash.html
16:19KirinDaveWe don't get reader macros in clojure, unfortunately.
16:20mebaran151oh I didn't know
16:20KirinDaveYeah
16:20KirinDaveScheme and Common Lisp allow for reader macros
16:20mebaran151I don't know about scheme, but I know sbcl had defstruct
16:20KirinDaveSo basically you can really have any syntax you wan
16:20KirinDaveYou could make an algol reader macro ;)
16:21KirinDaveSo I think it's also true in sbcl
16:21mebaran151I never actually was able to use any lisps for serious programming before, so the most I did was dabble before Clojure
16:21KirinDaveBut defrecord/deftype are making distinct types to dispatch upon.
16:21KirinDaveIf you use a function to do it, that works, but it doesn't have any type system stuff and thus loses a bit.
16:21mebaran151well assuming you didn't redefine it at the REPL, would you dispatch on a function type, though the name is really nasty?
16:22KirinDaveBut that wouldn't be terribly helpful to the compiler.
16:22mebaran151and maybe write some macros to work with it like a java object
16:22KirinDaveBoth SBCL and Clojure can do a hell of a lot more if you use defined objects rather than fns or hash tbales.
16:22KirinDaveThe compiler and jits can actually make things equivalent to offset in C in the best case. SBCL frequently does this
16:22mebaran151I'm not saying it should be done, I'm just saying it was theoretically possible
16:22KirinDaveYes
16:22KirinDaveHave you read the scheme paper?
16:23mebaran151which?
16:23KirinDaveThe original sussman one, i think
16:23KirinDaveClosures and Objects are equivalent
16:23KirinDaveBut offer different perspectives with different optimization potential
16:23mebaran151I think I learned the style from the SICP, and was reminded from some blog post in recent memoryy
16:24mebaran151well you could never make mutable closures right?
16:24Licenseraloa my lispy friends!
16:24mebaran151locals have to stay local
16:24KirinDaveI don't understand your question
16:25KirinDaveAnd you could make mutable closures in clojure
16:25mebaran151in standard oop, usually field mutation is take for granted
16:25KirinDaveIt need not be
16:25KirinDaveBut yes, in common lisp fields in a clojure are mutable.
16:26KirinDaveSetf will rebind a local just as well
16:26mebaran151in a closure?
16:26mebaran151ah I didn't know not
16:26mebaran151*that
16:26KirinDaveThere is a book, "let over lambda"
16:26KirinDaveYou should check it out.
16:26KirinDaveif you can successfully finish 2 chapters in that book, ANY two, you will be a better lispologist than most people.
16:27greghI have that book, it's kinda neat
16:27KirinDaveit's the most insanely dense macro book imaginable
16:30mebaran151I really do a need a good macro-fu book
16:30KirinDaveThat book is the fu book
16:31mebaran151one of my coworkers is a macro machine, but he came from computational ling, so it was expected
16:31_fogus_LOL is amazing
16:31_fogus_It will melt your mind
16:31mebaran151I often has to spend a lot of unpacking his stuff
16:32mebaran151heh, skimming, it looks like a real tome of a macro book
16:36tomojLOL is a book/
16:36tomoj?
16:37mebaran151http://letoverlambda.com/index.cl << it's got an ISBN
16:41Licenser_fogus_: I bought JoC the other day :) great book!
16:41tomojand VIP codes? O_o
17:11raekwhen is it idiomatic to use 'rest' and 'next'?
17:12arohnerraek: when you need to
17:12arohnerraek: sorry for the sarcastic answer. Do you think you're in a situation where it's un-idiomatic?
17:12islonnext: when testing (if (next coll) stuff other-stuff)
17:12raekwhat I wonder is which should I use?
17:12islonnext is test-friendly (returns nil on an empty list)
17:13raekyes, I know about next calling seq on the result
17:13raekso it becomes nil if it empty
17:14islon(next [1]) => nil
17:14raekI've seen next being used outside tests
17:15raekbut that was in clojure.core
17:15raekmaybe rich just replaced all rest calls with next calls when these things changed
17:16raekcould one consider 'rest' to be the standard choise when nil-on-empty doesn't matter?
17:18programbleanyone else interested in CSS support in Hiccup?
17:22ysphprogramble: a clojure CCS lib would no doubt be useful, what's the reasoning behind including it within hiccup? just that html and css are strongly coupled?
17:22programbleyes
17:23programblehttp://github.com/programble/hiccup
17:23programblei added in CSS rendering
17:23programbleand it seems a little too small to stand as its own project
17:23programbleits only about 20 lines of code
17:30onkarahi Guys ... I am having hard time configuring clojure REPL shell with command history and tab completion functionality
17:30onkaracould anyone please point me to a resource that can help with this ... FYI i am on ubuntu-lucid
17:31hiredmandunno about tab complete, but rlwrap will get you history
17:31onkaraand whats the best way to save the code snippets (that have been tested in a shell) to a file
17:32cemerickonkara: most good environments (emacs/slime, netbeans/enclojure, and eclipse/ccw) all provide completion
17:33programbleemacs/slime is great
17:33arkahnwe need the clojure equivalent of ipython ; )
17:34technomancyI think the CLI integration is bad on purpose in order to convince you to get your editor set up more quickly.
17:35arkahnit's not a bug, it's a feature, huh? ; )
17:36onkaracemerick: ccw is counter clock wise plugin the one hosted at code.google.com ???
17:36programbleemacs/slime/swank ftw
17:37LicenserI'd like to ask if someone could look at some small function ( http://gist.github.com/423027 ) it is meant to find the key that changed in a hash-map (so the lowest when there are multiple changes that holds all of them)
17:37LicenserI know it's not optimized I am just looking for correctness or total stupidity
17:40KirinDaveLicenser: For starters, do arg validation in pre and post
17:41KirinDaveLicenser: It'll be way clearer
17:42TimMcCCW is pretty grungy.
17:42KirinDaveLicenser: Secondly, wouldn't a quick first check be to compute the hashcode for each of the maps and compare? You could save a lot of work.
17:44hiredmanI think pre and post conditions only run when a certain var is bound
17:44KirinDavehiredman: ?
17:47hiredmanclojurebot: git commit 0ac482878a1dd520cbee2faa0f5f6ab1082ffa76
17:47hiredmanclojurebot: git 0ac482878a1dd520cbee2faa0f5f6ab1082ffa76
17:47clojurebot:pre and :post conditions as metadata on arglist, or map following arglist conditions are predicate exprs in a vector return value of fn is bound to % for :post (defn foo [x y] {:pre [(even? x) (< x y)] :post [(> % 3)]} (* x y)) add *assert*, default true, when not true asserts are no-ops *assert* is bound in repl
17:48hiredmanso if you always want to validate you can't use :pre and :post
17:48LicenserKirinDave: I think = does the hash code stuff
17:48Licenserand I'm not sure what you mean with arg validation
17:49hiredman(I'm assuming you mean :pre and :post when you said pre and post)
17:49ataggart(defn constrained-sqr [x]
17:49ataggart {:pre [(pos? x)]
17:49ataggart :post [(> % 16), (< % 225)]}
17:49ataggart (* x x))
17:49Licenserbut I don't want the function break when it is not a map
17:50ataggartfrom http://clojure.org/special_forms
17:50hiredmanataggart: yes, and those will only run if *assert* is true
17:50hiredmanwhich it is at the repl, but not other places
17:51ska2342Hello. Can someone tell me how I can access the docstring of a method defined in a defprotocol? I only see the doc metadata in the map that is the protocol itself. I'd expect `doc' to just work.
17:52hiredmanhuh
17:53hiredmanlooks like the default value of *assert* is true
17:53hiredmanor root I should say
17:54ataggarthiredman: the deeper question is whether such checks are properly assertions or input validation. For the latter a different mechanic would be used
17:55ataggartassertions should be disableable (is that a word?)
17:55hiredmanwell, input validation ittself is a loaded term
17:55ataggarttrue
18:16cemerickonkara: yes, ccw is counterclockwise @ google code
18:17timcharpercan lazy seqs eagerly load in a separate thread ?
18:17timcharper(do they?)
18:18timcharperbuilding a somewhat-long stream pipeline, and would be super sweet if each step of the pipeline could be processed simultaneously
18:20technomancytimcharper: you could use futures, but it's not transparent.
18:21timcharperok, willing to abstract here
18:21timcharperhow would I go about abstracting a lazy seq to eager load using futures ?
18:22technomancytimcharper: just wrap your calculation in (future [...]) and deref it when you want to use it. easy peasy.
18:23timcharperah... so that won't cause the whole lazy seq to load all at once because lazy-seq only reads a few ahead ?
18:23mebaran151any tips on setting up a slime environment that can connect to both sbcl and clojure proper?
18:24timcharpermebaran151: A) first, use technomancy's starter kit. B) add the proper swank dep to your project using lein
18:25timcharperoh... A2) install swank-clojure from ELPA (via m-x package-list-packages)
18:34timcharpertechnomancy: so with the future wrapping, not only will each step of my pipeline be processed in parallel, but each iteration of each step will be processed in parallel, right ?
18:35timcharper(my understanding of clojure leads me to that conclusion)
18:35technomancytimcharper: think of a future as an agent that you can only set once
18:35technomancyrather than an identity with a series of values over time.
18:35timcharperand, one, according to my benchmarks, is much faster than agents
18:36technomancyhow you consume a seq of futures will determine how things are processed.
18:36timcharperawesome, that's a neat trick. Thank you
18:39onkaraCCW rocks
18:48cemerickonkara: oh? What's the best part so far?
18:56mebaran151timcharper: I've got a working clojure env with lein swank (and swank-clojure from elpa is officially unsupported based on the net's whisperings)
18:56mebaran151I'd like to run some of these examples in let over lambda, but I need SBCL to do so
18:57vIkSiTdid technomancy post about that somewhere?
18:59mebaran151I remember the old days when I could just run m-x slime to get a clojure repl, but modern emacs doesn't like this; slime-connect works fine though
19:03timcharpermebaran151: I am using swank-clojure 1.1.0 and clojure-mode 1.7.1. slime-connect works great for both clojure 1.2 and 1.1.
19:03mebaran151when I had swank-clojure installed C-c C-k didn't work
19:04mebaran151complained about bad arities: I was advised to move to swank-clojure 1.2.0 and launch slime via lein swank
19:04timcharperstrange... works here
19:04mebaran151are you using slime-connect or plain slime?
19:04timcharperslime-connect
19:04mebaran151slime-connect probably works, because your project is loading a modern swank implementation
19:05timcharperfor clojure 1.1, I am using this: [leiningen/lein-swank "1.0.0-SNAPSHOT"]
19:05mebaran151try just M-x swank-clojure-project
19:05timcharperI use that too
19:05mebaran151hmm, I got weird Java errors
19:05timcharperhmmmm
19:05mebaran151oh yeah, what version of slime do you run?
19:05timcharper20091016
19:06mebaran151new slime isn't as good as nicely aged slime
19:06mebaran151there we go
19:06mebaran151now we've got something
19:06mebaran151I'm on 20100404
19:06timcharperhmmm, I'm seeing I can upgrade. Now that you say it's no bueno, tempted to not
19:07mebaran151I had to because I upgraded my workstation
19:07mebaran151installed some new Linux love
19:07mebaran151Ubuntu Lucid!
19:08timcharperhurray for bleeding edges!
19:08mebaran151yeah, the upgrade is a little nasty
19:08timcharperlol
19:08mebaran151new swank though has some cool functions like breakpointing with local variables
19:08mebaran151which I like alot
19:08mebaran151(swank.core/break) is my friend
19:08timcharper_REALLLY_
19:09timcharperthat rocks! you don't have to patch clojure for it to work?
19:09mebaran151only Clojure 1.2
19:09mebaran151has the magic sauce I think
19:09timcharperwill have to give that a spin. Lack of debugging tools has been somewhat of a sore-spot for clojure
19:09mebaran151well it's still not like netbeans, where I'd click a line
19:10timcharperdoes netbeans work though?
19:10mebaran151but a real breakpoint line with locals inspection is nice
19:10timcharper(I couldn't get it to)
19:10mebaran151when netbeans works it works pretty well
19:10KirinDaveBlog article I'm about to post about clojure and prototypes
19:10KirinDavehttps://gist.github.com/raw/2349be16daab2a02cba6/4a2f3b463b95b97ae696b5083309f81c235376ec/post-draft.txt
19:10mebaran151I was on 6.8 before I got addicted to paredit
19:11timcharperparedit is great
19:11mebaran151the repl was nice and friendly, and java completion _mostly_ worked
19:12timcharperhave you installed highlight-parens for emacs ?
19:12mebaran151yeah I think I have
19:12timcharperI really like it
19:12timcharperthe end
19:12mebaran151but not rainbow-parens
19:12mebaran151that was ugly
19:12mebaran151well clojure netbeans had highlight parens built in
19:12mebaran151decent formatting
19:13mebaran151but it was finicky and would often die for reasons I could never resolve
19:13timcharper(I use highlight-parens and customized it to be rainbow... looks decent)
19:13tomojwhoa.. never saw highlight-parens before. cool!
19:13timcharper'(hl-paren-colors (quote ("#ff2244" "#ff7700" "#ffff00" "#00ff00" "#2266ff" "#00aaff" "#ff00ff" "black")))
19:14mebaran151I think that Emacs needs a major update, though it's the best editor I've used yet
19:14mebaran151it knows how to get out of your way
19:14mebaran151it's kind of sad the best editor we have comes from the 70's
19:15mebaran151especially for mulitdocument editing, I think it could do better (though I don't know emacs lisp well enough to fix anything)
19:15timcharperemacs-lisp, in my opinion, is a terror
19:16timcharper(I've written a few emacs extensions)
19:16mebaran151I've often though it might be cool to write an emacs clone in Java and Swing
19:16mebaran151*thought
19:16timcharperyeah... and clojure ?
19:16mebaran151something you could script a little more sanely in Clojure
19:16mebaran151yeah, and Clojure
19:17mebaran151maybe mostly Clojure, but Swing components are so so brittle
19:17timcharperI think an emacs rewrite in clojure would be the coolest thing since sliced bread
19:17mebaran151well it wouldn't run emacslisp, because that would be annoying
19:17timcharperheh.. it might include an emacs-lisp emulator
19:18timcharperto help with the transition
19:18KirinDaveIt'd be a bad idea
19:18mebaran151Clojure really needs a programming envirionment written in Clojure
19:18timcharperemacs-lisp is really primitive, it'd be easy to implement an interpreter
19:18KirinDaveElisp's biggest limitation is that it thinks about editor things with a very dated model
19:18KirinDavebuffers, frames, etc
19:18mebaran151KirinDave: exactly
19:19timcharperKirinDave: But why couldn't you map it?
19:19tomojwhat's a better model?
19:19mebaran151it has no concept of buttons or controls that could make things a lot easier
19:19tomojbuttons? pff
19:19tomojlike, ones that you hit with the mouse, I assume?
19:19mebaran151or interactive text within text
19:20timcharpermebaran151: it has a concept of overlays that have click actions
19:20mebaran151oh overlays are interesting
19:20mebaran151but not just click, I'm talking about demarcating regions of text and rendering different things appropriately
19:21tomojdoesn't emacs demarcate regions of text and render different things appropriately?
19:21mebaran151kind of
19:21vIkSiTKirinDave, do you have a non raw version of that blogpost?
19:21mebaran151I mean everything is in nice terminal 1980's style
19:21mebaran151you couldn't exactly create a pretty IDE with Emacs :)
19:21tomojI wonder if I really like it that way
19:22tomojI certainly _feel_ like I wouldn't want the clojure-scriptable editor to be a pretty IDE
19:22tomojbut maybe emacs has just brainwashed me
19:22timcharperyes: I prefer a scriptable editor that has IDE-like components. Editor first.
19:22mebaran151that's probalby the only thing TextMate got right
19:22timcharperby IDE-like components I mean extensions
19:23timcharperTextMate got many things right
19:23mebaran151I was also thinking of a IDE that edited code rather than files
19:23mebaran151kidn of like smalltalk
19:23mebaran151that could perhaps just export the project
19:23mebaran151into something that lein or maven would jar up
19:24mebaran151instead of representing everything in terms of files, it would work in terms of a program graph, and you'd manipulate that tree, like a pervasive version of paredit
19:25mebaran151you could do ns refactors and stuff like that
19:25timcharperand then all of your source control systems would work marvelously with it
19:26mebaran151well save would be bound to export as files
19:26tomojI don't see the point in ignoring the code<->file mapping while editing, especially since it's a pretty simple mapping in clojure
19:26vIkSiThmm has anyone here used defrecord?
19:27mebaran151for one thing makes merging harder
19:27vIkSiThttp://paste.lisp.org/display/111083
19:27vIkSiTHow do I get my push function to return a record of type FStack?
19:27timcharperI think a Text Editor that can understand the language syntax (as with lisps) is a better way to go.
19:27tomojyeah
19:28tomojI think we need a cleaner compiler
19:29mebaran151I think most version control systems suck because they don't understand what they're comparing
19:29mebaran151it's bytes to bytes
19:29mebaran151where as if they were merging syntax trees, lots of things might make more sense
19:29timcharperis there any reason you couldn't extend a source control system to understand syntax trees when resolving conflicts?
19:29tomojbut can't we merge syntax trees anyway without pretending code isn't in files?
19:30mebaran151timcharper: I once decided I'd hack mercurial: I failed
19:30tomojmerging syntax trees sounds pretty dangerous to me
19:30timcharperif you have a specialized source control system, it will be great for that code, but generally suck for everything else
19:30mebaran151tomoj: merging syntax trees sounds like the lisp macro way of handling merges
19:30mebaran151where as straight merging is more like a C preprocessor
19:30mebaran151that blindly smashes text
19:30tomojexcept I think it's very likely the merge results will usually not make any sense
19:31mebaran151why would it make any more or less sense than a merge that worked on bytes?
19:31technomancyonce threads get merged to mainline, Emacs bytecode could be a semi-reasonable Clojure compilation target. way easier than a rewrite.
19:31tomojmerging diverging histories of a lisp form correctly (so that the lisp program actually does something useful) seems like a problem for humans
19:32mebaran151tomoj: I at least think the diff program might be easier to work with
19:32mebaran151I find myself usually blindly clicking my way through merges
19:32timcharpermebaran151: agreed: the suggested merges would be easier to understand. But I still think you can use an underlying SCM, such as git, to achieve such an end. git-merge-tool, for example, allows you to specify a custom merge resolution tool
19:32mebaran151getting a bad file, and then taking the old file, merging it by hand by copy and paste, and resubmitting that file as the Final one
19:33timcharperit could be done with the current flexibility of git
19:33tomojit bugs me that mvn clojure:swank tries to compile stuff
19:33timcharpertomoj: try lein swank ?
19:34tomoj:P
19:34timcharper(git was originally meant to be a platform which you could use to develop an SCM)
19:34mebaran151timcharper: I'm not git expert: we usually use mercurial over where I work
19:34timcharperseveral emerged, and then one of them became standard
19:35timcharpermebaran151: so sorry...
19:35mebaran151because of some windows developer guys; git used to be hell to make run on Windows
19:35timcharper:)
19:35mebaran151hg is pretty good, actually
19:35timcharper(I kid, I kid... I know
19:35timcharper)
19:35mebaran151heh
19:35timcharperI started out with git and have devoted time to learning it inside out. I really love it, but understand it has it's warts.
19:36mebaran151still, an editor shouldn't need to use files for everything
19:36mebaran151you could emulate that behavior with a sufficiently clever version of save as
19:37mebaran151one should save a project rather than a file
19:39Licenserwhat is wrong with this code:
19:39Licenser,(update-in {1 2 3 4} [] assoc 3 5)
19:39clojurebot{nil {3 5}, 1 2, 3 4}
19:39tomojvIkSiT: still stuck?
19:39Licensershouldn't that be {1 2 3 5}
19:39mebaran151if you kept track of the version of entities rather than of tiles
19:39vIkSiTtomoj, yea :)
19:39mebaran151you could mix and match the old and the new
19:39tomojyou have "Fstack." instead of "FStack."
19:40mebaran151maybe even pull up old versions for a visit to see what got broken
19:41tomojLicenser: what exactly are you trying to do?
19:41tomojif you want {1 2 3 4} -> {1 2 3 5}, why not just (assoc m 3 5) ?
19:41Licenserupdate a map by a given path that does not work if the path is empty
19:41LicenserI think that is a bug in update-in
19:41Licenserunless there is some special thought of that
19:41vIkSiTtomoj, *ARGH*
19:41tomojyeah, seems like it should error out
19:41vIkSiTthanks :)
19:41Licensertomoj:
19:42Licenser,(get-in {1 2 3 4} [])
19:42clojurebot{1 2, 3 4}
19:42Licenseracts as expected
19:42tomojthat's not really what I would expect
19:42tomojwell, yeah, I guess it makes sense
19:43tomojLicenser: seen the source for update-in?
19:43Licensernope
19:43tomojit is assumed that you will pass at least one key
19:43Licenserhmm
19:43tomojit destructures the path like [k & ks]
19:44tomojand checks whether ks is nil or not to decide whether to recur
19:44tomojbut for you, k is nil, so
19:45Licenserhmm yes but it is kind of not intuitive
19:45Licenserin my eyes at least
19:45tomojdoing anything at all with [] seems unintuitive to me
19:45tomojyou think it should pass the whole map to your function, I guess?
19:46tomojagain I guess that does make sense.. :)
19:46tomojjust never thought about it before
19:50vIkSiThmm how would a purely functional pop work?
19:50vIkSiT(w.r.t stack)
19:51vIkSiTshould it return the value of the popped element, or should it return the changed stack?
19:51tomojyou need two functions
19:51tomoj(or return both, but..)
19:51vIkSiTlike a "top" and "pop"?
19:51tomojyes, like first and next :P
19:52vIkSiThehe but how do you return *two* things?
19:52tomojin a vector or something
19:52tomojbut that's ugly
19:52vIkSiTurgh, thats ugly
19:52tomojlists are already stacks, aren't they?
19:52vIkSiThmm
19:53vIkSiTyes they should be
19:53Licensertomoj: it is about when you don't have a fixed path you want but one that is passed or constructed
19:53vIkSiTand the behavior there is to return the (rest coll)
19:53tomojLicenser: yeah, it just took me a while to understand, but I think you're right
19:53Licensertomoj: or at least make get-in behave the same :P
19:53tomojvIkSiT: but we also have first
19:53Licenserbecause it is really confusing otherwise
19:55tomojvIkSiT: push pop peek, maybe?
19:55vIkSiTyes, I've got push, pop working
19:55vIkSiTnow to figure out peek
19:55vIkSiTas in, for the other two I can do (swap! my-stack push val) and (swap! my-stack pop)
19:56vIkSiTwrapped the stack around an atom
19:56vIkSiTbut peek is read only
19:56mebaran151you know, vectors already implement peek pop and push (under conj)
19:56tomojis this just an exercise in protocols/records? just curious
19:56vIkSiTand If I use swap there, its going to override my stack with the top value!
19:56mebaran151it might be weird you start from the bottom, but I don't see any problem with that
19:57tomojvIkSiT: just peek before you swap, then
19:57vIkSiToh yes, its an exercise.. I'm going through Okasaki's purely functional data structures
19:57tomojah, cool, then
19:57tomojare inductive graphs in there, I wonder?
20:01tomojwouldn't it be cool if there were an easy way to proxy all of an interface's methods to a field of a deftype?
20:02hiredmanif you have your queue in a ref, then you can compose multiple operations peek/pop/etc in a transaction
20:02hiredmantomoj: macro
20:03hiredmanoh
20:04tomojoh, with an atom, I guess there is no way to peek+pop atomically?
20:05tomoj(unless you do something silly like a function which returns a vector tuple with the first/next..)
20:06vIkSiTah, I guess I could convert that to a ref
20:19vIkSiTif only Okasaki used lisp to implement the structures in his book :)
20:19tomojwhat is it, haskell? ML?
20:22vIkSiTboth actually
20:23vIkSiTprint version has ML, and addendum with Haskell code
20:24tomojah
20:24tomojyeah the paper about inductive graphs I found is haskell, too
20:24tomojpain to translate
20:25vIkSiTI've had to jump into SML for that
21:23lancepantzanyone know of a function in core that is similar to filter, but will return two collections, one for which the predicate is true, the other false?
21:26lancepantzlooks like group-by is what i want
21:31AntonyBlakeyanyone know why this:
21:31AntonyBlakey(defmacro action-guard [name]
21:31AntonyBlakey (let [method-name (symbol (str "can-" name))]
21:31AntonyBlakey `(do
21:31AntonyBlakey (defmulti ~method-name (fn [ctx# module#] (-> module# :workflow :state)))
21:31AntonyBlakey (defmethod ~method-name [ctx# module#] false))))
21:31AntonyBlakey(doseq [x '[edit reassign submit approve reject reedit delete]] (action-guard x))
21:31AntonyBlakeyfails with: "Unable to resolve symbol: ctx__3472__auto__ in this context" in the doseq ?
21:33AntonyBlakey(regardless of the missing :default dispatch value on the defmethod)
21:43AntonyBlakeyAh, stupid me. :default in the wrong spot in the defmethod.
21:54ataggartlancepantz: split-with
22:09arohnerin compojure 0.3, there was a function url-params. Does anyone know where that went in ring / compojure 0.4-land?
22:11Raynesarohner: What did it do?
22:12dsantiagoarohner, I think it is not in 0.4, but it should probably be in hiccup.page-helpers.
22:12arohnerRaynes: it constructed the URL parameters for a link, given a map i.e. (url-params "google.com" {:a 1 :b 2})) => "google.com?a=1&b=2"
22:13dsantiagoI'd email James Reeves and say you want it. :)
22:13AntonyBlakeyThere was a library published recently with generic url-construction facilities
22:14arohnerAntonyBlakey: do you know the name of it?
22:14AntonyBlakeyjust looking in planet clojure
22:15Raynesarohner: I wrote a function for that a few days go and put it in clojure-http-client. It's small, and I believe Phil renamed it to add-url-params or something similar. You can steal it if you'd like.
22:15AntonyBlakeyhttp://github.com/paraseba/resource-url
22:15arohnerRaynes: thanks. I'll probably just pull the fn out of compojure 0.3.2 and publish a patch for hiccup
22:16RaynesNot sure it belongs in hiccup. Maybe you should ask weevy why he removed it and throw it into ring or something.
22:17arohnerAntonyBlakey: interesting. thanks
22:18dsantiagoYeah, in my experience some things were just lost in the reorganization. He's been pretty responsive about putting things back in.
22:18dsantiagoI'm not really sure why you want that function, if not to generate a URL for a link. It was in page-helpers in 0.3.
23:22redalastorI'm looking for the name of a function I know exists. It takes a function and value, applies the function to the value and applies the function again to the result of that, lather, rinse, repeat.
23:29tomojiterate?
23:29redalastorYes!
23:29redalastorThanks