#clojure logs

2013-06-15

00:00ddellacostahmm, I wonder if there is a Google Closure IRC group with any activity...
00:04bbloomdnolen: scalajs has source maps!
00:04bbloomhttp://lampwww.epfl.ch/~doeraene/presentations/scala-js-scaladays2013/
00:08bbloom"Scala standard library = 16 MB of JavaScript code after compression by Google Closure's simple optimizations."
00:08bbloomwow. heh
00:09ddellacostahow much was Clojurescript at first?
00:11bbloomddellacosta: cljs has supported goog advanced optimizations since v1
00:11bbloomddellacosta: but there are some things that prevent dead code elimination that weren't fixed until quite recently (and i think there might be a few left)
00:11bbloomeven still, compiled code is under 400k with no optimizations
00:11bbloomclojure core is TINY compared to scala's core
00:12bbloomthere isn't really a scala core to speak of
00:12bbloomit's a very large std lib
00:12bbloomand the type system is a dense cyclic graph, so it's gonna be really hard for them to untangle it and get that size down
00:13bbloombut since they are a research group, i'm excited to see what they come up with :-)
00:14ddellacostagotcha, thanks bbloom for the explanation
00:14ddellacostavery interesting, I look forward to hearing more too.
00:15bbloomi suspect they will be able to leverage the type system to perform some smart, static code elimination
00:15bbloomthey don't really bother w/ dead code elimination on the jvm, since there isn't really a point
00:16bbloomalso, i should mention that unoptimized cljs core has grown from 400k to about 600k
00:17futilewoot: https://github.com/evanescence/test2/blob/master/SPEC.md
00:18tomjack1.3-beta???
00:18lazybottomjack: How could that be wrong?
00:19futiletomjack: meaning, the spec kept changing and i didnt want people building from it yet
00:20SegFaultAXYou should semvar that.
00:20tomjackusually 1.0 is like a big deal
00:20SegFaultAXAnd it shouldn't have a whole digit version if it's still in complete flux
00:20bbloomi need to write an anti semver blog rant so i can link to it in anger :-)
00:21futiletomjack: ok then its really 0.1
00:21SegFaultAXbbloom: What's your issue with semvar?
00:21SegFaultAX(I have no particular allegiance other than it's relatively common and easy to implement)
00:21bbloomSegFaultAX: you'll just have to mention semver again sometime in the future after i've written that rant to link to :-)
00:21futilefixed version number
00:22SegFaultAXbbloom: Well that's the tl;dr?
00:22bbloommy biggest issue isn't w/ semver, it's with things like node's npm which ASSUME semver
00:22SegFaultAXWhat's*
00:22SegFaultAXSemver* I don't know why I keep hitting a
00:23bbloommanaging breaking changes is a subtle and complex process which 99% of maintainers can't be trusted with, so it is totally the wrong default for a package repository
00:23tomjackI have made a bunch of commits removing the goddamn tildes in package.json that my coworkers forget
00:24tomjackevery time I make the message "remove TILDES OF DOOM" but they don't learn :(
00:34futileOkay so, nesting things actually breaks this idea I had of *assertion-result*
00:34futilekinda
00:57futileOh man.
00:58futileI'm not sure how the Run-fn is supposed to recursively run descendent groups *while* still executing once-fixtures around each group.
00:59futileThese 4 lines need to be wrapped in a once-fixture: https://github.com/evanescence/test2/blob/master/src/test2/api/run.clj#L32-L35
00:59futileOnce I can figure that out, it's done.
01:38Raynes$mail futile (if-let [pending (:pending (meta test-fn))] ..)
01:38lazybotMessage saved.
01:48callenRaynes: brave.
01:48Raynescallen: Valiant.
01:53n_bSo, when releasing stuff on Clojars, is the preference for the tld.yourdomain.some.id nonsense from Java-land, or straight up library names?
01:54n_bI checked a few common libraries and there was a mix, and core does the clojure.data.* stuff, clj-http is just that, fogus has his namespaced
01:57callenn_b: I think it's up to preference.
01:57callenn_b: but the pattern you saw is more or less indicative.
01:57RaynesThe domain stuff is not at all nonsense.
01:57RaynesIf you don't do it, then it's impossible for two people to name their projects "beep".
01:57RaynesNamespacing helps with that.
01:58callenn_b: I would base it on how likely there is to be somebody else with the same name and preference.
01:58tomjackI've wanted to name projects ridiculous things like 'io'
01:58tomjackin protest :)
01:59n_bRaynes: It does, my gripe is more the ridiculous namespacing that is so prevalent in Java (and somewhat forced upon you by the language) that it results in import statements with more periods in them than a James Joyce novel
02:00n_bcallen: Yea, that makes sense. There are literally no projects on GitHub with the same name, and it's a word from a small language, so I'll just go straight up
02:00n_bJust need to fix a few remaining bugs and write the test suite before I push up the 0.0.01 release
02:01callenn_b: what's the name?
02:01n_b"eventyr"
02:01callenn_b: I'd namespace it.
02:02RaynesThe better question is why does n_b *not* want to namespace.
02:02RaynesLike, what do you lose?
02:03n_blike, five whole characters!
02:03RaynesI used to hate namespacing as well for the same reason.
02:03n_bI was more concerned about what convention was
02:03RaynesBut then I became a man.
02:03RaynesOooh, burn.
02:04Raynesn_b: The convention is to either: a) not give a shit and so no namespacing b) namespace based on domain names or something c) namespace based on the name of the project.
02:04RaynesLike, less-awful-ssl by aphyr is namespaced as less.awful.ssl
02:14Apage43dictionary word? namespace that puppy
02:21amalloytomjack: you'll find "io" is already taken, from back before ninjudd heard the holy word of namespacing
02:23tomjackhah
02:24tomjackwell, even better
02:24tomjackI'll just publish a library with the same name to another repo
02:59lain1Hello. Hopefully it's ok if I ask about clojurescript here since #clojurescript is quiet right now
03:00lain1I'm new to clojurescript and clojure. When would I use an atom over a var in clojurescript. As far I can tell javascript is basically a single threaded environment so I don't see the point in atoms
03:04wei_anyone have an example of combining the maybe monad with the writer monad?
03:07wei_lain1: as far as i know there are no vars in clojurescript
03:09lain1Ah, that's right there in the documentation
03:09lain1So I guess atoms for all mutable state then
03:10wei_yep
03:11tomjackwei_: in clojure?
03:11tomjacklike algo.monads or something?
03:11clojurebotSomething weird that I noticed: & (use '[clojure.contrib.json :as json]) & &| (json/pprint-json nil) |&
03:11wei_tomjack: yes, preferably with algo.monads
03:16tomjackdo algo.monads even compose?
03:16tomjackthere are no transformers, are there?
03:20nonubyis there anything like lein-search but recently so I can find the semver of say clj-http without switching it browser and hitting github or clojars
03:20tomjackthen I'm guessing with protocol monads you just get crazy unpredictable behavior if you try to mix?
03:22tomjackoh looks like protocol-monads has transformers
03:24wei_tomjack: there do seem to be transformers
03:25wei_i was trying (def writer-maybe-m (maybe-t (writer-m []))) but the final value is always nil
03:27lain1nonuby: Never tried it but is this what you're looking for: https://github.com/cldwalker/lein-grep
03:28nonubyfound there actually just "lein search" i was trying to use the 2 year old lein-search plugin. so most of issue solved!
03:31wei_btw, my goal for this is to have chain a series of actions that may fail at any step, and return the value along with a success/failure message. maybe+writer seemed like a good fit
03:31lain1Oh cool
03:32nonubylein-grep is better though, just install it, much easier to navigate results (.e.g on lein search latest clj-http appears on page 2 and need to reissue query not very user friendly)
03:33nonubythanks
03:33nonubyjust install => just installed
04:17can3pHello everyone. I'm making my first steps with clojure and clojurescript. I have a question and did not find the answer in the docs. If I have multiple declarations in the let form, are there any cases when it's valid to reference between them?
04:22terom,(let [a 1, b a] b)
04:22clojurebot1
04:26teromcan3p: What do you mean by referencing between? You can reference a previously declared symbol later in the let form, as you can see above.
04:37can3pSo, I cannot make a mutual recursion between them, right?
04:39mthvedtcan3p: not without using some tricks. clojure is not lazy by default, even though many of its data structures are
04:48wei_is there a long-polling client library for clojurescript?
04:52can3pmthvedt: thanks for the clarification
04:54ddellacostawei_: not sure if this suits your needs but maybe take a look at http://docs.closure-library.googlecode.com/git/class_goog_net_xpc_IframePollingTransport.html, since it's baked in?
04:56augustlwei_: I would have used Faye and interop for that
04:57wei_thanks guys, will look into it
04:57wei_if there was a clojure port of socket.io would have loved to use that
05:09augustlwei_: I'm a big fan of interop.. You should consider it :)
05:09wei_augusti: i did find this netty-socketio implementation, maybe i'll give it a shot
06:25danbellQuestion: are there multiple macro steps? As in, is it possible to use a macro, and have it expand into code that ALSO uses a macro, which macro then expands into...you get the idea?
06:25hyPiRiondanbell: yes, that's exactly how -> and ->> works today
06:25hyPiRion,(source ->)
06:25clojurebotSource not found\n
06:26noahlzI have a lot of experience packaging Java apps with Maven Assembly Plugin, but it seems there's no equivalent for Leiningen? Should I just whip up a small plugin of my own for packaging - or has the world moved on to Pallet / Chef / etc for distribution of complex JVM apps that include scripts, directory structure etc.
06:26hyPiRion$source ->
06:26lazybot-> is http://is.gd/8ScCRY
06:26hyPiRiondanbell: ^
06:26danbelljust checked source in my own repl
06:26danbellty
06:27hyPiRionnp
06:27danbellok, less fundamental question: how do you namespace-qualify that "returned" macro
06:27danbell"?
06:27danbell-> is obv. in the same namespace as ->
06:27noahlzhmm perhaps will post that question on lein mailing list
06:28danbellI'm trying to use dommy's node macro (from...dommy.macros) in a separate macro ns
06:29hyPiRiondanbell: all macroexpansions will be namespace-qualified. So for instance, if you use clojure.string/blank?, then even this works fine:
06:29hyPiRion,(require '[clojure.string :refer [blank?]])
06:29clojurebotnil
06:29hyPiRion,`(blank? "")
06:29clojurebot(clojure.string/blank? "")
06:30hyPiRionif there's no symbol with that name, it will just use the current namespace
06:30hyPiRion,`(foo a b c)
06:30clojurebot(sandbox/foo sandbox/a sandbox/b sandbox/c)
06:31danbellhm....k, I must have gotten my ns declarations wrong
06:31danbellty very much
06:31hyPiRionnp
06:32callennoahlz: generally speaking, leiningen knows enough about your application that it's best to use leiningen itself or a specialized plugin to package your application for your into a jar.
06:32callennoahlz: I am lazy as all hell so I uberjar pretty much everything and so have a deployment story approxiating `rsync muh_app.jar`
06:33hyPiRionwow, rsyncing the jar is new
06:33augustlis there a clojure XML zipping cheat sheet out there?
06:34noahlzok
06:34hyPiRionoh, read that wrong. Well, it's almost like I rsync it as well
06:34hyPiRionsans environment variables and those other nitty gritty details
06:35callenaugustl: http://clojure.github.io/data.zip/ http://nakkaya.com/2009/12/07/zipping-xml-with-clojure/ ?
07:02danbellhypirion: reason i was having trouble was b/c that was all enclosed in a macro-helping helper fn, so backtick resolved to macro ns
07:03hyPiRionoh, I see.
07:03hyPiRionI've (luckily) not worked much with macros in practise.
09:27fikuszis there something like mapAccumL (haskell) in the clojure libs? http://hackage.haskell.org/packages/archive/base/latest/doc/html/Data-List.html#v:mapAccumL
09:43bprdoes anyone have experience using with friend with pedestal?
09:49abpbpr: https://github.com/cemerick/friend/pull/54
09:51bprthanks
09:52ivanpierre@fikusz look reducers http://www.infoq.com/presentations/Clojure-Reducers?goback=.gmr_1058217.gde_1058217_member_249925963
09:57noncomhow to know if a vector of keywords contains a keyword?
09:57noncomcan't find a simple way
09:59noncomafaik `contains?` only verifies index containtment
09:59hyPiRionnoncom: .indexOf
09:59hyPiRion,(.indexOf :b [:a :b :c])
09:59clojurebot#<IllegalArgumentException java.lang.IllegalArgumentException: No matching method found: indexOf for class clojure.lang.Keyword>
09:59hyPiRionwhops, wrong order
09:59hyPiRion,(.indexOf [:a :b :c] :b)
09:59clojurebot1
09:59hyPiRion,(.indexOf [:a :b :c] :f)
09:59clojurebot-1
09:59noncomheh, nice :)
10:00noncomthank you!
10:00hyPiRionalthough (some #{:b} [:a :b :c]) is perhaps more idiomatic
10:00hyPiRionnp
10:00noncom,(some #{:b} [:a :b :c])
10:00clojurebot:b
10:00noncom,(some #{:f} [:a :b :c])
10:00clojurebotnil
10:01noncom,(time (some #{:b} [:a :b :c]))
10:01clojurebot"Elapsed time: 0.042404 msecs"\n:b
10:01noncom,(time (.indexOf [:a :b :c] :b))
10:01clojurebot"Elapsed time: 0.048897 msecs"\n1
10:01noncom,(time (some #{:c} [:a :b :c]))
10:01clojurebot"Elapsed time: 0.034186 msecs"\n:c
10:01noncom,(time (.indexOf [:a :b :c] :c))
10:01clojurebot"Elapsed time: 0.041578 msecs"\n2
10:02hyPiRionnoncom: .indexOf is certainly faster, although the speed shouldn't matter that much
10:02noncomlooks like the sets solution is a time win
10:02supersymlein deps :tree gives [ring-mock "0.1.5"]
10:02hyPiRionthing is, .indexOf issues a reflection call here
10:02hyPiRionfor larger vectors you may see it
10:02supersymoverrides [ring-mock "0.1.5"]
10:02hyPiRion,(time (.indexOf (vec (range 4000)) 3999))
10:02clojurebot"Elapsed time: 22.294616 msecs"\n3999
10:03hyPiRion,(time (some #{3999} (vec (range 4000))))
10:03clojurebot"Elapsed time: 7.985011 msecs"\n3999
10:03hyPiRionwha
10:03supersymthey are the same, or not? few other deps too... same version numbers appear to conflict
10:03noncomhmmm
10:03hyPiRionNot that time is the best way to measure, but .indexOf should in theory be faster
10:03hyPiRionoh well
10:03noncomyeah, maybe a type hint would do
10:04noncom,(time (.indexOf ^java.util.Collection<Float> (vec (range 4000)) 3999))
10:04clojurebot#<CompilerException java.lang.ClassNotFoundException: java.util.Collection<Float>, compiling:(NO_SOURCE_PATH:0:0)>
10:04noncomumm
10:05noncom,(import java.util.Collection)
10:05clojurebotjava.util.Collection
10:05noncom,(do (import java.util.Collection) (time (.indexOf ^java.util.Collection<Float> (vec (range 4000)) 3999)))
10:05clojurebot#<CompilerException java.lang.ClassNotFoundException: java.util.Collection<Float>, compiling:(NO_SOURCE_PATH:0:0)>
10:06noncompff
10:06hyPiRionyeah, generics are a bit messy
10:06hyPiRion,(time (.indexOf ^Collection (vec (range 4000)) 3999))
10:06clojurebot"Elapsed time: 1.3185 msecs"\n3999
10:06hyPiRionbwahah
10:07supersymyup
10:15noncomthat timing which is faster is strange since vectors are known to implement Collection by default. so why casting matters?
10:19supersymsay guys, what's to be expected if I have a piece of what seems clj abandonware, and updated it to current references/deps
10:19hyPiRionno, it's not strange, because the JVM/Clojure has no way of knowing what vec returns
10:20hyPiRionso it'll have to figure out what kind of object this is, look up the hierarchy tree etc
10:20supersymshould I put it in clojars or...how does that work/what are the social conventions? :P
10:21hyPiRionsupersym: with the proper group id and a reference to the abandoned project in a readme or something, that shouldn't be an issue
10:21hyPiRione.g. if Leiningen somehow died tomorrow and I wanted to continue it, it would be com.hypirion/leiningen
10:22hyPiRion(and yeah, clojars)
10:29supersymnah none of that proportions, but same may prove to be useful to a niche at least. Not that I personally care too much but I wanted to know what one would expect. Maybe like 1 out of a handful explicitly asked for maintainer anyway, so not too much concern. And I can do with a github fork and lein checkouts/local mvn
10:29supersymsame*some
11:10gfrederickshas anybody written anything that analyzes which vars in a namespace use which others?
11:10gfredericksI remember technomancy wanting such a thing, and at a glance it seems like it might be easy to do on top of jvm.tools.analyze
11:19futile,(test +)
11:19clojurebot:no-test
11:22futileOnly one file left, and then test2 is feature-complete.
11:27gfredericks,(doc test)
11:27clojurebot"([v]); test [v] finds fn at key :test in var metadata and calls it, presuming failure will throw exception"
11:28gfrederickswhat a weird thing to have in core
11:32winkwat
11:33supersymyea sorta.. not like its bash test equivalent important, or so it seems to me
11:35loliveirais there some way to access the project's version?
11:35loliveirathe verion
11:36loliveirathe version witch is defined by lien's defproject.
11:36supersymi think you need lein-environ for that
11:36supersymhttps://github.com/weavejester/environ
11:37loliveirathank you.
11:52gfredericksI think there's also a file compiled into jars that you can look for
11:53gfredericksit at least has the git sha but I expect the version as well
12:05fsmunozI need to specify a -cp, so apparently I can't use -jar. THis is likely obvious but what is the name of the main function? My ns is oradcn-demo.core .
12:07fsmunozI.e. whatever I must use as foo.bar.baz in "java -jar -cp proprietary.jar:lein_uberjar.jar foo.bar.baz"
12:07fsmunoz(unless this doesn't make any sense at all, of course :) )
12:08gfredericksfsmunoz: if you have a vanilla :gen-class in your ns then oradcn_demo.core should be the class name
12:08gfredericksi.e., the main gotcha is the underscore substituted for the dash
12:09fsmunozgfredericks: splendid, that was it
12:09fsmunozNow I remember reading about that in the tutorial, but without a real need I forgot about it.
12:12gfredericks,(chunked-seq? (range))
12:12clojurebotfalse
12:12gfredericksam I crazy? isn't (range) the canonical example of chunked-seq gotchas?
12:16Bronsa,(chunked-seq? (rest (range)))
12:16clojurebottrue
12:17Bronsagfredericks: the ChunkedCons is wrapped in a LazySeq
12:17Bronsa,(map class ((juxt identity rest) range))
12:17clojurebot#<IllegalArgumentException java.lang.IllegalArgumentException: Don't know how to create ISeq from: clojure.core$range>
12:18Bronsa,(map class ((juxt identity rest) (range)))
12:18clojurebot(clojure.lang.LazySeq clojure.lang.ChunkedCons)
12:18gfredericksah ha
12:18gfredericksI should have examined the source closer :)
12:19Bronsait's easy to miss the lazy-seq at the top
13:00piranhaalandipert: hi
13:09dnolenjasonjckn: yeah it was never clear to me what the source of the AOT issue was, doesn't matter much now, the problematic code was badly written and has since been replace with something much simpler.
13:10jasonjckndouble win then
13:11dnolenbbloom: I find it very surprising that they didn't address the code size thing up front - something to definitely give rhickey credit for.
13:11dnolenjasonjckn: yes, core.match is much simpler now - I hope to write up some detailed explanations about how it works.
13:12dnolenbbloom: also the emitted JS is written in a way that it defeats advanced optimization. I'm sure they'll sort it out in the end
13:12bbloomdnolen: i skimmed a little more info about it. seems like generating advanced-mode js is almost done, but their std lib is too large for gclosure to compile w/o freaking out
13:13dnolenbbloom: hmm interesting
13:13bbloomdnolen: i expect them to do a lot of scala-level dead code elimination
13:13dnolenbbloom: yeah
13:13dnolenstill cool to see another language join the fray
13:13bbloomdnolen: which we should do too, but it's just not as pressing as it is for them
13:14bbloomtheir approach os having js types defined w/ implicit conversions to scala types is interesting
13:15dnolenbbloom: what are they doing exactly?
13:15bbloomhttp://lampwww.epfl.ch/~doeraene/presentations/scala-js-scaladays2013/#/16
13:17bbloomthey basically encoded a js type system in their own type system
13:17bbloomturns out scala's type system is sufficiently expressive to cover the same sorts of things as typescript
13:17dnolenbbloom: I'm not gleaning anything from that slide
13:17dnolenbbloom: oh interesting
13:18bbloomso they do stuff like this: https://github.com/lampepfl/scala-js/blob/master/library/src/main/scala/scala/js/JSAny.scala
13:18bbloomand, if i'm understanding correctly, the compiler replaces those stub impls with the equivilent of js*
13:23bbloomdnolen: they did a nice job on it though overall. they compiler is only ~3200 lines of code & includes a proper JS AST & printer
13:28bbloomdnolen: ooo very interesting. they actually don't compile directly to javascript
13:28bbloomdnolen: they compile to "Extended-JS"
13:28bbloom * Extended-JS is a non-existent language that is a superset of JavaScript
13:28bbloom * with Scala-esque constructs. Most notably, most constructs can be used in
13:28bbloom * expression position. Extended-JS also features ES6-like classes.
13:28bbloomthen they desugar that
13:28bbloomclever.
13:28dnolenwell I can't even play with it SBT just OOMed
13:29bbloomheh.
13:31bbloomdnolen: how did you install sbt?
13:32dnolenbrew
13:32bbloomyou on the latest?
13:32bbloom0.12.3
13:34dnolenoh looks like I'm not
13:34bbloomafter you do that, run `brew info sbt`
13:34bbloomand edit your .sbtconfig file
13:38bbloomshesh, the compiler is sloooow
13:39dnolenheh I'm not convinced about this JS AST business
13:39bbloomthoughts?
13:41dnolenhard to say without playing around with it a lot more
13:43dnolenseems less usable than initial ClojureScript release after 2 months of development
13:43bbloomto be fair, this was done by a student in 4 months :-P
13:43dnolenso something to watch, but in it's current state - a curiosity
13:43bbloomrich & team are a weee bit more experienced :-)
13:44dnolenand Clojure is simpler
13:44dnolenbut true enough
13:44bbloommuch.
13:44bbloomjust in sheer number of syntactic forms to process, clojure is just a smaller volume of work
13:45dnolendefinitely looking forward to seeing where it goes
13:45bbloomlikewise
13:45dnolenoverall it's cool see more people taking JS target seriously
13:45dnolenin 5 years no one will bat an eye about compile to JS langs
13:46bbloommy real hope is that in 5 years, it will be a no brainer to finally push to standardize some sort of more sane browser compilation target :-)
13:46bbloombut maybe that's 5 years after your no-eye-batting scenario
14:09bbloomi have a really freaking hard time writing ruby now. clojure has ruined my brain
14:09bbloomi have to resist the urge to call freeze on everything
14:10gfredericksmodule SelfMethods
14:10dnolenbbloom: unlikely
14:10bbloomgfredericks: ?
14:12gfredericksbbloom: I have a hard time resisting mocking the weird OOP patterns that the ruby community has developed
14:12gfredericksso I was just mentioning one :)
14:12bbloomgfredericks: i'm not familiar with that one
14:13gfredericksit's instead of class Foo; def self.bar; ...; end; end
14:13gfredericksclass Foo; module SelfMethods; def bar; ...; end; end; extend SelfMethods; end
14:13gfredericksor maybe s/extend/include/; I can never keep those two straight
14:13bbloomoh that thing where they put the instance and class methods in two different files b/c their file got too damn large?
14:13gfredericksnot quite that
14:14gfredericksSelfMethods keeps you from specifying `self.` in the method name
14:14futileWhoa.
14:14futileRuby?
14:14clojurebotChunky bacon!
14:14gfredericksand probably some other subtle "benefit"
14:14futileI have to admit, once I learned Ruby I hated all other languages I knew in comparison.
14:14futileIt was really really fun and enjoyable, and I felt like I *got it*.
14:15futileRuby seemed so simple and consistent!
14:17gfredericksfutile: did you know `-42` and `- 42` parse differently?
14:17futileNope.
14:17bbloomgfredericks: that hardly seems surprising
14:17gfredericksthat's my favorite ruby syntactic trivium
14:17gfredericksbbloom: also not surprising that they're semantically different?
14:18futileI know that Ruby fakes consistency with all sorts of ugly hacks.
14:18bbloomgfredericks: even haskell has some weirdness around negative vs minus
14:18futileLike, the top-level self.
14:18gfredericksoh haskell I have no syntactic respect for :D
14:19gfredericksbut maybe slightly more than for ruby
14:19futileClojure has spoiled me with its consistency.
14:19bbloomgfredericks: http://www.haskell.org/haskellwiki/Unary_minus
14:19gfrederickslisp has ruined my appreciation of any other syntax
14:19futileI'm sure there are inconsistencies in Clojure. I just don't know about them off-hand, which is a good sign.
14:20futileAnd compared to every other language, lisp-family or not, Clojure seems pretty pure in its semantic and syntactic consistency.
14:20gfredericksI assume though that in haskell `-42` and `- 42` cannot be made to evaluate to different things
14:20futileSeriously, what are some inconsistencies in Clojure?
14:20gfredericksfutile: this sounds like a fun list to curate
14:20hyPiRionsyntax-wise or semantic-wise?
14:20gfredericksthe first one off the top of my head is conj
14:21gfrederickshyPiRion is probably a treasure-trove of syntactic curiosities :)
14:21futilelets say syntax for now
14:21murtaza52I am creating a leiningen plugin which watches over a folder an executes an action if any file has changed. Is there some code which I can use to watch over a folder?
14:22futile$mail Raynes ok
14:22lazybotMessage saved.
14:22hyPiRionHeh, what would you expect ((-> [%] #(list %)) 10) to do?
14:22futilegonna finish test2 today. Just two functions left to write, and I think I know how to make it work.
14:22futilehyPiRion: hmm
14:22hyPiRionI'm not sure if it's inconsistent, but it's surprising.
14:23gfrederickshyPiRion: my guess is a symbol not found error
14:23futile,(list [10] 10)
14:23clojurebot([10] 10)
14:23futileThat.
14:23hyPiRiongfredericks: yep
14:23hyPiRion,((-> [%] #(list %)) 10)
14:23clojurebot#<CompilerException java.lang.RuntimeException: Unable to resolve symbol: p1__57# in this context, compiling:(NO_SOURCE_PATH:0:0)>
14:24futileOh no wait, because #() isn't a form that -> can handle, it's a reader form, so it probably gets converted into (fn...)
14:24futileman Clojure sucks.
14:24gfredericksfutile: that's it
14:24gfredericksthe [%] becomes the arg list
14:24futilegfredericks: oh so I did get it right?
14:24gfredericks,'#(list %)
14:24clojurebot(fn* [p1__86#] (list p1__86#))
14:24gfredericksso you end up with (fn* [%] [p1__86#] (list p1__86#))
14:24futileyay!
14:24bbloom,(macroexpand '(((-> [%] #(list %)) 10))
14:24clojurebot#<RuntimeException java.lang.RuntimeException: EOF while reading>
14:24bbloom,(macroexpand '(((-> [%] #(list %)) 10)))
14:24clojurebot(((-> [%] (fn* [p1__142#] (list p1__142#))) 10))
14:24bbloom,(macroexpand '((-> [%] #(list %)) 10))
14:24clojurebot((-> [%] (fn* [p1__171#] (list p1__171#))) 10)
14:25bbloom,(macroexpand '(-> [%] #(list %)) 10)
14:25clojurebot#<ArityException clojure.lang.ArityException: Wrong number of args (2) passed to: core$macroexpand>
14:25futileok, moving on
14:25bbloomblah i can't even parse that
14:25bbloomtoo much line noise
14:25bbloomhaha
14:25futileNow BESIDES macros, what are some inconsistencies in Clojure?
14:25hyPiRion,(macroexpand-1 '(-> [%] #(list %)))
14:25clojurebot(fn* [%] [p1__229#] (list p1__229#))
14:25hyPiRionoh, conj man
14:26gfredericksthe arg signature of distinct vs distinct? is annoying and was discussed the other day
14:26hyPiRion,(conj {1 2} [3 4])
14:26clojurebot{3 4, 1 2}
14:26hyPiRionfutile: see that? ^
14:26bbloommy biggest issue w/ any language that isn't clojure: nothing has a fucking sane default printed representation
14:26futileI never ever use conj directly. Only usually via into.
14:26bbloomblargh. i do no want to see fucking pointers when i call to_s
14:26hyPiRionGuess what (conj {1 2} {3 4, 1 6}) would do.
14:27futileCuz I always want to know where something is gonna go, like which end.
14:27bbloomblargh. i do no want to see fucking pointers when i call to_s
14:27gfredericksfutile: I'm not sure why into is any different in that regard
14:27bbloomsorry didn't meant o send that twice
14:27hyPiRiongfredericks: oh yeah, there is one issue with the reader actually
14:27bbloombut i guess the emphasis is important
14:27gfredericksbbloom: having rouble wih your t's?
14:27futilegfredericks: and I only use into like ##(into {} [[1 2] [3 4]])
14:27lazybot⇒ {1 2, 3 4}
14:27bbloomgfredericks: i have issues with everything all the time
14:27futileThat's the only time I ever use conj that I'm aware of.
14:28hyPiRion,`{~@[1 2] ~@[3 4]}
14:28clojurebot{1 2, 3 4}
14:28hyPiRion,`{~@[1 2]}
14:28clojurebot#<RuntimeException java.lang.RuntimeException: Map literal must contain an even number of forms>
14:28Bronsaew hyPiRion
14:28hyPiRion,`{~@[1 2] ~[3 4]}
14:28clojurebot#<IllegalArgumentException java.lang.IllegalArgumentException: No value supplied for key: [3 4]>
14:28bbloomhyPiRion: oh yeah, that's annoying
14:28hyPiRionIt's a big issue when you're swearjuring.
14:29hyPiRionfutile: see here: ##[(conj {1 2} [3 4]) (conj {1 2} {3 4, 5 6})]
14:29lazybot⇒ [{3 4, 1 2} {5 6, 3 4, 1 2}]
14:29futilehyPiRion: no comprendo
14:30futilebut to be fair, my attention has moved back to test2 right now
14:30hyPiRionthe last result is weird.
14:30hyPiRionah, ok
14:30futileto make it official: bbl
14:30futile,(prn "bbl")
14:30clojurebot"bbl"\n
14:30hyPiRiongfredericks: btw, seen this little gem?
14:30hyPiRion,(let [s (set (apply hash-map (range 10)))] [s (keys s)])
14:30clojurebot[#{[2 3] [4 5] [6 7] [8 9] [0 1]} (2 4 6 8 0)]
14:31gfrederickshyPiRion: I've been watching the clojure-dev list, so this seems totally reasonable now :)
14:31hyPiRionoh darn you
14:32gfrederickswould replacing `set` with any of seq, vec, list* do the same thing?
14:32hyPiRionyeah
14:32futileBtw does anyone wanna go through the Spec and tell me in what places it doesnt make any sense and is stupid? https://github.com/evanescence/test2/blob/master/SPEC.md
14:33futileI'm pretty sure the spec is feature-complete now, aside from lacking a few keys for timing tests in the assertion-result and test-result types
14:33hyPiRionwell, the same thing as in you'd get the keys back. The order depends on the data structure
14:33futileI spent tedious amounts of time making this spec as easy as possible to navigate for extension-authors.
14:33futilenavigate/read
14:33futileand /understand
14:43berdarioHi, I think I might have stumbled on a lein-cljsbuild bug
14:45berdarioIt should be line 100 of cljsbuild.compiler
14:46berdariothe (load ) fails
14:46berdarioprobably, it's a classpath issue
14:57berdarioI don't know if it's related... but it seems that lein it's not creating a target/ directory when compiling
14:58futileRaynes: what was that if-let-pending thing supposed to be?
15:00berdariono, if I delete the target/ directory, it can still build just fine
15:02futile,e
15:02clojurebot#<CompilerException java.lang.RuntimeException: Unable to resolve symbol: e in this context, compiling:(NO_SOURCE_PATH:0:0)>
15:02futilethen why does it highlight weird in clojure-mode.el!
15:05Bronsahttps://github.com/technomancy/clojure-mode/blob/master/clojure-mode.el#L251-L252
15:05futileOh.
15:07futileCrap. `carton update` broke something in my emacs initfile
15:08futileSomeone broke my delete-selection-mode :/
15:10futilenm
15:16Raynesfutile: An improvement to the run.clj or whatever code you linked to last night.
15:16futileok thx
15:18mthvedtfutile: why are group maps required to be in vars?
15:19futilemthvedt: so it can uniquely identify groups that multiple tests point to
15:19futilemthvedt: I can imagine a sub-group of one group having the same :description as a sub-group of another group, yet they should be considered different groups.
15:19futilemthvedt: ok bad example. better one: two top-level groups with the :description should be considered different
15:20futilemthvedt: thus (defn ^:test ^{:group #'some-group} test-name [] ...)
15:20futilemthvedt: although usually you wont have to type that, some macros will generate that for you since its kind ugly.
15:21mthvedtfutile: that doesn't explain why a var, instead of a symbol or a string name
15:21futilemthvedt: because vars are automatically super-duper-unique
15:22futilemthvedt: symbol or string name has the same non-uniqueness problem that a map does.
15:22futilemthvedt: vars are tied to a namespace and file and line, etc. ie, what people usually mean.
15:23mthvedtfutile: it seems like you're stating an opinion, that test groups should only exist by def-ing a var in a .clj file
15:24mthvedtthe uniqueness problem with, say, symbols is easily solved if you're generating them, and if you're using them in code symbol collisions work the same as var collisions.
15:24futilemthvedt: no, just that the alternative creates too many identity problems
15:24futilemthvedt: are there any downsides to making it a var?
15:28futileAha! Paredit broke deleting stuff!
15:28futileawwwww
15:29mthvedtfutile: you're making a var _key_ part of a data definition, which seems odd. the value doesn't know about the uniqueness you're imposing on it. someone reusing a var is as likely as someone reusing a symbol, except now your var has been redefed and your code doesn't know.
15:29mthvedtfutile: it's very easy to make an auto generated unique :id, or something.
15:30futilemthvedt: hmm yeah. so you propose just leaving it up to the user to make sure their groups are unique?
15:30futilemthvedt: (i.e. maybe with some macros like defgroup or something)
15:30mthvedtfutile: yeah, as long as you're already assuming the use of macros in the common case, i don't see why not
15:30futileAlso, everybody using emacs: don't update paredit, the latest breaks deleting stuff.
15:30mthvedtvars as keys make me uneasy because they aren't values.
15:30mthvedtin the clojure sense
15:31futilemthvedt: ah
15:31futilemthvedt: how do you feel about test-fns being vars like the spec says?
15:32mthvedtfutile: fns aren't (usually) values either so that doesn't bother me as much
15:33mthvedtfutile: though again you're not using the var for its var-ness, you're using it because it has metadata on it.
15:34futileok
15:35futilemthvedt: so now the spec should mention that they should be made unique to all other groups with something like :id
15:35mthvedtso the var seems like an extra assumption. fns are almost always unique, and when they're not unique, that's on purpose
15:35futilemthvedt: i suppose that makes sense
15:40amalloyi can't imagine a good reason for a generalized testing tool to only work on vars. why can't i build up a map of functions at runtime and run tests on them?
15:40bbloomamalloy: i've said that a few times, but apparently nobody cares
15:41amalloyin fairness i don't care either, because i don't see myself using test2
15:42bbloomamalloy: now we agree on two things :-)
15:42bbloomnot to disparage the effort, i think it's worthwhile
15:42bbloomi just don't really care until/unless it takes off
15:42gfredericksA function which, given a filename, returns a map from vars to sets of referenced vars: https://gist.github.com/fredericksgary/5789305
15:43futileamalloy: well, the metadata thing was just so it can find any tests written like (defn ^:test my-test [] ...)
15:44futileamalloy: if that were all, then it would just need test functions, and that would be all.
15:44amalloygfredericks: plz to call this on a file with the following contents: "(map inc [1 2]) ;; for testing"
15:44futileamalloy: but i needed a way for you to mark a test as pending without throwing exceptions, and this seemed reasonable: (defn ^:test ^:pending my-test [] ...)
15:45futileI'm open to another way to mark tests as pending statically without depending on its metadata.
15:45gfredericksamalloy: empty map, as I would expect
15:45gfredericksoh hwait
15:45amalloygfredericks: you sure you didn't, say, put a newline at the end of the file? cuz my string doesn't have one
15:45gfredericksthis is about my parens isn't it
15:45gfredericksand the newline
15:46amalloygfredericks: right. wrapping with () and using read-string is a gross hack, when you can just use (read) the way it was meant to be used
15:46gfrederickswith loop?
15:46mthvedtfutile: it sounds like you're assigning something to 'test' what really is a way to help things find tests.
15:46mthvedtonce you've gathered all your test vars, you have no need for the var anymore
15:46futilemthvedt: yes, thats why i want to get rid of the use of vars for test fns
15:46futilemthvedt: but there's still the problem with pending.
15:46amalloygfredericks: well, with take-while and repeatedly
15:46futilei Really dont want to have it throw exception from within the test to tell that its pending.
15:46amalloyor loop, whatever
15:47futilemthvedt: right now ^:pending is part of the metadata. is there a way to define it as part of the function's metadata while ditching the var?
15:47futile,(meta +)
15:47clojurebotnil
15:47futile,(meta #'+)
15:47clojurebot{:arglists ([] [x] [x y] [x y & more]), :ns #<Namespace clojure.core>, :name +, :column 1, :added "1.2", ...}
15:47gfredericksamalloy: in any case that's beside the point; do you know if this function existing elsewhere?
15:47gfredericksif not I'm surprised, given how easy it was
15:48amalloy*shrug* slamhound probably has something similar
15:48gfrederickstechnomancy has said that he wishes this function existed
15:48gfredericksif I understood him correctly
15:49futile,(defn foo [])
15:49clojurebot#<Exception java.lang.Exception: SANBOX DENIED>
15:49futileaw
15:49futile##(defn foo [])
15:49lazybotjava.lang.SecurityException: You tripped the alarm! def is bad!
15:49futileaww
15:49futileamalloy: anyway, any particular reason you said you wouldnt use test2?
15:50mthvedtfutile: with-meta, or #(vary-meta % merge …)
15:50mthvedtany IObj can have metadata
15:51futilemthvedt: right but I don't see any easy way, when using defn, to attach it to the fn itself
15:51gfredericks,(instance? clojure.lang.IObj #())
15:51clojurebottrue
15:51gfredericks,(instance? clojure.lang.IObj #'first)
15:51clojurebotfalse
15:51futileif it was using (def a-test ^:pending (fn)) that's doable, but ugly since it's not using defn
15:51mthvedtfutile: does it need to be attached to the fn itself at defn time?
15:51amalloyfutile: to paraphrase http://blogs.msdn.com/b/ericgu/archive/2004/01/12/57985.aspx, every new project starts out at -100 points
15:52amalloymetaprojects doubly so, imo
15:52futileamalloy: oh, gotcha. chronology-bias
15:53futilemthvedt: my hope is that anyone who has a test-fn (direct fn, not var) can statically determine whether it's pending and should be not run.
15:53futilemthvedt: (and if so, why)
15:53amalloyi also regard test2 as a windmill you're tilting at while you learn clojure. a good thing for your development, but i don't expect a project written by someone who's still asking pretty basic questions in #clojure to change the testing landscape
15:53futileamalloy: hmm
15:53futileamalloy: thats all very fair. thanks for your input :)
15:54amalloyyou're welcome. glad to hear you weren't too offended by my rude bluntness
15:57gfredericksanother win for nerds communicating via plain text
15:57mthvedtfutile: dunno if that's possible at all, if you define tests using defn.
15:58futileamalloy: well you're right, no reason to be offended at the truth.
15:58gfredericksamalloy: are you aware of the undocumented `recursive?` arg to read?
15:58amalloy(inc gfredericks)
15:58lazybot⇒ 24
15:58mthvedtprobably, if something's handing off tests to test2, you can trust it to assign the correct metadata
15:58futilemthvedt: i think it has to be done via exceptions. arg. i didnt want the spec to talk about exceptions.
15:58amalloygfredericks: i just know that it's an arg i never want to pass, and that if you want the doc for it you can probably find it in CLTL
15:59gfredericksthat's a weird single thing to know
16:00amalloygfredericks: i mean, the signature for clojure.core/read was stolen from another lisp, and i'm reasonably certain CL has the same signature. so CLTL is probably the place to look, but maybe it's the hyperspec
16:00gfredericksgotcha
16:00gfredericksthx
16:02futileamalloy: i dont mean to say you're right about it not gonna take off, just that it seems unlikely :)
16:02hyPiRiongfredericks: yeah, it's from CL
16:02hyPiRionfrom the hyperspec: "If recursive-p is true, the call to read is expected to be made from within some function that itself has been called from read or from a similar input function, rather than from the top level."
16:03mthvedtfutile: i don't think pending-ness is an intrinsic property of the test, it's something you attach to a test to say "hey don't run this"
16:03mthvedtthe mechanism that gathers tests should get to decide which tests are pending
16:03amalloyhyPiRion: where is that? i couldn't find it in CLTL
16:03hyPiRionamalloy: http://www.lispworks.com/documentation/HyperSpec/Body/f_rd_rd.htm
16:03futilemthvedt: but some libs let you stop half-way through the test and say "oh no wait nm im actually pending"
16:04hyPiRionoh, it's not in the spec?
16:04hyPiRionthat's a bit strange I suppose.
16:04mthvedtfutile: well, if that's the case, metadata won't help anyway :P
16:04amalloyhyPiRion: http://www.cs.cmu.edu/Groups/AI/html/cltl/clm/node195.html#SECTION002621000000000000000
16:04futilemthvedt: yeah i suppose. i was trying to just ignore those libs and say "lalala i cant hear you" to them
16:05amalloybut it's in the hyperspec; cltl isn't a spec
16:05futilemthvedt: because i REAALLY dont want to add an exception to the spec
16:05finishingmoveanyone into skinning LightTable?
16:05futileDoes LightTable have paredit-like functionality?
16:06hyPiRionamalloy: "Many input functions also take an argument called recursive-p. If specified and not nil, this argument specifies that this call is not a ``top-level'' call to read but an imbedded call, typically from the function for a macro character. It is important to distinguish such recursive calls for three reasons."
16:06amalloyhyPiRion: yeah, i just got to that bit myself. i didn't read that far at first, because the signature looked like it was just at the top
16:07amalloyrather than scattered throughout the text like a gibbon
16:26gfredericks,(namespace-munge "foo.bar-baz$*&")
16:27clojurebot"foo.bar_baz$*&"
16:39antares_wrote a blog post about ClojureWerkz docslate and how you can use it to document your Clojure project well: http://blog.clojurewerkz.org/blog/2013/06/15/how-we-document-our-projects-with-clojurewerkz-docslate/
16:51gfrederickslein has started putting jars under target/provided ?
16:51rodnaphwhen eval'ing code, is there a way to pull in other namespaces? (like... "(require 'foo) (foo/bar 1)")
16:57ianeslickIs there a way to ensure that a particular namespace is evaluated when a jar is on the classpath at load time, or do you have to manually require it from somewhere?
17:01bprianeslick: i'm fairly sure you have to require it. there are tools to scan the classpath to find all the available namespaces though.
17:01ianeslickI'm writing a little library that extends a method; so you have to add it to dependencies and explicltely require it to get the new methods.
17:02ianeslick(I take it)
17:02bpryes
17:04gfredericksyour library has side-effects when you load it?
17:05ianeslickI'm extending a multi-method defined in another namespace. Would be nice if you could just add it to dependencies and get the new methods.
17:05ianeslickBut requiring is fine
17:05bbloomgfredericks: any library that does defmethod has side effects when you load it :-/
17:07Rayneshttp://i1.kym-cdn.com/photos/images/newsfeed/000/322/446/dde.gif
17:07RaynesTechnically any library with a def has side effects when you load it, guys.
17:08ianeslickRight, but having the jar on the classpath doesn't mean it is loaded!
17:08bbloomRaynes: yes, but that side effect has no impact on a consumer who isn't using :use
17:08ianeslickSo it is only loaded when required (when the usual def side effects happen)
17:08Raynesbbloom: I didn't say it did.
17:09RaynesI was merely pointing out that using the word 'side effects' when you mean 'bad things' is probably not a good idea.
17:09nopromptughh, i need halp.
17:09RaynesThere is no doubt.
17:09RaynesCall the poison control center at ...
17:10Raynesnoprompt: Wazzup?
17:10nopromptwell garden is starting to grow (no pun) intendended, and i'm having to think a bit harder about the organization of the library and what stuff goes where.
17:11Raynesnoprompt: (no pun) intendeded
17:11bbloomwell if it's growing as intendeded, what's the problem? (grin)
17:12nopromptRaynes: yeah, my typing skills are bad.
17:12RaynesThat was the most confusing sentence I've read since I read the logs from the last time I got wasted.
17:12nopromptor rather, my re-reading skills.
17:14nopromptRaynes: basically, i'm not sure in some cases what the right choices are when it comes to working with record types and protocols.
17:14RaynesNice. I just realized that having an external mouse plugged in causes OS X to display scrollbars.
17:14nopromptRaynes: it could just be that i'm not used to building a large library in clojure.
17:15nopromptor large libraries in general.
17:15nopromptRaynes: yep.
17:16noprompti mean i'm not gonna commit suicide or anything over it but it'd be nice to have a little feedback from time to time. even if it's heavy on the criticism
17:17Raynesnoprompt: But what if it's so heavy on the criticism that you commit suicide?
17:19nopromptRaynes: the that would imply something i can't even fathom.
17:19Raynesnoprompt: What part are you having trouble organizing>
17:19Raynes?
17:19RaynesThe library is split up pretty well.
17:20tjb1982I'm having a problem connecting to postgres. "No suitable driver found" I have `[org.clojure/java.jdbc "0.3.0-alpha4"]` and `[postgresql "9.1-901.jdbc4"]` in my project.clj file, so I would've thought that would be enough. The `:classpath` arg is "org.postgresql.Driver" and the :subname is `"//postgres:postgres@localhost/myDatabase`
17:21nopromptRaynes: you think? maybe i'm just hard on myself when things aren't dry.
17:25Raynestjb1982: What are you passing a :classpath arg for?
17:26tjb1982I had been using the `with-connection` api previously, and I happened upon some documentation that made mention of that
17:26tjb1982Raynes: when I don't supply it, I get a different error
17:26nopromptRaynes: btw, clojure is hard to teach.
17:28tjb1982Raynes: without the :classname I get a NullPointerException
17:28tjb1982Raynes: sorry, I meant to say :classname not :classpath
17:30tjb1982Raynes: so to be clearer, I had the old with-connection style working before with this "postgres://postgres:postgres@localhost/myDatabase"
17:30nopromptit could just be state colleges, but i get the feeling that universities aren't spending enough time on functional programming.
17:30nopromptby that i meant spending enough time teaching functional programming.
17:34lalilunaIs there a convention to use 'test_foo.clj' instead of foo_test.clj in clojure contrib libs? I stumbled over it as clojure test mode is not enabled by the first one.
17:36SegFaultAXHoly crap, have you guys seen prismatic.com?
17:37akhudektheir domain is getprismatic.com
17:38SegFaultAXakhudek: Prismatic's is, sure.
17:38akhudekSegFaultAX: then I guess I don't get what the big deal is with prismatic.com
17:38SegFaultAXPrismatic Sign's website is like a walk down year 1999 memory lane.
18:07NeedMoreDesuHi. Is there a way to write this with tail-recursion optimizations? http://www.everfall.com/paste/id.php?p7ol3exb0dw1
18:09nopromptNeedMoreDesu: the first thing i would suggest you do is pull that (defn two ..) part out. defn's shouldn't be nested. instead you should probably use something like letfn.
18:10noprompt,(doc letfn)
18:10clojurebot"([fnspecs & body]); fnspec ==> (fname [params*] exprs) or (fname ([params*] exprs)+) Takes a vector of function specs and a body, and generates a set of bindings of functions to their names. All of the names are available in all of the definitions of the functions, as well as the body."
18:10NeedMoreDesuWell, yeah, with letfn. Anyways.
18:11NeedMoreDesuCould it be optimized?
18:11noprompthave you learned about loop/recur?
18:12NeedMoreDesuYou can recur to function "two", but you can't recur to "one".
18:12nopromptso you need mutual recursion?
18:12bbloomNeedMoreDesu: i just want to clarify noprompt's feedback. letfn isn't simply more idiomatic here, defn is *wrong* to be nested
18:12NeedMoreDesuI know.
18:13NeedMoreDesuHm, maybe it's the name.
18:14bbloomNeedMoreDesu: anyway. in *theory* any mutually recursive function can be eliminated by inlining one into the other
18:14bbloomNeedMoreDesu: and any non tail recursive function can be made tail recursive by consuming heap space with an explicit stack in your loop args
18:14bbloomNeedMoreDesu: however, it's generally easier to utilize a trampoline
18:14bbloom(doc trampoline)
18:14clojurebot"([f] [f & args]); trampoline can be used to convert algorithms requiring mutual recursion without stack consumption. Calls f with supplied args, if any. If f returns a fn, calls that fn with no arguments, and continues to repeat, until the return value is not a fn, then returns that non-fn value. Note that if you want to return a fn as a final value, you must wrap it in some data structure and unpack it after trampol
18:15nopromptbbloom: beat me to it. :)
18:15NeedMoreDesuHow do I write my example with trampoline?
18:15Apage43https://www.refheap.com/15814
18:15bbloomwrap your recursive calls in #()
18:15bbloomthen wrap your whole function in trampoline
18:16bbloombut i'm not looking at your example at all, just speaking from first principals
18:18NeedMoreDesubbloom: this works, thanks :3
18:18NeedMoreDesuApage43: Well, yes, but it's not the same.
18:20berdarioDoes someone here knows if it's possible to use the repl from lein-cljsbuild, without a ring (or another kind of) server?
18:21berdarioI'm trying to connect it through a pure cljs application... and in the web inspector console, I see that there's an error when trying to access the robots.txt
18:21berdarioso, I fear that it might not really be fit for this purpose
18:26berdarioUhm, according to this https://github.com/clojure/clojurescript/wiki/The-REPL-and-Evaluation-Environments
18:26berdariothere shouldn't be any server requirements, aside from the repl listener
19:49futilemthvedt: this means at compile time every group *contains* all of its parents: (defn ^:test ^{:group {:description "a group" :parent {:description "another group" ...}} my-test [] ...)
19:49futilemthvedt: that's weird
19:55futilemthvedt: but maybe its not that bad to have every group contain its parent group directly (if it has one), instead of just referencing it..
19:55futileThoughts anyone?
19:58futilecc bbloom gfredericks et al
20:00futilemthvedt, amalloy: ooh yeah I remember another reason I made tests be vars instead of fns: so you can get useful metadata about it for reporting, like the function's name and docstring, etc.
20:07mthvedtfutile: what do you think of having the test finder pick up the metadata
20:08mthvedti'm of the opinion that the piece that does running and reporting shouldn't have any assumptions about where test comes from
20:09futilemthvedt: I was thinking that too. If the finder is responsible for knowing about ^:test, perhaps it can translate :name and :doc etc too. Only problem is, where does it store this information, if a test is supposed to be just a function, plain-and-simple?
20:10futilemthvedt: Can functions reliably house metadata? http://clojure.org/metadata says only symbols and collection, even though I think it might technically *work* for a function.
20:14mthvedt,(meta (with-meta (fn [] 'foo) {:a :b :c :d}))
20:14clojurebot{:a :b, :c :d}
20:15futileSo it seems to work, but is it reliable? Who knows.
20:16futile,(let [f (with-meta + (meta +)] [f (meta f))
20:16clojurebot#<RuntimeException java.lang.RuntimeException: Unmatched delimiter: ]>
20:16futile,(let [f (with-meta + (meta +))] [f (meta f)]
20:16clojurebot#<RuntimeException java.lang.RuntimeException: EOF while reading>
20:16futileugh
20:16futile,(let [f (with-meta + (meta +))] [f (meta f)])
20:16clojurebot[#< clojure.lang.AFunction$1@c943ba> nil]
20:17hyPiRionI think you meant this
20:17futileprobably
20:17amalloymetadata on functions is reliable, but i don't know why you want to use metadata at all. what is "better" about '[^{:test blah :doc whatever :name foo} f ^{:test more} g] than '[{:test blah :doc whatever :name foo :fn f} {:test more :fn g}]?
20:17hyPiRion,(let [f (with-meta + (meta #'+))] [f (meta f)])
20:17clojurebot[#< clojure.lang.AFunction$1@139110c> {:arglists ([] [x] [x y] [x y & more]), :ns #<Namespace clojure.core>, :name +, :column 1, :added "1.2", ...}]
20:18hyPiRion(with-meta foo (meta foo)) is like saying just foo.
20:18futileamalloy: i.e. where "test" would be a map of info about a test, including the test fn itself?
20:19amalloyindeed
20:19mthvedtfutile: i use a 'punning' approach in this parser lib i wrote, https://github.com/eightnotrump/clearley
20:19mthvedtwhere a parse rule can be one of several things, and there are exposed fns to turn them into "full fledged" rules
20:19futileamalloy: I dunno. I think part of the initial attraction was how simple it would be to find and run tests. This adds a little complexity to the intermediate functions, although I think it's probably worth it and usually hidden enough inside "required" functions to be unnoticable.
20:19mthvedtit's a little messy but was much less messier than other approaches i tried--protocols, multi methods, putting conds in everything…
20:22futileie, its really not that bad if you have to do (run-test (test-from-fn my-widget-test))
20:22mthvedtso you could say that a test is a var, or a fn, or a test record, and expose a punning multi method
20:22mthvedtthat might be too heavyweight
20:23futilemthvedt: yeah I try my best to always avoid "you could give it this, or this, or this, or this, or even this if you want, and itll Just Work™"
20:23futilethats nothing but HeadacheVille and BugLand
20:24mthvedtfutile: clojure has a lot of that kind of punning. i don't think there's a problem as long as you try to stay well defined
20:24DuffmanHello, I'm experiencing some problems in Clojure and I'd like to get a second opinion on it as I have no ide at all what's going wrong. Should I paste my code in pastebin or so to get help here?
20:24gfredericksDuffman: sure
20:24futileDuffman: we like refheap.com
20:25mthvedtbut if you're not careful with your mishmash of types, you end up with javascript
20:25Duffmanalso I should admit that I'm doing this in the context of a school assignment
20:25DuffmanI hope that's no problem.
20:25futilemthvedt: [] + {}
20:26futilemthvedt: oh sorry I meant {} + []
20:26amalloyDuffman: go for it
20:27DuffmanOkay thanks. I'll just be a minute. I'm writing some context
20:33DuffmanOkay, here goes: https://www.refheap.com/b36e93390aed8c1b132639cab
20:33DuffmanI tried to add some context at the top of the file. The first time i get an element from the cache, it all works fine. But if I type "c" then in my REPL (look at the end of the file) or do another cache-get, it fails utterly.
20:35DuffmanIt looks as if "c" is broken once I invoke (cache-get c :a) because if I type "c" in the repl after this first invocation (which works fine); I get this error;
20:35DuffmanStackOverflowError java.util.HashMap.get (:-1)
20:36Duffmanif the description of the purpose is not clear, I can supply you with some more information
20:38amalloyis the stuff in the context a required way to implement the algorithm, or a description of how you've chosen to go about it? because it seems crazily complex
20:40Duffmanit's sort of required
20:41Duffmanit's a suggested way to do it
20:42amalloylike, if i were implementing an lru cache around a function, i would just have two maps: hashmap from key->value and sorted-map of access-time->key
20:42Duffmanbecause the cache needs to be so efficient.
20:42Duffmanyeah, that would be simpler but it should be more efficient than that
20:43DuffmanI'm not sure whether this is more efficient but I think they just want to add a degree of difficulty
20:43amalloythe description doesn't sound efficient at all. doubly-linked lists in a functional language are basically impossible, and reimplementing a hashmap by hand is a sure way to get slow code
20:44amalloyanyway, if you have to do it that way then you have to, i guess. but i can't make heads or tails of the code, so hopefully someone else can help
20:45Duffmanhttps://www.dropbox.com/s/d68b586csffu2gb/Project-Clojure.pdf
20:45Duffmandescription of the exercise
20:46DuffmanI know I'm starting late but I had to hand in a thesis yesterday and that really got my priority
20:57DuffmanThanks for looking at it anyway amalloy!
21:01hyPiRionDuffman: So the properties that you want for that second data structure is fast removal of an element you know exists in the structure, along with fast insertion at the front
21:02hyPiRionAlong with order
21:02Duffmanyes
21:02DuffmanI found one of my errors btw, on line 86 I should deref first, instead of ref
21:02Duffmanso I'm working on a new problem now
21:03DuffmanI'll try to fix it on my own first
21:04DuffmanI know see a lot of other errors like not adding keys to the cache and stuff like that, so I'm going to look into that first
21:04hyPiRionok
21:08wei_cljsbuild just started throwing this: Exception in thread "main" java.lang.RuntimeException: No such var: json/pprint, compiling:(cljs/source_map.clj:142:7)
21:08wei_anyone seen that before?
21:12DuffmanhyPiRion: one small question though if you don't mind
21:12amalloyi wonder if you just want a ring-buffer instead of a doubly-linked list
21:12Duffman(repeat 5 (ref '()))
21:12hyPiRionsure
21:12Duffmanthat spawns a list of 5 refs
21:12amalloyDuffman: that's the same ref five times, not five different refs
21:12Duffmanyes indeed
21:12Duffmanhow can I make them different?
21:12amalloy&(doc repeatedly)
21:12lazybot⇒ "([f] [n f]); Takes a function of no args, presumably with side effects, and returns an infinite (or length n if supplied) lazy sequence of calls to it"
21:12DuffmanI thought that ref made a new pointer everytime
21:13hyPiRion,(vec (repeatedly #(ref '())))
21:13amalloyDuffman: it does. but you only called it once
21:13clojurebot#<OutOfMemoryError java.lang.OutOfMemoryError: Java heap space>
21:13hyPiRionoh ops, I forgot the amount
21:13Duffmanhm that documentation makes sense
21:13DuffmanI had no idea repeat worked like that
21:13Duffmanbut it has to work like that
21:13Duffmanotherwise repeat until infinity couldn't be possible
21:14amalloyDuffman: repeat just takes a value, and gives you N copies of it
21:15Duffmanthanks amalloy, got it
21:17hyPiRionamalloy: persistent of mutable ring buffer? I haven't heard of a persistent ring buffer before, but how would you provide fast random-time removal?
21:17hyPiRions/of/or/
21:17papachan&(doc slurp)
21:17lazybot⇒ "([f & opts]); Opens a reader on f and reads all its contents, returning a string. See clojure.java.io/reader for a complete list of supported arguments."
21:17amalloyhyPiRion: i already have!
21:17amalloy$google amalloy ring buffer
21:17lazybot[amalloy/ring-buffer · GitHub] https://github.com/amalloy/ring-buffer
21:18amalloyanyway, he doesn't need fast removal from anywhere, only from the end, right?
21:18amalloyi think you're right that ring buffers aren't right, but it's close
21:18hyPiRionamalloy: he need to update elements if they're in the cache
21:18Duffmanit's not really removal amalloy
21:18amalloyi'd still use a sorted-map, personally, since it's O(log(n)) on an n that's known to be small, but if he needs O(1)
21:19DuffmanI have to add an element at the front of the list, and the one-but-last element it's next should then refer to 'nil'
21:19hyPiRionRight, it's "push-to-front"
21:19Duffmanits next*
21:21hyPiRionDuffman: I think it's smart to just implement a version using a sorted-map and a counter first
21:22hyPiRionJust so you have something to deliver
21:22Duffmanyeah maybe you're right
21:22Duffmanthis does make things complicated
21:24hyPiRion"It is not necessary to make use of Java
21:26Duffmanindeed
21:26hyPiRionthat's what confuses me, heh.
21:35gfredericksfor programs whose main output goes to STDOUT, is printing progress messages to STDERR considered normal behavior?
21:35gfredericksby "main output goes to stdout" I really meant that progress messages would corrupt the output
21:36hyPiRiongfredericks: depends. For e.g. lein classpath, we would like "fetching repository..." messages to be stderr so that you can pipe the results of lein directly into another command
21:39zRecursive&(doc ->)
21:39lazybot⇒ "Macro ([x] [x form] [x form & more]); Threads the expr through the forms. Inserts x as the second item in the first form, making a list of it if it is not a list already. If there are more forms, inserts the first form as the second item in second form, etc."
22:28tomjackgfredericks: wget is an example which does that
22:29tomjackalthough, hmm, what's STDOUT? empty?
22:51noahlzhttp://stackoverflow.com/q/17129117/7507
22:51noahlznoticed this question, wondering about the answer
22:51noahlz"something like find-doc but that gives you a prompt of matching names"
22:52noahlzremember seeing it too
22:54xeqi&(doc clojure.repl/apropos)
22:54lazybot⇒ "([str-or-pattern]); Given a regular expression or stringable thing, return a seq of all definitions in all currently-loaded namespaces that match the str-or-pattern."
22:58noahlzhmm
22:58noahlzyeah, the person asking this seems to think it is clojure.contrib.repl-utils/show
23:08wei_for anyone else who runs into this exception: Exception in thread "main" java.lang.RuntimeException: No such var: json/pprint, compiling:(cljs/source_map.clj:142:7).. my fix was to add [org.clojure/data.json "0.2.2"] to my project
23:09bbloomwei_: dnolen added that as a dependency to cljs. i guess maybe you've found a lein-cljsbuild bug? or are on an older version?
23:10wei_I'm on 0.3.2
23:11tomjackI experienced that as well. my guess is `lein cljsbuild clean` would fix it
23:11futileGents.
23:12futileAnd ladies, but I can't tell the difference in here.
23:12futileDoes it make sense to just use exceptions to tell that a test is pending?
23:12dnolenwei_: that should just work - but I'm not 100% sure
23:13dnolenwei_: in anycase, bbloom is correct, if it doesn't work cljsbuild and clojurescript are out of sync
23:14wei_thanks, I've fixed my project by adding the data.json dependency, but it fails if I take it out. investigating more to see if I isolate the problem.
23:15futileI think no other lib uses "pending" except speclj.
23:15wei_dnolen: btw, does the existence of cljs/source_map.clj mean we'll see cljs source in the inspector soon? :)
23:15muhoointeresting, if i use a library whose license is EPL or MPL, and there's no documentation, just code in test/core.clj, i can't use that code unless i keep the whole app EPL/MPL?
23:16dnolenwei_: there's basic support there, but we need more accurate information from the reader, this work is supposed to be part of GSoC 2013
23:16wei_sounds good. that's a killer feature
23:19muhoohmm, nevermind, i'm so used to GPL i forgot that EPL and MPL aren't quite that strict.
23:38wei_it appears that adding a library that includes a previous version of data.json, like [clj-pusher "0.3.1"], breaks cljsbuild unless you include the newest data.json in your own project.clj. demonstration app here: https://github.com/yayitswei/cljsbuildtest
23:43akhudekhttps://github.com/akhudek/zip-visit
23:44akhudekjust finished some docs for the above library, hope it's useful to someone
23:45dobry-den1if you define a function within a (let […]), that will get defined every time the fn is called. is that reason enough to extract those functions and use (defn- …) instead?
23:45dobry-den1wait a second...
23:45dobry-den1nevermind
23:46DuffmanI built a small use-case
23:46Duffmanhttps://www.refheap.com/15821
23:47Duffmananybody any idea why 'y' doesn't work anymore?
23:47Duffmannor does x
23:47DuffmanI'm guessing its because they refer to each other and you shouldn't do that in clojure?
23:48amalloyDuffman: the exception is when the repl tries to print them
23:48Duffmanoh
23:48amalloymutually recursive refs aren't really a good idea, but they're perfectly possible
23:48Duffmanbut the repl can't print them because he keeps on jumping back and forth between both?
23:49amalloyright
23:49DuffmanI see
23:49Duffmanmakes it hard for debugging
23:49DuffmanI've literally been looking into this for the past 2 hours
23:49Duffmanlooks like it's a limitation of the REPL
23:49amalloynot half as hard as having mutally-recursive mutable state does :P
23:50tomjackif you set *print-level* you can print them
23:50amalloycan you? i thought print-level was for nested lists, not nested print invocations
23:50amalloybut even as i say it now, it sounds crazy
23:50tomjackI dunno how it works, but just tested to see if it works on refs
23:51Duffmanhow do you set the print-level Tom? http://clojuredocs.org/clojure_core/clojure.core/*print-level* doesn't give an example
23:51tomjack(set! *print-level* 4)
23:51DuffmanI see
23:51Duffmanthx
23:51tomjacknot that I think you should be doing what you're doing :)
23:52DuffmanI know
23:52DuffmanI was just experimenting
23:52tomjackhmm, I'm confused
23:53tomjackthe only use of *print-level* seems to be in print-sequential
23:53tomjackoh, but the print-method for IDeref uses print-sequential