#clojure logs

2011-05-16

00:09alandipertanyone know off-hand the origin of take-while/drop-while? ML, miranda, other?
00:50stirfooDid (read) and (read-line) work with slime/sbcl? It's been a while, but it seems like it did. What needs to be done to get those to work with swank-clojure?
00:51amalloystirfoo: i think it's an issues caused by ant
00:54stirfoois ~/.lein/bin/swank-clojure using ant? I know nothiing about ant :(
00:54amalloyi don't either, really
00:54amalloybut technomancy says ant swallows his stdin
00:59technomancythe one in ~/.lein/bin avoids ant
00:59technomancyI have a cunning plan for getting stdin working in regular swank too
00:59technomancyhttp://p.hagelb.org/plan.jpg
00:59stirfootechnomancy: but the repl still blocks if I try (read) or (read-line)
01:00stirfootechnomancy: ahaha
01:00technomancyif read-line breaks in ~/.lein/bin/swank-clojure it's a different problem
01:00technomancyprobably worth opening an issue
01:01stirfooRET after entering say "foo" just sits there
01:03stirfootechnomancy: is *slime-events* relevant to swank-clojure? like (swank:listener-eval "(read-line)\n")
01:03technomancystirfoo: I don't think it's meant for user consumption.
01:05technomancyactually my other swank-related plan is much more cunning.
01:06technomancylooks like we may be able to bootstrap slime, durendal, and slamhound with nothing more than leiningen and clojure-mode.
01:06technomancyhmmmm!
01:07sexpbotjava.lang.Exception: EOF while reading
02:07ihodesI've got to say, while mathematica is great (and is an IDE Clojure would be lucky to have), it sure makes me miss clojure
02:28tomojshould a breadth-first search of a PEG grammar be too difficult?
02:37amalloythat depends on what you mean by "too difficult", "PEG grammar", and "should"
02:40tomojheh
02:40tomojI'm not, really
02:40tomojI mean, of a tree, sure
02:40tomojI'm not quite sure how to map a PEG into a tree of sentences
02:40tomojor, sentence structures I suppose
03:34amalloy~source require
03:37Fossi~source source
03:38Fossifunky way to read stuff
03:39Fossisomebody know why?
03:40amalloyhuh?
03:50Fossihaving the line and the pushbackreader i meant
03:52amalloyit's a bit gross, but since the reader doesn't maintain whitespace (and it shouldn't), there's no other obvious way to read the actual source with the whitespace it was given
03:54amalloyso it creates a Reader which, as a side effect of reading, appends to a local buffer, then reads one object with that reader
03:56Fossiwhich reader doesnt maintain whitespace?
03:56amalloythe clojure reader
03:56amalloy(1 2) is the same as (1 2)
03:57Fossiwhy is a clojure reader needed at all?
03:57amalloyhow else do you know how many lines the function you're reading takes up?
03:57Fossiah, now i see
03:58Fossiweird construct ;)
03:59amalloyif you have a better way, i'm sure someone would love to have it
04:00amalloyit would be possible to have :line-start and :line-end in the meta, but i think that just moves the problem somewhere else
05:21ilyakHas anybody had luck with clojure ant tasks?
05:21ilyakI have some bizzare classloader problems like and always has
05:22ilyakIt looks like that the taskdef is loaded in one classpath but is used in another classpath
05:22ilyaks/classpath/classloader
05:22sexpbot<ilyak> It looks like that the taskdef is loaded in one classloader but is used in another classloader
05:47opqdonut_has anybody done real tag generation for clojure? I mean using read or actually loading the ns and looking at what got defined?
05:58jamesswift$help
05:58sexpbotYou're going to need to tell me what you want help with.
05:58jamesswift$help eval
05:58sexpbotTopic: "eval" doesn't exist!
05:58jamesswift$help topics
05:58sexpbotTopic: "topics" doesn't exist!
05:58jamesswift$help commands
05:58sexpbotjamesswift: http://github.com/Raynes/sexpbot/wiki/Commands
05:59jamesswift$help evaluation
05:59sexpbotTopic: "evaluation" doesn't exist!
05:59jamesswift(+ 1 2 3)
05:59clojurebot*suffusion of yellow*
06:03jamesswift$(+ 1 2 3)
06:07jamesswift&(+ 1 2 3)
06:07sexpbot⟹ 6
06:07jamesswift&(not (empty? (clojure.set/intersection (set "test1") (set "1234"))))
06:07sexpbot⟹ true
06:08jamesswiftSo anyone can tell me if this is a good or bad way to determine if a string contains any chars from another string? (not (empty? (clojure.set/intersection (set "test1") (set "1234"))))
06:09opqdonut_i'd maybe go with (not (some (set "test1") "1234"))
06:10opqdonut_(not (some #(get (set "test1") %) "1234")) might be a bit more explicit
06:10opqdonut_err and here "test1" are the banned characters and "1234" is the (potentially long) string to be processed
06:14jamesswiftthanks
06:14jamesswifti guess some finishes on first match
06:14raekit does
06:14jamesswiftthanks again
06:14raek(it also returns it)
06:50opqdonut_wait what? keywords aren't symbols?
06:50opqdonut_(= :x (symbol ":x"))
06:50opqdonut_is false, while (= :x (keyword "x")) is true
06:50opqdonut_the problem is that the printed representation for (symbol ":x") is :x
08:27ilyakWhat's the clojure policy on - versus _ in file/package/namespace names?
08:28opqdonut_clojure namespaces tend to use -
08:29opqdonut_which gets converted to _ in (java) package names and filenames because of technical reasons
09:43the-kennyHello. What's the preferred way to do graphical stuff with Clojure? (Drawing onto a canvas, capturing mouse events etc.). I tried Processing-clj, but it's
09:43the-kennyWhops. Cont: not very pretty for bigger projects as it isn't even possible to load an image without passing the sketch-instance around.
09:57lchaplinwould you guys be interested in java jobs in general, or only clojure based jobs?
09:57TouqenJVM yes, java not particularly
09:58lchaplinTouqen: can you please elaborate?
09:59TouqenI think the JVM as a platform is pretty awesomesauce.
09:59TouqenI however am not a fan of java the language.
09:59lchaplinjvm as in java virtual machine?
09:59Touqenyes
09:59aavlchaplin: thread scheduling, garbage collection :)
10:00Touqendon't forget hotspot
10:00lchaplinTouqen: hmmmm. don't have such jobs atm :/
10:41ttmrichterlchaplin: Wouldn't you have better luck recruiting in ##java?
10:48gfrloglooks like (assert) is a bad way to validate user input
10:48chouserheh
10:48gfrlogI didn't even know java distinguished between Exception and Error :-/ you learn something new every time you learn that
10:57aavgfrlog: "For in much wisdom is much grief: and he that increaseth knowledge increaseth sorrow." :)
10:58gfrlogfirst time I've seen Solomon quoted in #clojure
11:07gfrlogdo we like that compojure is trailing-slash-sensitive?
11:12ejacksontechnomancy: is it a bug in leiningen (1.6.0) that lein uberjar leaves ./lib in a state different lein deps. Specifically w/o jars specified in :native-deps dependencies, or do I have the wrong end of the stick ?
11:16gfrlog(def print-once (memoize println))
11:19ejacksoni should clarify - the .so files from the native libs are extracted to ./native, as expected, but the native-deps jar contains within it normal jars, that make it into ./lib with lein deps, but not after lein uberjar :(
11:54technomancyejackson: it's probably a bug; can you open an issue?
11:54ejacksontechnomancy: shall do.
11:56technomancyejackson: keep in mind that I have never used any native libraries, so I'm depending on users to tell me their expectations to a degree.
11:57ejacksontechnomancy: no sweat. It also doesn't seem to bring in dev-dependencies as my swank-clojure gets wiped out after a lein uberjar.
11:57technomancyuberjars definitely shouldn't contain dev-dependencies
11:58technomancyalso, it may be possible to just place native dependencies in the regular :dependencies list and have them automatically get special treatment with a little more tweaking to lein.
11:58technomancythat's something Sam Aaron suggested to me
11:59technomancyI'm definitely interested in hearing what people want and what makes sense in this area though
11:59ejacksontechnomancy: that's a nice idea
12:00technomancymaybe some kind of jar-level metadata to signal special treatment
12:00technomancyalso I'd be glad to get more test case projects as well
12:02ejacksonOK, I'll see what I can do. Right now I'm a bit knotted with this :)
12:25ilyakI wonder if anybody ever wants working clojure-ant-tasks
12:47rlbIs this a reasonable way to flatten a map into a (k v ...) list: (interleave (keys x) (vals x))?
12:48dnolen,(apply concat {:a 'b :c 'd})
12:48clojurebot(:a b :c d)
12:50rlbdnolen: ahh, right, thanks.
12:53gfrlogrlb: also I think your way is not reasonable, as I don't believe there's a guarantee that (keys) and (vals) return in the same order
12:53technomancyactually it's guaranteed for any given map
12:54gfrlogtechnomancy: is it? I figured it probably DID return in the same order, but didn't expect it to be in the method contract
12:54amalloyit is guaranteed
12:54gfrlogthe best way to learn is to assert stuff and see if you get corrected
12:54amalloyheh
12:54technomancyyeah, and it really should be mentioned in the docs
12:54amalloy100% agree
12:55amalloyyou could also ##(mapcat identity {1 2 3 4})
12:55sexpbot⟹ (1 2 3 4)
12:55rlbgregh: good point -- I hadn't considered that (even if it's true).
12:55amalloyif you happened to want to do some more processing on the way, rather than identity
12:56rlbIn my case, apply concat works perfectly since I was already calling concat, and the map would be the final arg anyway.
13:00scgilardithese are coming out in order because they're small and constructed as an array-map. in general there's no guarantee about the order of the pairs returned by (seq my-map).
13:00scgilardi,(seq {:a 1 :b 2 :c 3 :d 4 :e 5 :f 6 :g 7 :h 8 :i 9 :j 10})
13:00clojurebot([:a 1] [:c 3] [:b 2] [:f 6] [:g 7] [:d 4] [:e 5] [:j 10] [:i 9] [:h 8])
13:01amalloyscgilardi: nobody asserted that there was
13:01amalloythe assertion is that (keys x) and (vals x) will be in the same order
13:02scgilardiI wasn't refuting an assertion.
13:02amalloyah. an educational aside, then? fair enough
13:07edw/Is/ it true that the output of KEYS and VALUES will be in the same order?
13:07scgilardiright, because it can be confusing when all example maps up to 8 k-v pairs do preserve the order from their construction.
13:07edwAh, so the answer is "no"...
13:07scgilardiedw it is true. because for a given map, (seq the-map) has a deterministic order and keys and vals are both based on first constructiong that seq.
13:08edwAh. OK. So the answer is "yes".
13:09amalloybut the answer is yes
13:10edwAnd here's where I should consult the docs, but...: Is that a guarantee of the implementation or just something that's true for now?
13:10amalloybut eg if you do something crazy like gather the keys, then assoc a new item, then gather the values, they won't necessarily match at all)
13:10amalloyedw: my understanding is: it's a guarantee, but one that's poorly documented
13:10edwamalloy: But then it's not the same hash...
13:10amalloyhence "something crazy like"
13:12gfrlogamalloy: what's the difference between a poorly documented guarantee and an artifact of the implementation?
13:13amalloygfrlog: rich
13:14amalloyor stu or...someone on the clojure.core team who's said it'll stay that way
13:14edwamalloy: I would argue that you don't want to guarantee it, because it encourages inefficient code like (map #(... %1 %2) (keys foo) (values foo)).
13:15timvisherhey all
13:15timvisherany clojure lib for url sanitation?
13:16amalloyjava.net.UrlEncode, i think?
13:16amalloydepending on what you mean by "sanitation"
13:16edwWhat do you want to do? Parse a URL? Create a canonical URL?
13:16gfrlogI agree that the (keys) (values) thing seems shaky either way
13:17timvisherI want to include a name in a url that might include any character valid on the filesystem (at the very least '?') and i'm running into issues passing that to a url
13:17timvishersomething like `Warcraft3-b&w-1024_1024x768.bmp`
13:18timvisheror `And%20the%20Winner%20is?_1366x768.png`
13:18amalloyedw: inefficient, but not very. it allows easier code like (zipmap (map inc (keys m)) (vals m)), instead of (into {} (for [[k v] m] [(inc k) v])), which can be easier to think about depending on what you're doing
13:18edwtimvisher: In JavaScript, at least, there's an "encode URL component" procedure that's distinct from a "encode URL string" procedure in that it escapes more chars e.g. question mark, equals
13:19edw...and ampersand. Look for something like that. It's pretty common,
13:20timvisheredw: i know exactly what you're talking about. I use that all the time
13:20amalloy$google java net url encode
13:20sexpbotFirst out of 274000 results is: URL (Java 2 Platform SE 5.0)
13:20sexpbothttp://download.oracle.com/javase/1.5.0/docs/api/java/net/URL.html
13:20timvisheri need this to be server side
13:20amalloyhttp://download.oracle.com/javase/1.5.0/docs/api/java/net/URLEncoder.html
13:20edwamalloy: True. I'm the sort of anal programmer, however, that binds nearly anything I use more than once in a given scope. I program like CAR and CDR require communicating over the wire to a distant continent.
13:20jarpiaingfrlog: we have word of rhickey, http://clojure-log.n01se.net/date/2010-01-18.html#17:09
13:21amalloyedw: sure, me too. though i like to try to use HOFs instead of actually creating local bindings
13:21pdkcpu cache to main ram is a distant continent!
13:21edwtimvisher: So does that do what you want?
13:21amalloybut it's nice to have multiple ways to do something
13:22edwamalloy: True again. Sometimes you just want to club your problem to death. It's OK.
13:22amalloy*laugh*
13:22ataggarttimvisher: ##(java.net.URLEncoder/encode "Warcraft3-b&w-1024_1024x768.bmp" "utf-8")
13:22sexpbot⟹ "Warcraft3-b%26w-1024_1024x768.bmp"
13:23timvisheredw amalloy ataggart: yeah. i was hoping for some shiny clojure lib, but that does indeed do the trick.
13:23amalloytimvisher: someone's wrapped this up somewhere, but it's not worth the effort of looking for it
13:23ataggartit's probably baked into one of the many libraries
13:23edwtimvisher: Yes, I also interpret mixed case symbols with periods as errors.
13:23amalloyclojure takes the stance that if there's something perfectly serviceable in java, just use it
13:24ataggartat least until someone gets around to writing something more clojure-y, e.g., clojure.string
13:24timvisheredw: indeed. i'm trying to avoid sanitizing the file names if i can, just because i think i can avoid that and it's not a core part of this app
13:24ilyak,(.contains (java.util.Collections/singleton "a") "a")
13:24clojurebottrue
13:24ilyak,(contains? (java.util.Collections/singleton "a") "a")
13:24clojurebotfalse
13:25ilyakwtf? why is that?
13:25ataggartcontains?
13:25clojurebotcontains? is for checking whether a collection has a value for a given key. If you want to find out whether a value exists in a Collection (in linear time!), use the java method .contains
13:25edwamalloy: We're in the real world, so my Schemely obsession with orthogonality and clarity is misplaced, but the interaction of #(...) and the Java candied glue sometimes bites me in the buttocks.
13:25ilyak,(contains? #{"a"} "a")
13:25clojurebottrue
13:25ilyakI am rather annoyed that clojure treats java sets as second class citisens
13:25ilyakThis is wrong wrong wrong
13:26ataggartilyak: contains? just doesn't mean what you (or most people) think it should mean
13:26ilyakataggart: Why does it work on #{} then?
13:26ataggartilyak: contains? is a check to see if calling get will return a value from the container
13:26ataggarte.g. ##(contains? [1 nil 3])
13:26sexpbotjava.lang.IllegalArgumentException: Wrong number of args (1) passed to: core$contains-QMARK-
13:27ilyakAnd besides, if (or most people) sounds like language design error
13:27ataggarte.g. ##(contains? {:a nil} :a)
13:27sexpbot⟹ true
13:28ataggartilyak: yes, it seems a weekday doesn't go by that someone doesn't ask about it
13:28ataggartuse some intead
13:28ataggart,(some #{:a} [:a :b :c])
13:28clojurebot:a
13:28ilyak,(some (java.util.Collections/singleton "a") "a")
13:28clojurebotjava.lang.ClassCastException: java.util.Collections$SingletonSet cannot be cast to clojure.lang.IFn
13:29ataggart,(doc some)
13:29clojurebot"([pred coll]); Returns the first logical true value of (pred x) for any x in coll, else nil. One common idiom is to use a set as pred, for example this will return :fred if :fred is in the sequence, otherwise nil: (some #{:fred} coll)"
13:30technomancyilyak: it's a badly-named function, no question.
13:30amalloyataggart: i'll schedule you an appointment at 3:00 to explain how you can get a stackoverflow using lazy-seqs
13:30ataggartha!
13:31technomancyhehe
13:31ataggarttechnomancy: contains? is a great name if you're only thinking about sets, which apparently was the case
13:32ilyakAlso, am I the only one person who finds the pair (empty? not-empty) ridiculous?
13:32amalloyilyak: yes. they are different things
13:32ilyakhow about pair (empty not-empty)
13:32ataggartone is a predicate, the other converts empty collections to nil
13:33ilyakwhich are also different things which also smells of a design failure
13:33scgilardiI translate "contains?" in my head to "contains-key?"
13:33ataggartI translate "contains?" in my head to "will get return me a value that's actually in the collection (including nil)"
13:34gfrlogI translate "contains?" in my head to "don't use that function"
13:34timvisherthanks for the pointer everyone, sorry for the googleable question. that worked perfectly.
13:35amalloynp, #clojure is just a cluster of google AI machines anyway
13:36hiredmanlike, if I have a an atom that is a cache, (swap! cache [some-value] (fn [cache] (if (contains? cache some-value) cache (assoc cache some-value ...))))
13:36amalloytechnomancy: yeah, not-empty is a nice pair for if-let
13:36technomancyclojurebot: you're a replicant, aren't you?
13:36clojurebotPardon?
13:36technomancydenial—just as I suspected.
13:37amalloysince we're complaining about the language today, i wish sets returned true instead of returning the value
13:38amalloyso that i could do stuff like (filter #{false} [true false]) to look for false items
13:39ataggart,(filter false? [true false])
13:39clojurebot(false)
13:39amalloyataggart: yes, yes. special cases are easy
13:39ataggartheh
13:39gfrlogamalloy: and I wish more side-effect functions returned their arguments instead of nil
13:39amalloy&(filter #{false 1} [true 65 1 false])
13:39sexpbot⟹ (1)
13:39ataggartyeah, dealing with logical-false values can get funny
13:40ataggartsame with nil values inside collections
13:43amalloyataggart: my use case would be easier if sets returned true rather than the element, and i can't think of a case when i've needed to rely on (#{some set} x) returning x
13:44amalloythough i did do well in a code-golf context for using keep instead of filter, when using a set
13:46ataggartI guess it's one of those cases where you need to use a custom pred, e.g. #(or (#{...} %) (false? %))
13:49amalloyataggart: only if you know false is in the set
13:49amalloythe general solution is more like (filter #(contains? the-set %) the-coll-to-filter)
13:52jdsandersHi all, is this the best place for questions about clojure-contrib, or is there a separate room?
13:54jdsandersI'm playing around with the combinatorics library, specifically the subsets function
13:54jdsandersand I'm blowing out memory when trying to do a filter and count of subsets of a vector with around 30 entries
13:54jdsandersand I'm not sure why
13:54gfrlogjdsanders:
13:54jdsanderssince subsets is lazy, and filter is lazy
13:54gfrlogthere are a lot of them
13:55gfrlogoh
13:55jdsanderswhat is using the memory?
13:55gfrloghow many are you collecting?
13:55jdsandersis count actualizing the whole list?
13:55gfrlogyes
13:55gfrlogdon't count a big sequence :)
13:55jdsandersthere is no way to count a big sequence...?
13:55jdsandersI understand why the runtime may be long
13:55jdsandersb
13:55jdsandersut
13:56jdsanders count wouldn't need to hold onto head so it shouldn't need much memory no?
13:56gfrlogright
13:56gfrlogso if you don't have the head you'll be okay, just run a while
13:56gfrlogbe careful with things like (def my-seq (subsets ...)) vs (defn my-seq [] (subsets ...))
13:56jdsandershow do I make sure I don't have the head, I didn't think I would, but I guess I must
13:57jdsandersyeah I didn't def any of the sequences besides the original vector
13:57gfrlogjdsanders: just gotta be careful. if you link to some code we can look at it
13:57jdsanders(def numbers [ 1 2 3 ...
13:57jdsanders(count (filter #(< 4 (count %1)) (clojure.contrib.combinatorics/subsets numbers)))
13:58gfrlogjdsanders: on a side note, doing that manually will probably be much faster
13:59gfrlogwell. not probably. it will be much faster.
13:59jdsandersyou mean rather than grabbing all subsets and filtering, only getting subsets of size less than 4 in the first place?
13:59gfrlogalso there's a formula for it :)
13:59jdsandersah
13:59jdsandersyeah
13:59jdsanderswell I simplified my example
13:59gfrlogokay
13:59jdsandersbasically the anonymous function is replaced with something non-trivial
13:59gfrlogas long as you're aware of the number of total subsets...
13:59gfrlogokay
13:59jdsandersyeah for sure
13:59jdsandersthat's precisely why I thought clojure would be excellent with it
13:59jdsandersbecause of laziness
14:00jdsandersjust can't figure out how to throw away the memory I no longer care about :)
14:00gfrlogit looks good to me.
14:00rpgHas anyone used MCLIDE with Clojure? I was thinking about that as an easier path to starting up than using SLIME....
14:01jdsandersgfrlog: ok thanks, harumph!
14:01jdsandersi also have trouble using last rather than count
14:01jdsandersthough things working from the front are ok
14:02jdsanderswhich I suppose is the way "holding onto head" always manifests...
14:06tnovelliIs anyone working on a native x86 or ARM implementation of Clojure?
14:07tnovellior even LLVM...?
14:07pjstadignot as far as i know
14:07pjstadigi'm not sure it's even really on the radar
14:10tnovelliso CinC is basically about cleaning up the JVM implementation and making it easier to support .NET?
14:11hiredmanit's about self hosting, ensuring clojure provides a rich enough implementation to self host
14:12hiredmane.g. all the power and abstractions needed to write the runtime are available in the language
14:12tnovelliat least that'd make it easier to add a native code back-end
14:12hiredmani.e. I guess
14:12technomancyrpg: slime is about to be several orders of magnitude easier to set up.
14:12hiredman*shrug* people keep saying that, but there are no plans anywhere for a naitive backend
14:12tnovellispeaking of editors, anyone here use VIM for Clojure?
14:13hiredmannaitive code is just not a very good host
14:14tnovelliyou mean it's a lot more work :)
14:16hiredmantnovelli: I mean, you would need to implement half a buggy jvm, why bother?
14:16tnovelliI know Clojure really leans on Java, but it could be adapted to a C/POSIX environment, or anything really..
14:17hiredmantnovelli: doesn't come with gc, or a standard threading library, or java.util.concurrent, etc
14:17tnovellisuppose you don't want anything to do with the JVM, you just want a better Lisp.
14:17hiredmantnovelli: you would be better servered asking why you want nothing to do with the jvm
14:18rpgtechnomancy: My problem with the SLIME setup is setting up SLIME for Clojure without breaking SLIME for Common Lisp.,
14:18hiredmanthe jvm is a sweet piece of tech to be leveraged
14:19technomancyrpg: oh, ok. that's a lot harder.
14:19hiredmanpeople tend to have bad experiences with Java then ignore anything that starts with a J
14:19hiredmanthe jvm is not java, and gives you way too much as a platform to just ignore
14:19tnovellihiredman: I think bytecode VMs in general are an unnecessary layer. JVM, CLR, LLVM, Smalltalk, you name it.
14:20rpgtechnomancy: I use CL every day for the stuff that pays the bills, so breaking it is a problem for me.
14:20edwBut if only the face-palm inducing early design and implementation decisions with the standard classes could be quarantined or exiled...
14:20technomancyrpg: understood; swank just needs someone who's CL-savvy to step up and do the leg-work of making it compatible.
14:21hiredmantnovelli: what alternative do you propose then? compiling for each target arch seperately?
14:21tnovellihiredman: I'm speaking about principles here, not practical enterprisey programming.
14:21rpgtechnomancy: I think there's also the problem that SLIME doesn't have versioning, so it's hard to avoid getting at least one of CL and Clojure broken!
14:21rpg(i.e., no release versions)
14:21technomancyrpg: yeah, if they just released proper versions like the big kids this would be a lot easier
14:22technomancyrpg: that said, my upcoming hacks could let you use the CVS trunk version normally and then have the clojure-compatible version get loaded just for when you want to use Clojure
14:22technomancyso it would taint the instance, but it would work.
14:24hiredmantnovelli: what problem do you perceive that your principles address?
14:24tnovellihiredman: yes, you have a small 'kernel' of primitive functions to implement in assembly on any given platform, and write the rest in Clojure.
14:24hiredman:(
14:24ataggartimplementing a GC in assembly?
14:25hiredmantnovelli: why? what is the point? what do you gain from that, besides making it monumentally difficult to implement languages
14:25tnovellimaybe a bit of inline asm... you can write most of a GC in Clojure itself..
14:25dnolentnovelli: is there any language that you are aware of that uses your strategy that actually works across the heterogenous landscape of platforms?
14:26hiredmanthrowing away all of the optimizations the jvm does
14:26ataggarttnovelli: patches welcome
14:26tnovelliJVM is a shortcut. A perfectly legitimate one, but you're stuck with all of Sun's design decisions.. no tail recursion, etc.
14:26hiredmanit's just a horrible idea, but don't let that stop you from doing it, just use your own irc channel to discuss it
14:27tnovelliyeah, I didn't come here to argue. Just wondered if anyone here was doing it.
14:27tnovelliIt's a big project and I probably won't bother, but it's a thought.
14:27dnolentnovelli: everything besides the JVM would require 20 years of effort. See Haskell.
14:28tnovelliHaskell's an academic project. Different goals.
14:29hiredmanwhy?
14:29clojurebothttp://clojure.org/rationale
14:29hiredmantnovelli: -^
14:29dnolen_tnovelli: many people would disagree w/ that claim.
14:29dnolen_tnovelli: people are interested in seeing Clojure run elsewhere, but a lot of other things need to get lined up first.
14:29rpgtechnomancy: There's a guy at our user group who forked the SLIME and renamed all its functions, so that it could be used without tainting the instance.
14:30rpgtechnomancy: https://github.com/bigfoote/slclj
14:31technomancyrpg: I've thought of that. I guess I'm not totally ready to give up on upstream compatibility, but I'm also not ready to do the grunt work of making it work.
14:31technomancyif only elisp had modules =\
14:32edwtechnomancy: Sacre bleu! Then Emacs might someday not be the world's largest ball of mud.
14:33rpgtechnomancy: Isn't there a fair amount of work making clojure output masquerade as CL output?
14:35technomancyrpg: TBH I don't even know how much work it is. my knowledge of swank is pretty superficial
14:37hiredmanrpg: swank actually sends back something like (print "{:a 1}") which is valid for both clojure and cl
14:37hiredmanand emacs lisp
14:38rpgtechnomancy: OK, thanks. Anyway, you can see why I was hoping that I could just get MCLIDE to work...
14:38hiredmanthe only real munging is for namespaced symbols
14:38hiredmanswank-clojure has to do stuff like rewrite foo:bar as foo/bar
14:38rpghiredman: I was just typing "I had trouble where it would blow up for me with namespaced symbols..."~
14:39technomancyI'm a weirdo since I launch new emacs instances all the time, so the problem is a lot easier to solve in that case.
14:39hiredmanbut it doesn't even actually have to do that, just a design decision
14:40hiredman,foo:bar
14:40clojurebotjava.lang.Exception: Unable to resolve symbol: foo:bar in this context
14:40hiredmanvalid symbol
14:40tnovellihiredman, dnolen_: I see the part about VMs... the only part I disagree with is bytecode. There's an "abstract VM" idea, which might look sort of like core Lisp, like an uber-language (I'm not totally sold on that either)
14:41tnovelliAnyway, I'll definitely try some serious Clojure hacking under JVM before I seriously think about writing a compiler :)
14:42hiredmantnovelli: if you really want, I would suggest taking something like maxine and trying to rewrite it in clojure
14:42hiredman~maxine
14:42clojurebotmaxine is http://research.sun.com/projects/maxine/
14:43tnovelliwho'd Oracle buy that from?
14:43hiredmansun
14:43hiredmana long with the rest of sun
14:43pjstadigoracle bought sun!!?!
14:43tnovelliand are you at Oracle now?
14:44pjstadigthere's also jikes rvm or something
14:44hiredmanpjstadig: crazy, right?
14:44pjstadigsimilar project to maxine
14:44technomancypjstadig: you may want to sit down for this...
14:44hiredmanpjstadig: jamvm
14:44tnovelliJikesRVM, yeah.. wow :)
14:44hiredmanjikes is actually just a compiler, no?
14:44tnovellipretty sure it's a VM
14:44pjstadigeh no there's a vm project
14:45tnovelligrew out of a parser project 20 years ago, apparently
14:46pjstadigtechnomancy: i kno... next you'll be telling me that M$ bought Skype or something
14:46edwThere was a recent article linked to from Hacker News that discussed the GC styles of the three major JVMs: Hotspot, WebLogic, and the IBM one...
14:47opqdonut_what, is Jikes still alive?
14:47opqdonut_or is "the IBM one" for their mainframes
14:49edwHold on...
14:52tnovellilooks like Jikes is still maintained, and parts (like the GC) have been extracted
14:53edwCan't find the link, but IBM has a server JVM for webapps. WebSphere?
14:53pjstadigwhat is jrockit isn't that another JVM?
14:54edwDunno. (Again, I wince when I see mixed case symbols and periods in Clojure code.)
14:54hugodhiredman: swank-clj 0.1.3 includes a basic frame disassembler - still need to add lookup of class statics and add a bit of unmangling
14:56edwIt seems to me that "the JVM issue" has more to do with dependencies on crufty Java libraries than on the JVM in particular, though there are irritating issues like the JVM's difficulty with properly handling tail calls.
14:56hiredmanhugod: wow
14:56hugodthought you'ld like that…
14:57technomancyedw: for me the pain points are primarily about the inflexibility of the classpath and the boot time.
14:59tnovelliedw: ahh. Yeah, every 'platform' has crufty libraries.. GNOME, KDE, Microsoft.. Python, if you call that a platform. It's getting ridiculous.
14:59tnovellihehe
15:00pjstadigtechnomancy: +1
15:00edwtechnomancy: It drives me nuts that I have to bounce the VM just because I added a dependency. I want to measure my REPLs uptime in months.
15:01edwdnolen_: Speaking of PLT, is Arc anything more than just some really obstuse syntactic sugar atop Racket?
15:02tnovelliedw: that's all it is!
15:02edws/obstuse/obtuse/
15:02sexpbot<edw> dnolen_: Speaking of PLT, is Arc anything more than just some really obtuse syntactic sugar atop Racket?
15:02edwtnovelli: Are you joking or serious?
15:03tnovelliserious. it's a snarfed implementation. unless something's changed in the last year or two.
15:03tnovellinot that there's anything wrong with snarfing :)
15:04edwThe Schemer in me would like to see Clojure's #{} and {} and the cleaned-up LET and COND syntax baked into Scheme, enough that I've considered porting Clojure's reader to Scheme...
15:06edwIt's time Scheme used those curly braces for something useful.
15:08tnovelliyeah really :) When I was coding a little lisp-ish compiler last year I borrowed from Clojure and Arc... not Scheme or CL.
15:09dnolen_ewd: I'm not familiar w/ Arc. However, Racket does have persistent data structures, threads, continuations, tail call optimization. Seems like the easiest Clojure target really.
15:09dnolen_also good FFI
15:10edwdnolen_: I see Clojure as "Scheme, beaten into submission by reality."
15:11tnovellihey, Racket has some kind of native code implementation.. actually I think it's just got its own bytecode VM, and Lightning JIT
15:11tnovelliedw: that's pretty accurate :)
15:12dnolen_edw: not totally accurate. The protocol oriented nature of Clojure is a real trump card on many Lisps.
15:12tnovelliall that hygiene and language-tower stuff in Racket is much too clever for me
15:13KirinDavetnovelli: Don't sell yourself short.
15:13KirinDaveNone of it is terribly complex.
15:13edwI like hygiene. I actually like SYNTAX-RULES.
15:13KirinDaveedw: +1
15:13tnovelliClojure still doesn't have macros, does it?
15:13edwHas someone written SYNTAX-RULES for Clojure?
15:13KirinDaveIt does
15:13edwtnovelli: Yes, messy ones.
15:14KirinDaveedw: Someone was working on something like it
15:14KirinDaveActually clojure macros are more hygenic than common lisp macros.
15:14KirinDaveAnd their gensym syntax is way nicer.
15:15edwKirinDave: Why aren't they just porting the portable Scheme implementation? It should be like a one day job. (And hear you re: GENSYM.)
15:17tnovelliWell, I've gotta run.. nice chatting with you guys.
15:18edwSpater
16:00kotarakHow do I override a method of a proxy on a per instance basis?
16:01amalloyum. create a new proxy with different overrides?
16:02kotarakhmm.. I heard rumors, that it is possible, and was actually quite surprised.
16:02kotarakSo maybe I'll skip that part.
16:04amalloy&(doc update-proxy)
16:04sexpbot⟹ "([proxy mappings]); Takes a proxy instance and a map of strings (which must correspond to methods of the proxy superclass/superinterfaces) to fns (which must take arguments matching the corresponding method, plus an additional (explicit) first arg corresponding to t... http://gist.github.com/975239
16:05kotarakamalloy: ah! thanks. I knew I was missing it.
16:05amalloykotarak: there's that, but unless you need to *change* mappings of an existing proxy, you should just figure out what you want to override when you create the proxy
16:06kotarakIt's just for a talk. For differences with proxy and reify.
16:07kotarakamalloy: I think, I think too static for such dynamic behaviour....
19:30gfrlog$findfn [1 2 3] [[1 2] [2 3]]
19:30sexpbot[]
19:31gfrlog$findfn [1 2 3] 2 [[1 2] [2 3]]
19:31sexpbot[]
19:31amalloy&(partition 2 1 [1 2 3])
19:31sexpbot⟹ ((1 2) (2 3))
19:31gfrlog$findfn [1 2 3] 2 1 [[1 2] [2 3]]
19:31sexpbot[]
19:31gfrlogah right
19:31gfrlogbackwards
19:31amalloyindeed
19:31gfrlogamalloy: thx
19:31amalloy$findfn 2 1 [1 2 3] [[1 2] [2 3]]
19:31sexpbot[clojure.core/partition]
19:32gfrloglet's start a kickstarter project to finance a patch to sexpbot that will check alternate argument orderings
19:33amalloygfrlog: knock yourself out. for three args there are only six orderings, so it's not like it's slow
20:07no_mindI am using enlive. I have a template in which I want to render some html in inside a div (id of div known). The html to be rendered is present in another file. How do I do this ?
20:14akhudekbeen a while, but I think you use can use defsnippet or deftemplate
20:16no_mindproblem with defsnippet is that it will use selectors. I want the html from other file to be rendered as is
20:18akhudekjust wrap it in some parent div and select the parent
20:20akhudekouch, so apparently I managed to create a memory leak :/
20:21akhudekanyone have any tips on how to track these things down? I've managed a heap dump and found a referrer chain: http://pastebin.com/B5iPYYry
20:21akhudekbut it's not clear to me what is going on here
20:22akhudekthere should be no data allocated at all at this point
20:22akhudekwell, not of the alphabet type at least
20:22amalloydon't use finalizers
20:23amalloy(if that's what you're doing)
20:23akhudekNone of my code is doing that, although I've wrapped things from the MALLET library.
20:28no_mindwrapping in div's is not an option always.. I am looking for something like subtemplating
20:35akhudekno_mind: I've only ever done it with selectors. You could also try to see if there is a selector to match everything.
20:35akhudekmaybe :* ?
20:38akhudekhmm, it looks like the memory leak is actually in MALLET
20:55kirasi've read that in clojure, data is often stored as .clj files as clojure code. does this mean that if, for example, i were writing a program to keep track of books and allow searching through them, i might have a file like books.clj, containing several maps like {:title "" :author "" :genre "" :data-published ""} and so on? it might even make sense to have all of these maps inside a vector or something?
20:57dnolenkiras: that works for simple things yes. nothing wrong w/ using a database either.
20:58kirasdnolen: ok, i'll have to look into whether a database is a better solution for my needs or not, but part of what i'm wondering is, it seems like a large part of the reason to store data in this way is to avoid having to write custom parsers for data files, right? since clojure should be able to parse these maps already?
20:59dnolenkiras: yes, if what your requirements are modest along the lines of JSON / yaml, then just storing Clojure data is great.
21:00akhudekjust be careful about sanitizing that data if you are writing it based on user inputs!
21:00kirasdnolen: i'm not familiar with either JSON or yaml, unfortunately
21:00kirasakhudek: noted :)
21:01dnolenkiras: are you going to store many records? are you going to update this file often? if yes to both just use a db.
21:04kiraswhat i'm interested in at the moment is, how does one generally load/process these .clj data files? it doesn't seem like it would make sense to read each line as a string. i read a brief discussion on the mailing list where it looked like use of read or read-string was suggested? is that the typical way of reading .clj data files or is there a more typical way? do you know of a good page discussing this?
21:04kirasdnolen: i don't expect to update it very often, but i do expect to have a lot of records.
21:05technomancykiras: the short version is: you use read-string+slurp if you know the data is going to be very small, you use reader+read if you need to process it lazily.
21:08kirastechnomancy: ok, i'll do some searches on that. you don't happen to know of a site with a good explanation of this somewhere, do you?
21:17amalloykiras: it's easiest to have the file look like [{:title blah, :pages 300}, {...}], because then you can just (read) the single object
21:23kirasamalloy: that seems to make sense. i found this page http://nakkaya.com/2009/11/01/clojure-persistence-for-java-programmers/ that seems like it explains the read-string+slurp method, now i'm looking for one explaining the reader+read method.
21:23kiras i have a feeling either reader+read or a database might be necessary for what i'm trying to do, since i will have a fair amount of records to deal with.
21:23amalloykiras: the tricky part (for me) of reader is getting a PushbackReader, which the reader demands
21:24amalloyi think you can just do (with-open [pb (java.io.PushbackReader. (clojure.java.io/reader "the-file-name"))] (read pb)), but i don't do this often
21:26amalloykiras: hey, i was right, that seems to work
21:26kirasamalloy: nice. i'll have to try that out.
21:27kirasamalloy: what do you mean by "the tricky part"? that it's tricky because you don't do it often or that there's actually something difficult about it that i should be aware of?
21:28amalloythe former
21:28kirasamalloy: ok :)
21:28amalloyit's also easy to forget that you even *need* a pushbackreader
21:29kirasamalloy: i see. so if you don't find yourself doing this often, what is it that you usually do as an alternative?
21:29amalloyhaha i don't read a lot of files, i guess
21:29kirasamalloy: lol neither do i, usually
21:29amalloythis is the technique to use, afaik
21:35kiraswell, i'm going to take a break. thanks for the help, everyone. :)
22:41symboleIs it possible to interoplate a symbol inside another symbol, e.g., `(defn ~foo?, where foo is a parameter to the macro. I'm tring to generate a predicate by attaching a ? to whatever was passed to the macro.
22:44amalloy&(let [name 'foo] `(defn ~(symbol (str foo "?"))))
22:44sexpbotjava.lang.Exception: Unable to resolve symbol: foo in this context
22:44amalloy&(let [name 'foo] `(defn ~(symbol (str name "?"))))
22:44sexpbot⟹ (clojure.core/defn foo?)
22:44symboleOh, right. I can just write it outside `.
22:45symboleThanks.
22:46amalloywelcome
23:05amalloydoes https://github.com/clojure/data.xml imply that there's no equivalent of clojure.contrib.pr-xml available on the 1.3 alphas?
23:05symbole(defmacro bar[] `(defn g[]) `(defn g?[])). After evaluating (bar) it seems that g? is defined, but g isn't. What's happening there?
23:05amalloywrap them in a do
23:06amalloyyou're evaluating the first form (which evaluates to a list, remember) for side effects, then returning the second form as the one to macroexpand
23:07symboleRight. Thanks again.
23:09symboleamalloy: So is a do really necessary? Without the due, won't it evaluate the first list as a side-effect, and then return the last one for macro expansion?
23:09amalloysymbole: yes to both questions
23:09amalloyit *constructs* the list, but doesn't evaluate it
23:10amalloybecause only the thing returned from the macroexpansion gets fed to the compiler
23:10amalloyyou may have misunderstood my recommendation, though
23:10amalloy(defmacro bar [] `(do (defn g []) (defn g? []))) will work
23:11amalloy(defmacro bar [] (do `(defn g []) `(defn g? []))) won't; it's identical to your previous version
23:12amalloythe first of those is saying: "this macro means: do these two things!"
23:12amalloythe latter is more like: "this macro means: do the last thing here. i had to compute that other thing in order to decide on this answer, but i'm not telling you about it"
23:13symboleI see.
23:15symboleI need to be more careful.
23:15amalloyit can take some work to get the different scopes straight in your head
23:17tomojany less confusing written this way? (let [form-a `(defn g []) form-b `(defn g? [])] (defmacro bar [] (do form-a form-b)))
23:20symboletomoj: Pretty much the same. I was simply confused about maco expantion time and evaluation time.
23:38scottjalternatives to cc.def's defnk? (looking for one that allows concise default values for non-keyword optional args)
23:39technomancysneak preview: http://p.hagelb.org/slime-in-60-seconds.webm
23:39gertalotI wrote a with-defaults macro the other day
23:39gertalotscottj: maybe this is useful? http://gertalot.com/2011/04/29/named-arguments-with-defaults/
23:43scottjtechnomancy: does clojure-mode install slime via elpa?
23:43technomancyscottj: no, via lein, sorta
23:44technomancyscottj: https://github.com/technomancy/swank-clojure/blob/master/src/leiningen/jack_in.clj
23:44scottjok so in this scenario you'd just git clone clojure-mode?
23:44technomancyscottj: git or marmalade, yeah
23:45scottjonly changes that would have been nice I think would be to first show git cloning clojure-mode and maybe installing lein (if there's a one-liner for that)
23:45scottjmight be hard to hit 60seconds then :)
23:46technomancyyeah, maybe show the marmalade installation
23:46scottjmarmalade one would be more complicated than git clone, but maybe you prefer ppl to use that method. cause marmalade you'd have to show install package for non-24 plus repo etc
23:47scottjof course w/o I guess I forgot load-list and require lines
23:47scottjanyway, cool vid
23:48technomancythanks
23:48technomancyhuge difference vs doing everything through package.el I think
23:50scottjbtw your recent s/start-repl/start-swank commit doesn't fix swank so it works in lein swank, foo situation? I didn't look closely at it
23:53hugodtechnomancy: I like the elisp injection idea :)
23:54hugodbeing able to keep .el files rather than embed them in .clj seems like a win
23:54technomancyhugod: it would make it a lot easier to break compatibility with elpa slime if we ever need to
23:55technomancyscottj: no, that's separate. not sure how to switch between blocking/non-blocking tasks
23:58scottjhugod: what is the motivation for your swank debug fork over jahad's recent work?
23:58hugodscottj slime debugger integration
23:59scottjso jahad's recent stuff into swank doesn't use the slime debugger UI?
23:59scottjbtw does yours use jahad's stuff underneath for stepping?
23:59hugodas far as I know it uses GUD, though I could be wrong…