#clojure logs

2012-03-22

00:05gfredericksI think there's something about (def foo #'bar)?
00:10brehaut#' is var quote; #' is equivalent to (var bar)
00:11brehautif you quote the var, you get the var itself rather than whatever it points to
00:11brehautso if the var is updated (eg, by def) then anything calling through that var gets the new version
00:11brehautyes
01:35y3dihow do you go about finding a mentor?
02:14coltnzhi can anyone suggest the idiomatic way to prevent this:
02:14coltnzuser[9]: (apply str/trim []) --------------------------------------------------------------------------- clojure.lang.ArityException: Wrong number of args (0) passed to: string$trim
02:16ivancoltnz: how many items can your vector have?
02:16coltnzwell it can have 0+ and its the zero bit thats the problem
02:17ivan(user=> (map clojure.string/trim ["hey " " hi"])
02:17ivan("hey" "hi")
02:17ivanand really? it doesn't take more than 1 arg here
02:18coltnzhmm maybe i do want map
02:45RaynesYou do.
02:56rudyl313is (def ^{:private true} sym "val") the only way to make the sym symbol namespace private?
05:22muhoo(= fun-fun-fun (reduce + [clojure incanter couchdb clutch]))
05:22clgvmuhoo: what are you doing?
05:27amalloyaw, (apply + ...) is surely more appropriate here
05:27amalloyyou're not adding pairwise, you're throwing them all into a big pot and stirring
05:28alcyfolks, is there something like a Learn you some clojure apart from tryclojure(which was great while it lasted!)
05:29RaynesDamn. Now I feel bad for not writing more tutorial.
05:30Raynesalcy: http://java.ociweb.com/mark/clojure/article.html is a pretty nice introduction.
05:31alcyRaynes: yep, tryclojure site suggested that, just didnt feel as awesome as tryclojure :) will work with it anyway
05:31Licenserdun dun dun
05:32Rayneshttp://www.unexpected-vortices.com/clojure/brief-beginners-guide/ I think this is more recent.
05:32RaynesNot sure of quality though.
05:32Raynesalcy: I apologize. :(
05:32RaynesI'd write more tutorial but I'm also writing a book that will be freely available online and thus a bit more of a resource than tryclojure.
05:33RaynesI was hoping somebody else would come along and add some tutorial but nobody has done so.
05:33alcyRaynes: you wrote tryclojure ? awesome, thanks for that! good to know about the ebook, should be nice
05:33RaynesI did. With plenty of help, of course. :)
05:34alcyi have played with higher order perl some and so this looks familiar a bit, will spend some time on data structures
05:36alcyRaynes: anyway, thanks for the hel
05:36alcylol s/hel/help
05:36RaynesYou're welcome for both the hel and the help.
05:44clgvalcy: get you a book ;)
05:46clgvRaynes: your second link seems to be more of a bootstrap summary for clojure ;)
08:19caspercI am messing around a bit with records, and I am wondering - is it possible to have a private field on the record which is not initialized when creating the record but loaded later?
08:34fliebelcasperc: Why would you want to do that?
08:35fliebelI suppose you could play some nasty scope tricks..
08:46clgvsounds too OOPy ;)
08:51caspercYeah, it probably is too OOPy indeed.
09:50solussdso, I'm experimenting with Noir for a project that will have both an html front-end and a RESTful interface. Does anyone know how I can check the "Accept" header to see if it is, e.g., application/json, so I can determine what format to respond with?
09:51cemericksolussd: there are a couple of content negotiation libraries out there that work well with ring.
09:53cemericksolussd: Something like webmachine is the Right Way to do stuff like this though. It's not done yet, but bishop looks promising: https://github.com/tnr-global/bishop
09:53solussdI was looking at the noir.request/ring-request function, which I think is suppose to return the request, but I haven't been able to squeeze headers from it. :/
09:54cemerickIf it's actually returning the ring request, it must have :headers
09:54solussdhmm. i'll checkout the clojure web machine port, thanks
09:55cemerickAccept-* headers can get gnarly though. I wouldn't really want to parse them myself.
09:56solussdi was hoping to build on top of noir for both the web and rest side of things and dip down into the lower levels when needed
09:56cemerickthere's no reason why you shouldn't be able to use noir where you want.
09:57cemerickit's all ring handlers; from the readme of bishop, you should be able to map content types to ring handlers, including noir'rs.
09:58solussdk. I got some reading to do then. :D
10:11ohpauleez lynaghk ping, again
10:17fishmacsI found clojure use vector instead list in many places, is it because of JVM?
10:19solussdfishmacs: it looks different than a list, so it stands out against the parentheses; it's more efficient to construct new vectors from existing ones when you're not adding to the front
10:19RickInGAfishmacs: probably lots of reasons, for me, I like not having to quote vector…. and what solussd said :)
10:24fishmacsI doubt syntax convenient is not a big reason for vector, seems a "modern" choice ?
10:26RickInGAfishmacs: the code seems a lot easier to read when it isn't all parens
10:26fishmacsRickInGA: yes, it is true. but is it main reason?
10:28stuartsierraBy convention, Clojure uses Vectors instead of Lists to distinguish "data" from "code." |n Clojure syntax, Lists almost always mean "call a function, macro, or special form." Vectors are commonly used for things that are not directly executed, like function parameters. There are exceptions to this convention, notably in the `ns` macro.
10:29ejacksonI figure also vectors are much like lists with the added advantage of O(1) lookup by index, rather than O(n).
10:29fishmacsstuartsierra, but in lisp, code is the data?
10:29RickInGAfishmacs: also, vector useful when you want to find things by index, and someitmes you want to add stuff at end. If you want to grow at front, use list and to hell with convention!
10:29stuartsierrafishmacs: Yes, but there's "data that represents code to be executed" (lists, usually) and "data that's just data" (vectors, usually).
10:30fishmacsejackson: vector may waste many memory space
10:31ejacksoni usually have more memory than time...
10:31stuartsierraClojure's vectors and lists are both persistent tree-like data structures which make pretty efficient use of memory.
10:31fishmacsOh, I think vectors are array-like?
10:32stuartsierrafishmacs: Clojure's vectors offer similar behavior to classical arrays (indexed, near-constant-time lookup) but they are actually trees.
10:35fishmacsthinks stuartsierra, I forgot vector is immutable
10:35stuartsierrayes, all Clojure's data structures are immutable and persistent
10:37fishmacsstuartsierra, you said both vector and list are tree-like, is clojure list the conventional FP list?
10:38stuartsierrafishmacs: It is not a conventional singly-linked list, if that's what you mean.
10:38fishmacsstuartsieera: yes,this is what I meant
10:38stuartsierraBut Clojure also has sequences, which are an abstraction that behaves similarly to the lists in functional languages like Haskell.
10:42_andrew_kwhat about maps ?
10:42fishmacsis old list in functional language out of time? I had read some posts talk performanace penalty of list
10:43patrikkarlindepends on how you use it
10:44ejackson_andrew_k: maps are also perstistent, tree like structures
10:45ejacksonin fact they are trees under the hood
10:45ejacksoncheck out http://blog.higher-order.net/2009/09/08/understanding-clojures-persistenthashmap-deftwice/ and the link to Vectors
10:45fishmacswhy clojure give up conventional list as its basic data structure?
10:46patrikkarlinmost of my code is lists
10:46clgvfishmacs: immutability and structure sharing between original and "mutation"
10:47fishmacsclgv: I think conventional lists also provide immutability and sharing
10:48clgvfishmacs: a simple single linked list can't do that
10:50fishmacsclgv: single linked lists can share their tails
10:50ejacksonyeah, but tries can share anything and are very fast.
10:50clgvfishmacs: but they could be edited as well.
10:52djwhitthmm... isn't this the implementation: https://github.com/clojure/clojure/blob/master/src/jvm/clojure/lang/PersistentList.java
10:52stuartsierraI take back my earlier statement. Clojure's lists ARE singly-linked lists, with a few extra features.
10:53djwhittyeah, was about to say, that looks a lot like a singly linked list to me :)
10:53stuartsierradjwhitt: I was thinking of vectors instead.
10:53stuartsierraok, time for me to get back to work
11:02fishmacs`think about (vec (map + [1 2 3] [4 5 6])), I have to convert back and forth between vector and sequence, I must pay some price?
11:03ejacksonfishmacs`: map works with seq, which is very fast to create,
11:04ejacksonso you get a seq over [1 2 3] and [4 5 6], and then construct a vector for the results
11:04ejacksonno more than any other immutable system
11:06fishmacs`ejackson: so if clojure is pure, it would select sequence as its basic data structure?
11:06ejacksonsequence is basic abstraction
11:06ejacksonbut its not a datatype
11:07cemerickfishmacs`: actually needing a vector instead of a sequence is rare
11:07fishmacs` I mean an implement of the abstraction, just like the implement you get from [1 2 3] and [4 5 6]
11:10fishmacs`yeah, I'm a newbie, just a little confusing about the choice of data type. I think imperial languages's basic data types are array-like, and functional languages's are singly-linked list
11:11TimMcfishmacs`: Traditionally, yes. Not with Clojure.
11:12TimMc$google clojure vector tree 32-way
11:12lazybot[Understanding Clojure's PersistentVector implementation | Higher ...] http://blog.higher-order.net/2009/02/01/understanding-clojures-persistentvector-implementation/
11:13fishmacs`think you guys, I need read a lot more to understand the decisions made under hood
11:15TimMcfishmacs`: All you really need to know here is that vectors, maps, and sets in Clojure have O(n log n) insertion time.
11:15ejacksonwhere log is base 32... so FAST
11:15TimMcBasically linear.
11:16clgvTimMc: errm, n*log n? that sounds not right
11:16fishmacs`O(log n)
11:17rhcyeah n log n for a vector would be pretty bad
11:17rhcconsidering non-immutable usually has o(1)
11:17ejacksonyeah, log_32 n.
11:17rhcand its supposed to be "equivalent", right?
11:18mknoszligrhc: in practice, yes
11:19fishmacs`rhc: what supposed to be equivalent? O(1) and O(log_32 n)?
11:19rhcfishmacs`: right, that's my understanding
11:19ejackson,(/ (log 10000) (log 32))
11:19rhcconsidering log_32 2^32 is 6
11:19clojurebot#<CompilerException java.lang.RuntimeException: Unable to resolve symbol: log in this context, compiling:(NO_SOURCE_PATH:0)>
11:19rhcmeans, a pretty bad case will result in 6 tree traversals
11:20mknoszligrhc: in big O, 6 = 1 ;)
11:20ejackson,(/ (Math/log 10000) (Math/log 32))v
11:20clojurebot2.65754247590989
11:20rhcmknoszlig: well yes, once you know n
11:20ejacksonlog_32 is a strong function
11:20rhcin bigO O(log n) and O(log_32 n) are equivalent too
11:20TimMcEep, O(log n), right.
11:20rhcluckily people are realizing there's more than just 1, log n, n log n, and quadratic of n
11:21rhcespecially whne you have an awesome fast O(1) alg with a massive constant time
11:21rhcso its super fast for n = 2^32 and slow for n = 100
11:21TimMcRight, that's why we have benchmarks. :-)
11:21rhcand profiling :)
11:21rhcsame thing I guess :D
11:21mknoszligrhc: that's two different aspects of optimization, no?
11:21TimMcNah, profiling is better.
11:22TimMcerr
11:22TimMcIgnore me today, I am having trouble with words.
11:22TimMcWhat I *meant* was, performance tests on your real data is better than benchmarks on made-up data.
11:23rhci figured as much
11:39Bronsahmhm
11:39BronsaI have a question.
11:39Bronsasuppose i define a protocol P and extend it to String from the namespace a
11:40Bronsaif i extend it again from a namespace b, is there anyway to refer to the implementation defined in the namespace a?
11:40Bronsa*any way
11:42TimMcYou're trying to extend the same protocol to the same class twice?
11:42Bronsayes
11:42Bronsait's just ipotetic, not really sure if this will ever happen to be needed
11:47TimMcI haven't worked with protocols, but my understanding is that extending protocol P to type T is only done when you own either P or T.
11:48TimMcSo in this case you'd do the extension in the same ns where you define the protocol and be done with it.
11:52konrWhat's the right way to add a library with its current version to project.clj? Manually copying the line from clojars.org? If so, is there a way to automatize that?
11:57clgvkonr: what do you want to automatize? resolution of the current version?
11:57konrclgv: yes
11:58fishmacs` q
11:58clgvkonr: but often you will have to decide which version you really want to use
11:58clgve.g. basic question: stable vs snapshot
11:59clgvkonr: lein search should help you finding out what versions exist
12:04konrclgv: thanks!
12:08cemerickTimMc: You can extend P to T even if you don't own P or T. That's one of the big draws of protocols.
12:23romanandreghey dnolen, where can I find the source code for PersistenVectors in cljs?
12:23dnolenromanandreg: https://github.com/laczoka/clojurescript/commit/a1409dfe6a1dfb4c3f35aba69bd43a0e281af5a5
12:24romanandregdnolen: awesome! thanks
12:39TimMccemerick: But is that wise?
12:41cemerickTimMc: well, if you need some type to participate in a protocol, there aren't a lot of alternatives.
12:41cemerickIf one of the owners does introduce support later on, you can retract your extension.
12:47technomancyisn't that the moral equivalent of monkeypatching though?
12:48technomancynot that you should never do it, but that it renders protocols advantages over monkeypatching void
12:51dnolentechnomancy: not quite. protocols mean something. If someone else extends String to ISeq, not a big deal.
12:52technomancydnolen: well, monkeypatching is also not a big deal when there are no collisions.
12:53dnolentechnomancy: not even remotely the same guarantee.
12:54dnoleneven if several implementations replace one another, in the protocol case - who cares?
12:54technomancypresumably the one that loses cares?
12:54dnolentechnomancy: why?
12:55dnolenif someone is side-effecting in an ISeq implementation - that's their problem.
12:55dnolenthey have a broken implementation.
12:55technomancysure, but what if the broken one wins?
12:55dnolentechnomancy: one library you'll never use again.
12:55technomancyyes
12:55technomancyso... exactly the same as monkeypatching
12:56dnolentechnomancy: no because in the monkeypatching case there no zone of agreement.
12:57technomancyit's still easy to get bitten by subtle differences
12:57technomancyprobably not on ISeq, but as a rule
12:58dnolentechnomancy: as a rule it should never matter. if it does you probably shouldn't be writing a protocol.
12:59technomancywell that won't be a problem for me then =)
13:02wmealing_I'm sure there is a better way to do this (functionally) can someone help me with the terms/ideas i should be learning to implement it correctly ( http://hastebin.com/qakobinudu.lisp )
13:04lpetitJust released Counterclockwise (An Eclipse Plugin for Clojure projects) version 0.6.0. http://code.google.com/p/counterclockwise/wiki/CuttingAReleaseRecipe
13:04wmealing_its short, its sweet, and you know it complete known as fizz buzz or something something
13:04dnolenlpetit: cool! is that the right url?
13:05lpetitcrap
13:05lpetitCounterclockwise Release Note: http://code.google.com/p/counterclockwise/wiki/ReleaseNotes?ts=1332435665&amp;updated=ReleaseNotes
13:05lpetitdnolen: thx
13:05devnugh, parsing the clojure cheatsheet is a bummer
13:05lpetitcrap again
13:06lpetitWhat's wrong with me today :)
13:06lpetithttp://code.google.com/p/counterclockwise/wiki/ReleaseNotes
13:07dnolenlpetit: neat that you've got the beginnings of ClojureScript support in there
13:07lpetitdnolen: as stated, really minimalistic, but definitely on the roadmap, right after Leiningen support
13:07wmealing_sweet, i shall try it.
13:09dnolenwmealing_: https://gist.github.com/2159796 is how I would do it.
13:12wmealing_looking now dnolen
13:12wmealing_ah
13:13wmealing_thanks, didnt know about else being used that way
13:18technomancyhttps://blogs.oracle.com/jrose/entry/value_types_in_the_vm <- interesting that John Rose says it's dangerous to allow identity? to be called on value objects
13:19cemericklpetit: Do you know what "real" cljs support would look like?
13:19cemericki.e. I wonder if, once lein tasks are available, that simply "use lein-cljsbuild" would be enough.
13:20lpetitcemerick: not really. The tricky part will be if one wants to use the REPL, right ?
13:20dnolencemerick: I would think so, there should be support to launch ClojureScript REPLs (Rhino, Browser) as well
13:21lpetitwhat does lein-cljsbuild provide, in short?
13:22dnolenlpetit: tricky? since you control the environment you can just fire up a regular Clojure REPL and start the Rhino CLJS REPL
13:22dnolenlpetit: or start the Clojure REPL and start the browser REPL on the user defined port
13:23cemericklpetit: auto-compliation of cljs files, among other things
13:23lpetitcemerick: this auto compilation of cljs files could be easily accomplished via a ClojureScript Eclipse Builder, right?
13:24lpetitcemerick: or does lein-cljsbuild embed too much goodness related to this auto compilation stuff to be ignored? (or maybe this can be extracted in a non-leiningen-based dependency?)
13:24lpetitcemerick: or maybe just use lein-cljsbuild :)
13:24cemericklpetit: probably, but I'd think cljs is moving too fast yet to expect such a thing to keep up vs. an easily-upgradable lein plugin
13:25lpetitcemerick: I understand, and that's part of the idea of not having done cljs support first, and rather leiningen first
13:25cemerickright
13:25lpetitcemerick: My concern is wrt to Windows support in third-party leinigen plugins
13:26lpetitcemerick: whereas I know that Eclipse handles OS specifics very well
13:26cemerickIt's a valid concern, but hardly one exclusive to eclipse.
13:26cemericki.e. if cljsbuild falls down on windows, that'll get noticed pretty quickly I'd think
13:27lpetitcemerick: no option is discarded atm. We'll see what the state of the art is when a first round of leiningen support is done, and there's room to work on cljs support
13:28cemerickre: REPLs, we can quite trivially run a cljs repl, but a lot of the expectations around REPLs fall down in that scenario. i.e. no completion, no go-to-declaration, not sure what sessions look like, no potential (or use for?) rich content returns…
13:29cemerickit's sort of an uncanny valley situation where, it's a REPL all right, but everything is different by one or two degrees.
13:29technomancyno metadata ಥ_ಥ
13:29cemerickRight. Insofar as everything we've built for Clojure depends on a dynamic running introspectable environment…
13:30dnolentechnomancy: cemerick: metadata is preserved. introspective facilities is an open ticket on JIRA.
13:32cemerickWhat do tools look like for Coffeescript? Is it an equivalent to cljsbuild + a console + a text editor + chrome inspector, or has anyone worked out anything more sophisticated than that?
13:33dnolencemerick: CoffeeScript dev mostly like JS dev, with the added step that you start of the compiler to watch files.
13:33lpetitCCW Version 0.5.0 has been downloaded 7093 times, let's see whether Version 0.6.0 can do better :)
13:33dnolencemerick: CLJS dev is already quite a bit more sophisticated if the tools support it - Emacs, SublimeText 2 is very good.
13:35technomancydnolen: metadata on defns? or just metadata that's explicitly attached to data structures?
13:36patrikkarlinOo has sublimetext 2 anny slime esk things?
13:36dnolentechnomancy: all the usual stuff that can't exist in the evaluation environment lives in an atom - namespaces.
13:37technomancycool; is that new-ish?
13:37dnolentechnomancy: all that's required is a cljs.reflect|introspect to call back into the complier to request information
13:37dnolentechnomancy: no been there the whole time as far as I know.
13:38technomancyaha
13:38lpetitdnolen: there are a bunch of core functions which are not yet implemented, right, such as clojure.core/public-*, right ?
13:38photexso figured out that my inability to clojure-jack-in last night was that rlwrap was hitting SIGFPE when run from emacs
13:38Zokalpetit: do you use latest nREPL in CCW 0.6.0?
13:39photexI had finally gotten around to installing it to get rid of the warning when running lein
13:39lpetitZoka: this has been saved for CCW 0.7.0.
13:39dnolenlpetit: yes anything that requires reified vars/nses has not been implemented yet.
13:39lpetitWill be released as a BETA version soon, next thursday
13:39photexso heads up in case anybody hits the same issue
13:39lpetitZoka: ^^
13:39dnolenpatrikkarlin: not slime stuff, more like inferior lisp via SublimeREPL
13:40Zokalpetit: Thanks
13:40lpetitdnolen: if I understand correctly, a new implementation, specific to cljs, of these functions can be written, based on the content of the atom you mentioned above?
13:40photexquick question for anyone who might know: clojure.java.shell <- is this the recommended way to launch and monitor long running processes?
13:41photexI don't see an obvious mention of streaming output back into my app
13:41photexshould I just punt and look at native java solutions?
13:41dnolenlpetit: yes, we already have communication between compiler and runtime environment - we just need to extend it to support introspection.
13:42technomancyphotex: yeah, leiningen had to reimplement clojure.java.shell since it assumes you're going to want to wait till the process exits
13:42photexcool, thanks technomancy
13:43technomancyphotex: also, rlwrap should be disabled if it detects $INSIDE_EMACS
13:43technomancyis that not the case for you?
13:43lpetitdnolen: I have existing code which uses the usual suspects in clojure.core for introspection. Is the intent of the issue mentioned above to implement those same usual suspects (so that my introspection code can work the same without adapting my code)?
13:43photextechnomancy apparently not, I just built it from source though
13:43photexat work I use CentOS 5.3
13:43technomancyphotex: why from source?
13:43photexrlwrap
13:43technomancythe 1.x branch?
13:44photexI didn't pay attention actually
13:44technomancythe master branch doesn't use rlwrap
13:44dnolenlpetit: pretty much.
13:44photexI built rlwrap 0.37
13:44dnolentechnomancy: wow, this is a cool feature of lein 2, http://sunng.info/blog/2012/03/my-favorite-feature-in-leiningen-2/ !
13:45photexoh, I'm using Leiningen 1.7.0
13:46photexwhenever I run lein I get the rlwrap warning; so I installed it and didn't notice the issue right away
13:46photexat first I thought .emacs.d was hosed because of a power outtage
13:46technomancydnolen: a transitive feature, if you will; that's all cemerick and xeqi.
13:46technomancybut yeah, handy to have around for sure
13:46dnolentechnomancy: that is RAD
13:47photexbut then I realized that the SIGFPE error was prefixed by rlwrap:
13:47photexso I renamed rlwrap to rlwarp.BAK in my ~/bin
13:47photexproblem disapeared
13:47technomancyphotex: what version of emacs? maybe checking $INSIDE_EMACS isn't reliable.
13:48photexI had to build Emacs from git
13:48photexI think it's 24.0.x
13:48xeqidnolen: got to be careful with that. if you pull in two dependencies seperatly you can get some conflicts if they rely on different versions of a sub-dependency
13:48xeqibut it works well enough
13:48photex24.0.93.1
13:48xeqifor simple playing around with a library
13:49cemerickxeqi: we'll be able to warn or fail in such scenarios eventually
13:49technomancyphotex: weird. can you open an issue on github for that?
13:49photexsure thing
13:49technomancydefinitely shouldn't be a problem
13:49cemerickand here I considered pulling the add-classpath stuff out of pomegranate some while back :-P
13:50dnolentechnomancy: the speed at which lein2 launches is a repl is pretty slick.
13:52technomancydnolen: there was a bug fixed in 1.3 that allows us to put the whole uberjar on the bootclasspath; that's where most of the boost is coming from
13:53ldopals
13:55ldopai'm surprised that doesn't happen more often to people using term-mode/rcirc
13:55technomancyldopa: different color themes helps =)
13:57cemerickjust as long as it's not a password or copy/paste snafu... ;-)
14:00stuartsierraJust noticed that lein 1.x highlight matches parens and lein2 doesn't. Is that a feature of rlwrap?
14:02technomancystuartsierra: yeah, lein2 uses jline2, which has nearly all the features of rlwrap, but apparently not all of them
14:02stuartsierraok
14:03stuartsierratechnomancy: Minor issue. Great work all around!
14:04technomancythanks
14:04technomancythe repl stuff was all Raynes and trptcolin though
14:04dnolenpure awesomeness is what that is.
14:04technomancyand also some scala guys making jline2 actually a respectable rlwrap replacement
14:05stuartsierraWe've been making a lot of use of custom tasks and `lein run -m` for bigger projects. It makes a nice way to portably invoke some Clojure code.
14:05technomancyfor a while we were using a scala-specific fork of jline even
14:05technomancystuartsierra: cool. are you aware of the trampoline higher-order task?
14:06technomancysaves memory in that kind of scenario
14:06stuartsierraaware it exists, but haven't explored it
14:06cemerickalmost no one uses it
14:06cemerickviz. the survey
14:07stuartsierraSo it still launches 2 JVMs, but only leaves one running instead of two?
14:07technomancystuartsierra: yeah, it's like clojure.core/trampoline, but for JVMs instead of functions
14:08stuartsierracool
14:10cemerickI've been using :eval-in :classloader for one project to optimize the startup time
14:11technomancycemerick: there have been concerns that the classloader stuff conflicts with the bootclasspath; have you found that to be the case?
14:11technomancyI guess it would only manifest if you needed a different version of Clojure from Leiningen itself
14:11cemerickI haven't hit a problem.
14:12cemerickAlthough yes, it could easily be a problem if your project shares a dep with one of Lein's.
14:12stuartsierraI don't think we'll ever be able to have two different versions of Clojure in the same ClassLoader.
14:12stuartsierraHierarchical ClassLoaders suck.
14:12technomancycemerick: I wonder if lein could be smart enough to switch that on if it can determine it's safe
14:12cemerickwell, :eval-in :classloader uses a different classloader.
14:12pandeirohas anyone done a wrapper for geotools?
14:13stuartsierracemerick: oh, so it doesn't inherit anything from Lein's classloader?
14:14cemerickstuartsierra: no, it does, but that's not trying to have different revs of Clojure in the same classloader.
14:14cemerickHrm, actually, that might not be right.
14:14cemerickClasslojure could be (or get to be) crafty enough to ignore the bootclassloader too.
14:15technomancycemerick: I definitely need to do some science on that before the final 2.0.0
14:15stuartsierraTo paraphrase Sartre, Hell is other people's ClassLoaders.
14:16cemerickright, so it doesn't; just gloms onto the ext classloader at the moment.
14:17cemerickstuartsierra: nice
14:18cemericktechnomancy: this is a broader problem that can't be solved statically; remember my ranting about the dynamic changes that lein.repl does
14:19technomancyif you would refresh my memory?
14:19cemerickI'll bet that's just the tip of the iceberg.
14:19cemericklein.repl adds nrepl vXXX (and others) to the project classpath, which might already contain vYYY.
14:19technomancyoh, sure
14:20technomancybut isn't that addressed by task-specific profiles that defer upon conflict?
14:20technomancyprofile merge logic already handles conflicting deps
14:20cemerickNot given multiple classloaders, or middleware magic.
14:20cemerickOr, I wouldn't think so.
14:21technomancyI think middlewares that touch :dependencies will only be safe if they use merge-profiles
14:21technomancyand perhaps we can only use an in-process classloader if we detect that there are no conflicts between the project and Leiningen itself
14:22cemerickYou could always shade everything in leiningen's uberjar!
14:23technomancyಠ_ಠ
14:23cemerickdid you get a new emote minor mode or something? :-)
14:25technomancyhttps://github.com/technomancy/dotfiles/blob/master/.emacs.d/phil/cosmetics.el#L38
14:26joegalloomg. slow clap.
14:26fliebelClojure does class loading and code generation at runtime, right?
14:28arohnerclojurebot: inc technomancy
14:28clojurebotCool story bro.
14:28arohnerwho does that?
14:28scriptor(inc technomancy)
14:28lazybot⇒ 22
14:28stuartsierrafliebel: yes
14:28arohnerah, of course
14:29fliebelstuartsierra: Ok. To bad... I'd like to run Clojure on the LEGO NXT, but it does some statick linking to save space.
14:29stuartsierrafliebel: if you AOT-compile everything then you don't need any run-time classloading.
14:30stuartsierraBut the JARs are still bloated with run-time metadata.
14:30stuartsierraThat's why Clojure on Android still doesn't work too well.
14:31fliebelstuartsierra: Right... I wonder what JVM language other than Java could run on the NXT.
14:31technomancyfliebel: mirah is nice for a "it doesn't hurt as much as java" without bringing along runtime baggage
14:32technomancybut it doesn't have a repl. =(
14:32fliebeltechnomancy: That's one of the pages I have open in my browser at the moment
14:32technomancyfliebel: for me personally, it's hard to have fun in a language that doesn't have a repl.
14:32fliebeltechnomancy: Yea, I miss the repl on NXT. pbLua is the only one that has it, as far as I know.
14:33fliebelpbLua has other shortcomings though.
14:33technomancyI think Mirah is valuable for targeting Android because currently the other existing options are awful, but I have a hard time recommending it recreationally until it gets a repl.
14:35fliebeltechnomancy: How would you do a repl, without runtime deps?
14:35technomancyfliebel: clojurescript manages it somehow. =)
14:36stuartsierraThe ClojureScript REPL is brittle and hackish compared to the Clojure REPL.
14:36stuartsierraFor now.
14:36fliebeltechnomancy: But JS has a repl of itself, and ClojureScript has quite some runtime deps right?
14:36technomancyyeah, that may not be a good example since JS has eval
14:38technomancyfliebel: the repl wouldn't be an integral part of the language; repl-enabled mirah would boot much more slowly than raw mirah
14:38fliebeltechnomancy: I guess nailgun is interesting... I don;t quite remember what it is though.
14:38technomancybut for development you wouldn't care
14:38fliebeltechnomancy: It can generate java source, so maybe beanshell is an option?
14:39technomancymaybe. I haven't looked into it
14:39sandoverdnolen: you tweeted the other day that sublime text is not a bad clojure dev environment. tweet more on this? I've been frustrated by lack of indent support, funny key cmds (ctl-p ctl-n), hanging repls, etc.
14:40emezeskefliebel: I think nrepl/jark supercede nailgun
14:55pcavsIs it possible to use a macro to do something like (defmacro my-macro [obj foo] (.myMethodCalled~foo obj)) such that (my-macro obj "Bar") ==> (.myMethodCalledBar obj) ? Messing around it seems not, so I was wondering if there is a way to do this?
14:56patrikkarlinuse the syntax (. obj myMethodCalledBar)
14:56patrikkarlinpcavs
14:56emezeske,(symbol (str ".myMethodCalled" "Bar"))
14:56clojurebot.myMethodCalledBar
14:56pcavsawesome, many thanks.
14:57pcavshaha, we'll find out
14:58emezeske,`(~(symbol (str ".len" "gth")) "hello")
14:58clojurebot(.length "hello")
14:58emezeske,(eval `(~(symbol (str ".len" "gth")) "hello"))
14:58clojurebot#<Exception java.lang.Exception: SANBOX DENIED>
14:58pcavsno eval I think in the jailhouse
14:58emezeskeAh, yeah
14:59pcavstrapped like rats!
14:59ClusterCatHi, as an emacs beginner, how do I get the output (like a failure stacktrace) in emacs when using C-c C-k?
15:01slyrustechnomancy: any idea which version of slime I should be using with swank-clojure 1.5.0?
15:02patrikkarlinclusterCat: u can use C-c C-l instead it showes a stacktrace
15:02patrikkarlini had newer used C-c C-k before :S
15:03arohneranyone have a good workflow for reviewing ~100 commits in GitHub?
15:04photexmasters of lein: I'd like to access a namespace in my project from control.clj but the classpath doesn't seem to get setup correctly
15:04photexis this a project.clj issue, or the plugin not being setup to handle this?
15:04amalloyarohner: just get a rubber stamp like http://www.webdesign-guru.co.uk/icon/wp-content/uploads/ok.gif
15:05photexmore specifically, I'd like to just access libs I depend on in project.clj
15:05photexbut I'm getting stacktraces out the wazoo
15:05ClusterCatpatrikkarlin, not for me. In fact no buffer shows any output. It is an clojure/seesaw programm. When running via 'lein run -m foo.core' it throws an exception which I don't see in emacs.
15:06amalloyseriously though, aside from using the compare/diff view to get all the commits in one place, i don't have any great ideas like a way to mark commits as good
15:06arohnermy main issue is just viewing them in something that has a good workflow for reading, like google reader
15:07photexbefore I file an issue with the plugin project I'd like to make sure it's not an issue with my project setup
15:07arohnerbut if I add a github RSS feed, I only get ~30 commits, I can't scroll back in time
15:07amalloyarohner: https://github.com/4clojure/4clojure/compare/e5e4c920...8f7e5aa2 ?
15:07arohneryeah, I find that really annoying. Reaching for the mouse, waiting for page refreshes, etc
15:08arohnerno hotkeys to visit next commit
15:08amalloyopen them all in tabs, C-w to close tabs you're done with
15:08arohnerand that munges commits together, rather than reading one at a time
15:09amalloyor do it from git instead of github - git log --patch-with-stat a...b
15:09arohneryeah, I'm playing with magit's log viewer now
15:09patrikkarlinClusterCat: what happends if you import the ns from the slime repl and run?
15:09emezeskeamalloy: Thank you for bringing --patch-with-stat to my attention. Awesomeness.
15:09mkarohner: what are the problems with how you expect to do it? just the delay between reviews?
15:10arohnermk: my ideal would be something like google reader. hotkeys to move between commits, and marking read vs. unread
15:10arohnermk: I'd use google reader if I could get it to display more than 30 commits when adding a new feed
15:11slyrusor, put another away, how do I keep my clojure process from dying soon after accepting my first C-c C-k?
15:11mkperhaps you could mess with the feed you give to the reader
15:11mkyahoo pipes lets you alter the feed in various ways, maybe you could cut off the most recent N, and do it in 4 batches, or something
15:13ClusterCatpatrikkarlin, it throws a class not found o.O
15:14patrikkarlinclusterCat: witch is not the exeption you get by running it?
15:16ClusterCatpatrikkarlin, no, when I run the program via lein, I get an AWT-whatever-exception, a seesaw related error. I think I'll try to set up a debugging buffer if I find out how :-D
15:19patrikkarlinclusterCat: have you changed you deps sins you started the slime session?
15:21ClusterCatpatrikkarlin, nope. Maybe I am using something wrong? I start emacs foo.clj, M-x clojure-jack-in, then C-c C-k. If everthing is correct a swing frame is displayed. If there is an error, I see absolutely nothing.
15:22dnolensandover: https://github.com/swannodette/cljs-demo
15:23patrikkarlintheres a slime events buffewr
15:23patrikkarlinbuffer*
15:25tacomaneveryone in the Haskell community (or at least on Reddit) seems to think monads are the best thing to ever happen to FP, whereas I've found a few tutorials on them from Clojurians, but they seem to be mostly ignored. is there any real point to them in a Clojure program/are they worth learning about, practically?
15:26emezesketacoman: There was a nice talk at Clojure/West about using the state and maybe monads for implementing DSLs
15:26scriptortacoman: if you read the reddict comments from those who know their stuff, monads are by far *not* the most important things on FP
15:26patrikkarlinthe core.logic libary sems to be monadic
15:26amalloytacoman: they're neat and something clojure people wish they understood better. but they're less useful/easy/necessary than they are in haskell, so we mostly wind up not getting them
15:28dnolentacoman: Haskell absolutely needs them. They aren't the best anything. They are a thing.
15:30sandovermonads are a solution to the problem of how to tractably do operations that have side effects in a purely functional language. Clojure isn't purely functional.
15:30sandovertractable isn't quite the right word
15:30amalloysandover: that's overly specific. monads do lots of things that aren't related to state at all
15:31sandovermaybe, but what they do that's actually _important_ is save haskell's pure functional bacon! ;)
15:42llasramEh. The sequence and maybe monads are pretty important too
15:43amalloyright. i kinda assume sandover has never written any haskell (not that i've written much)
15:46sandoveri've written some haskell, though not for production. i enjoy & respect the cult of monads, though I think it's beneficial not to take it too seriously.
15:47sandoverit's an amazing hammer that is still looking for the right nails.
15:49emezeskeThe maybe monad definitely seems like the right nail
15:49sandoverbeyond pure functional languages, do you think?
15:49sandoverin them, for sure.
15:50emezeskeYeah, I definitely think
15:50_andrew_k_we can use monads not only in pure functional languages
15:50_andrew_k_we use list and set monads in almost every language
15:51emezeskeWhenever you are transforming some value with a bunch of operations, any of which might return "no value", the maybe monad is great
15:51_andrew_k_exception is a kind of monad, too
15:52_andrew_k_monads is more about how we process the data
15:52sandoverare there any monads in clojure core libraries?
15:52_andrew_k_yep
15:52sandover(not implied ones, formally defined ones)
15:52dakronesandover: https://github.com/clojure/algo.monads is used in a few
15:52sandovermonad-as-design pattern doesn't count
15:53dnolen_sandover: not that I'm aware of.
15:55_andrew_k_in 1.2 there was clojure.contrib.monads
15:58llasramhttps://github.com/clojure/algo.monads is a 1.3 official contrib library
15:58sandoverunderstood; that's the hammer.
15:59llasramOh, sorry
15:59llasramHah!
15:59sandover:)
15:59llasramI only saw _andrew_k_'s comment 1.2
16:04_andrew_k_i played with it last time in 1.2, and didn't know what it's now .. )
16:10mkwhat's the difference between a symbol and a var?
16:10dnolen_mk: a symbol just another kind of Lisp value.
16:10brehauta var is a reference type, a symbol is just an identifier
16:10patrikkarlinsymbol is a data type a var is a reference
16:11amalloyin brief: a symbol is a name, a var is a name and a container
16:11RaynesAnd amalloy is a genius.
16:11RaynesBow to him.
16:12mkso x is a symbol. It's like "x", or 99, or whatever, but it's a value that tends to be used by the "language" itself more than anything
16:13mkjavascript blurs this, for example, by having maps everywhere: .foo is actually "foo", but lisp distinguishes between strings and symbols - right?
16:13mkand keywords are just like symbols...
16:13aperiodickeywords and symbols have completely different evaluation symantics
16:14mkbut they are both just values, and values of different types, right?
16:14dnolen_mk: many values self-evaluate at the REPL, an *unquoted* symbol at the REPL will be resolved - the var will be found and the value it contains returned.
16:14dnolen_,'first
16:14dnolen_vs.
16:14clojurebotfirst
16:14dnolen_,first
16:14clojurebot#<core$first clojure.core$first@5396e1>
16:14pandeirois there a way to make clojure-jack-in recognize the repl namespace in :repl-init and start there?
16:15amalloymk: yes, they are. dnolen's point is about what happens when you attempt to evaluate one (eg by typing it in at the repl or as source code)
16:15technomancypandeiro: not currently
16:15mkI'm reading an intro article that says def returns a var - I think this is confusing, because why not just bind to a symbol and return the symbol?
16:16dnolen_mk: symbols are not containers, their just regular Lisp values like I said above.
16:17mkright, but nothing is really a container, not even a list (it's just a value with relations to other values)
16:17dnolen_mk: vars are containers
16:17_andrew_k_symbols are the values themselves, var it's a label of container
16:17dnolen_,#'first
16:17clojurebot#'clojure.core/first
16:17dnolen_,(type #'first)
16:17clojurebotclojure.lang.Var
16:17mkif I evaluate a symbol, don't I get the bound value?
16:17_andrew_k_you get the symbols itself
16:17dnolen_mk: symbols don't self-evaluate at the REPL.
16:18mkI'm not sure I follow. If I type x, it evaluates to 5 because I did (def x 5) earlier
16:19mkso where does the var come in?
16:19TimMcmk: That's because it is compiled.
16:20dnolen_mk: symbol -> var -> var's value
16:20dnolen_mk: quoted symbol -> symbol
16:20Bronsait's not completly true that symbol -> var, isnt it?
16:21mkoh. Why not symbol -> bound value?
16:21TimMcBronsa: That's the resolve step
16:21Bronsait's more like the evaluator when encounter a symbol, resolves to a var
16:21dnolen_mk: because it's useful to manipulate symbols by themselves and not their values.
16:22mkdnolen_: what do you mean? Presumably I'd still be able to quote the symbol to just get the symbol
16:23dnolen_mk: macros, Clojure itself is defined in terms of being able to manipulate data structures and values - including symbols.
16:23mkok, I follow so far
16:24Chousukemk: in clojure, symbols are just names for things. vars are the actual containers of values
16:24mkwhy have symbol -> var -> value, instead of symbol -> value?
16:25mkChousuke: but how does one know which var corresponds to which symbol?
16:25ldopamk: both concepts exist in other languages, but are usually implicit
16:25_andrew_k_var is reference, symbol is name of var
16:25dnolen_mk: some symbols may represent things which are not top level - think about locals
16:25Chousukemk: the var has a name.
16:25_andrew_k_when you use a var - clojure looks up the var in namespace by symbol
16:25dnolen_mk: symbols may even get reused
16:25mkwhy not look up the value in the namespace by symbol?
16:26dnolen_mk: locals
16:26Chousukemk: in namespace foo, bar and foo/bar resolve to the same var, but are not the same symbol
16:26mkdnolen_: not familiar - I'm somewhat new to the language
16:26Chousukemk: if symbols held values, you'd get into trouble
16:27dnolen_mk: local bindings
16:27_andrew_k_,(def x 5)
16:27clojurebot#<Exception java.lang.Exception: SANBOX DENIED>
16:28Chousukemk: it has the added benefit of making symbols immutable which helps when processing them
16:28Chousukevars are the mutable things and they have mutation semantics like other ref types
16:28_andrew_k_,filter
16:28clojurebot#<core$filter clojure.core$filter@c9c89f>
16:28_andrew_k_,'filter
16:28clojurebotfilter
16:28_andrew_k_,#'filter
16:28clojurebot#'clojure.core/filter
16:28_andrew_k_the first is value - function
16:29_andrew_k_the second is symbol
16:29_andrew_k_and the third is var
16:29mksymbols would still be immutable, though namespaces would be mutable. If I def, do both x and namespace/x get bound to the new var?
16:29Chousukemk: no, symbols don't get bound to anything
16:29Chousukemk: but a var named namespace/x will get created
16:30aperiodicmk: i think the reason is that it if you went from symbol->value, then in order to implement local bindings, declaring a local binding would have to mutate the value of the symbol in whatever you're using to lookup symbol values, at whichi point the thing isn't really a local binding at all
16:30Chousukeand within that namespace, and any namespace that imports the x, the symbol x will *resolve* to that var
16:30Chousukein another namespace, the symbol x might resolve to a different var
16:33mkwhat is a local binding?
16:33Bronsalet
16:33mkwhat does it do?
16:34Bronsa,(let [x 1] x)
16:34clojurebot1
16:34aperiodicmk: in (let [x 42] x), x is a local binding which has the value of 42 only in the body of the let
16:34Chousukein that case, the symbol x is still only a name for the local value
16:34Bronsait binds the symbol `x` to the value 1 in the lexical scope inside the let
16:34Chousukeits storage is a detail of the compiler implementation
16:35Chousukein common lisp values actually do get stored in symbols, ie. they are pointers. but in clojure they're just names.
16:36aperiodicmk: if you haven't already, I'd highly recommend reading clojure.org's page on evaluation (http://clojure.org/evaluation)
16:37mkI'm somewhat familiar with how javascript does this, so maybe I'm thinking about it in the wrong way - in javascript, there is a chain of maps. Failure to resolve a symbol (in js, a string) in the first map means that the parent map will be checked, and so on
16:37pandeiroiwillig: do you use geoscript with clojure 1.3? i can't get geoscript.geometry to evaluate without error, gonna investigate when i have time tonight
16:37Bronsa,(let [x 1] (let [x 2] x))
16:37mkif I have clojure right, a namespace maps symbols to ...vars (I thought values)
16:38clojurebot2
16:38Chousukemk: yeah
16:38dnolen_mk: in JS symbols are not user manipulatable values, nor are the containers for defined things reified in the language
16:38Chousukemk: values are immutable, but bindings can change, so vars are needed
16:38Chousukevars are not immutable
16:39iwillighi pandeiro, you know i have not looked at geoscript for a long time
16:39mkdnolen_: they are. When you type x = 1 on the outermost scope, this remaps x. You can also push objects (maps) onto the chain using: with (foo)
16:39iwilligpandeiro, can you past me your error ?
16:39Chousukesymbols could have var-style semantics for mutation but then you'd have the problem I mentioned earlier. if symbol foo/x holds a value, then should x hold the same value, or something else?
16:40mkare namespaces immutable?
16:40Chousukenah, you add bindings to a namespace.
16:40Chousukewith def and require etc.
16:40dnolen_mk: they are not reified in JS you cannot manipulate them and there is no interface to them. scope chain and vars are not the same thing.
16:41mkbut is a namespace essentially a map?
16:41Chousukednolen_: well can't you add keys to some global object to create a binding in javascript?
16:41Chousukemk: yeah
16:41Chousukemk: with symbols instead of strings as keys
16:42Chousukejavascript in essence has strings instead of symbols for names, and then pretends that variables are something special :P
16:42mkdnolen_: in js, symbols are strings, and all objects are maps. object.prop is the same as object["prop"]
16:43Chousukeobject aren't quite maps IIRC. there's some gotcha but I can't recall it :/
16:43Chousukeobjects*
16:43mkChousuke: var foo = 5 does precisely that. It adds the key "foo" (a string) with value 5 to the global scope object
16:44Chousukemk: in clojure (def foo 5) would add an entry with the symbol foo as key pointing to a var named foo that holds the value, instead
16:44Chousukewell, var named namespace/foo actually
16:45mkChousuke: the gotcha might have something to do with the possibility of native objects (which can do arbitrary things according to spec), but conceptually they are definitely maps and can be treated as such
16:45Chousukethen whenever foo is referred, that var is dug up. and when its value is needed, deref is called on the var to get the current bound value
16:46Chousukethe deref is implicit in most code but sometimes you need to use vars directly
16:46Chousukeif you eg, want to be able to dynamically rebind a function that you pass as a parameter to something
16:46Chousukeyou pass the var instead and it works.
16:47terommk: I think "var foo = 5" adds key to local scope instead of global scope, but foo = 5 (without declaring it as a var) adds to global scope. But I might recall this incorrectly...
16:47Chousukescope is weird in javascript anyway
16:47Chousukedynamically scoped this is the weirdest thing ever
16:48mkterom: foo = 5 will look up the value "foo" along the scope chain. If found, it will bind it at that level.
16:48ChousukeI try to not think of it as "this" in the first place, just some context object that holds whatever context we are running in.
16:48dnolen_mk: it's still not quite the same as vars in Clojure, you can't get the container in JS. there's also the problem that many things that are normal symbols in Clojure are special in JS - operators.
16:48Chousukeit makes more sense to me that way
16:50amalloyi never really thought about the fact that this is dynamically scoped. i don't really do enough js to care, but hopefully that insight will help me understand it next time
16:50_andrew_k_i think it's bad idea - trying to understand clojure in terms of js )(
16:51technomancyamalloy: hopefully there won't be a next time
16:52Chousukethere are worse options than JS :P
16:52terom_andrew_k_: could be, or maybe if there would be a good comparision available, it would be helpful :)
16:53Chousukeif you're used to prototypal OO in JS working with plain data structures in clojure should feel quite natural
16:54mk_andrew_k_: yeah, definitely. I feel like an idiot for bringing it up, but it's how I understand scope, and is probably the reason I'm not following the quadruple namespace+symbol+var+value resolution system
16:55Chousukemk: you should think of them as separate things, not something complicated
16:55_andrew_k_mk: ask what the difference between let and binding and you get real brain storm )
16:55Chousukenamespaces hold bindings. symbols name things. vars hold values. values are values :P
16:56_andrew_k_values are bytes
16:56_andrew_k_bytes are bits
16:56scgilardino turtles?
16:56Chousukethat goes below the abstraction that clojure provides :P
16:56_andrew_k_bits are electorns in transistors
16:56mkwell, I'd hesitate to call js oo. The whole language is really just a bunch of maps, as well as prototype-style inheritance, and scope. You can encapsulate with closures and so on, but you don't have to
16:57mkok, so symbols are values, namespaces are maps, vars are pointers (and values are values ;)
16:57Chousukesymbols are not values, symbols are names :P
16:58aperiodicsymbols are values that are often used as names
16:58Chousukewell, a symbol is a value too, just like everything else, but yeah.
16:58aperiodicat macro-expand time, symbols are just values
16:58mk(namespaces map symbols to all sorts of value types; keys to map-values)
16:59dnolen_mk: JS is definitely OO, with a sensible does of FP.
16:59dnolen_dose
17:00Chousukemk: understanding why you need var containers for values is probably easier if you consider threading. a simple pointer can't provide any sort of sane semantics in a multithreaded environment
17:00Chousukevars provide the ability to thread-locally dynamically rebind their value
17:00mkI suspect that there's a very good reason why there's an extra pointer in there, because the map itself could have just pointed to the value. If you're using scope chains anyway, then let should just add to the chain. Smart people had the option of doing it that way, but didn't, so I wonder why
17:01dnolen_mk: injecting objects into scope chains is dog slow - thus it's removal in "strict mode"
17:02mkcan I access the namespace object in clojure?
17:02Chousukeyes
17:02dnolen_mk: yes
17:03Bronsa,(the-ns 'clojure.core)
17:03clojurebot#<Namespace clojure.core>
17:03pandeiroiwillig: yeah it's this: http://sprunge.us/fbUY ... i think it's just a matter of updating the dependencies
17:03aperiodic,(apropos 'ns)
17:03clojurebot(ns-aliases booleans the-ns instance? gensym ...)
17:03Chousukenamespaces are named by symbols too :P
17:03Chousukeand now that I think of it, java methods, classes, etc. are named by symbols too
17:04mkso I can map the symbols "ns/x" and "x" in both the global and current namespaces to 4 different vars, or the same single var?
17:04pandeiroiwillig: i am working with shapefiles for the first time and i was happy to find geoscript and your clojure implementation... i will see if i can fix it tonight, and if so send you a pull request
17:05Chousukemk: if you're in namespace ns, ns/x should always refer to the var #'ns/x in that namespace. but x could refer to #another.ns/x
17:05iwilligthanks pandeiro... however i to apologize because geoscript is unfinished and looks to be broken. never got a chance to fix it
17:05Chousukemk: if, for example, you somehow unmap the original mapping of x
17:06pandeiroiwillig: even if it only digests shapefiles, can simplify and output to geojson, and vice versa, that would be really useful
17:07Chousukemost often it's the other way around though. you might eg. want to remove the default mapping of = (which refers to clojure.core/=) and replace it with your own def of = in your namespace
17:07pandeirothe reading and converting part works, the simplifying doesn't b/c of geoscript.geometry
17:07mkdo vars contain/point to their original symbol as well as the value, then?
17:07Chousukemk: no, they just have a symbol object that represents their name
17:07Chousukemk: it might be the same symbol object, or it might not be
17:08Chousukethere is nothing that prevents you from having a dozen different objects that are the same symbol as far as clojure is concerned
17:08Chousuke,(identical? 'foo (symbol "foo"))
17:08clojurebotfalse
17:08Chousuke,(= 'foo (symbol "foo"))
17:08clojurebottrue
17:08_andrew_k_Chousuke: symbol x always point to the current namespace - it's short form of ns/x (when you are in namespace ns)
17:09Chousuke_andrew_k_: but it can point to a var in another namespace
17:09Chousuke,*ns*
17:09clojurebot#<Namespace sandbox>
17:09Chousuke,#'=
17:09clojurebot#'clojure.core/=
17:09mk_andrew_k_: but the namespace is a map. You can presumably map the symbol x to be anything you want, even not ns/x
17:09Chousuke,(ns-mappings *ns*)
17:09clojurebot#<CompilerException java.lang.RuntimeException: Unable to resolve symbol: ns-mappings in this context, compiling:(NO_SOURCE_PATH:0)>
17:10Chousukehm, what was the function :P
17:10aperiodic,(ns-map *ns*)
17:10clojurebot{sorted-map #'clojure.core/sorted-map, read-line #'clojure.core/read-line, re-pattern #'clojure.core/re-pattern, keyword? #'clojure.core/keyword?, unchecked-inc-int #'clojure.core/unchecked-inc-int, ...}
17:10Chousukeright. so it quite literally is a map :P
17:11mkis there something like a proper spec for clojure?
17:11Chousukenah
17:11Chousukeit's implementation-defined
17:11Chousukeby several different implentations
17:11_andrew_k_when you change var of symbol x - ns/x changes too
17:11_andrew_k_it's the same
17:11mkyou mean clj and cljs?
17:11Chousuke(ie. clojure implementations for different hosts do differ, intentionally)
17:12aperiodicmk: have you read through all the side links on clojure.org? they're fairly comprehensive (for the JVM implementation) though they are a bit academic in tone
17:13mk_andrew_k_: did you try adding one symbol or the other to the map directly? If it's a normal map, it shouldn't update both in the way you describe
17:13Chousukemk: The way I see it, Clojure has some big ideas at the core and symbiosis with the host is one of them
17:13Chousukeso you can't really create a portable spec of clojure that you could implement on several hosts
17:14Chousukebecause that would conflict with the philosophy of embracing the host.
17:14mkaperiodic: I should probably have a look at that - thanks
17:14technomancyChousuke: well, there could; it just wouldn't be practical for building applications
17:14dnolen_mk: cljs is actually a pretty interesting case study in in some of the design decisions in Clojure around symbols, var, namespaces
17:14dnolen_mk: in CLJS namespaces are indeed just objects, and definitions are just properties on those objects.
17:15_andrew_k_https://gist.github.com/2164617
17:15ChousukeI guess you don't need vars in cljs
17:15Chousukesince it's single-threaded
17:15dnolen_mk: all the symbol manipulation and resolution happens in the compiler.
17:16dnolen_Chousuke: and JS makes redefinition simple unlike the JVM
17:16mkok wait, are vars just a way to synchronize on key-value pairs without locking the entire namespace map?
17:16Chousuke_andrew_k_: I think you misunderstood what I meant
17:16Chousuke_andrew_k_: you're not changing the mapping of x in user there, you're redefining the var's value
17:17Chousuke_andrew_k_: but you COULD map x to point to the var in user2
17:17Chousukeby using eg, use
17:17dnolen_mk: vars are also Clojure's mechanism for supporting redefinition on a host designed for a much less dynamic language - Java.
17:19mkso they're not so much a theoretical thing, like the way that lists are evaluated, but a component that helps deal with the host?
17:21ChousukeI suppose
17:21Chousukethough bear in mind that vars are not the only reference type clojure has
17:21Chousukethere are refs, agents and atoms as well
17:21Chousukevars are just the default used for globals
17:21mkright :)
17:21technomancyit's worth noting that vars are the only one for which idiomatic usage does not involve deref
17:22dnolen_mk: not completely - they serve a few purposes - dynamically bound thread locals. They also store metadata so useful for introspection
17:22technomancymk: there was a talk on this at clojure/west
17:22technomancyuntil the videos are up you might find the slides helpful? https://github.com/strangeloop/clojurewest2012-slides/blob/master/Andera-Namespaces-Symbols-Vars.zip
17:23mkawesome - thanks. Yeah, I've been looking forward to the videos
17:23dnolen_mk: that said, they are puzzling - it took me a long time to understand them - but not understanding them doesn't really impair everyday Clojure programming.
17:24technomancyyeah, just dive in; you'll figure it out by osmosis eventually
17:24Bronsalol
17:24patrikkarlinlike in final fantasy :P
17:24patrikkarlinonly place i heard that word
17:25Chousuke:P
17:25technomancyyeah, just be sure to use lightning vars against water-based problems and you'll be fine.
17:26ChousukeI was ahead of my peers in English classes because I played Final Fantasy games and learned lots of new words from them.
17:29mkusing a language I don't understand feels like a bit of a grind. But that's probably the only way to do it at the very start
17:30dnolen_mk: learning ain't easy
17:30dnolen_my initial reaction to JS was close to WTF. I like it alright now.
17:31bsteuberin lein2, where do I put dev-dependencies that I want to reuse in every project?
17:31brehaut_any language that doesnt feel like a grind at the start probably isnt worth learning either
17:32BostXhi all.
17:32technomancybsteuber: that'd be the :user profile
17:32bsteuberI tried :profiles {:dev {:dependencies [[...]]}} under :user
17:32BostXguys do you know what should I use instead of global-singleton from former clojure.contrib.singleton ??
17:32lazybotBostX: What are you, crazy? Of course not!
17:33mkthe initial curve tends to put me off, but I like the payoff. I spent days with the ecma262-3rd spec, it was great - js is actually a rather elegant language
17:33technomancybsteuber: you don't want :dev there; bring it up a level
17:33technomancy:dev is for project.clj files
17:33technomancyhttps://github.com/technomancy/leiningen/wiki/Upgrading
17:34mkbut there's no way I would have read that ugly thing unless I was somewhat into js already
17:36dnolen_mk: JS has too many dark corners to call it elegant - but it was influenced by good languages.
17:37dnolen_mk: and the combining of OO & FP principles was forward-looking
17:37amalloywow, global-singleton looks like a terrible idea to begin with. you could easily replicate its functionality in a threadsafe way with ##(doc delay) and ##(doc force)
17:37lazybot(doc delay) ⇒ "Macro ([& body]); Takes a body of expressions and yields a Delay object that will invoke the body only the first time it is forced (with force or deref/@), and will cache the result and return it on all subsequent force calls. See also - realized?"
17:37lazybot(doc force) ⇒ "([x]); If x is a Delay, returns the (possibly cached) value of its expression, else returns x"
17:37clojurebot"([x]); If x is a Delay, returns the (possibly cached) value of its expression, else returns x"
17:37clojurebot"([& body]); Takes a body of expressions and yields a Delay object that will invoke the body only the first time it is forced (with force or deref/@), and will cache the result and return it on all subsequent force calls. See also - realized?"
17:38lancepantzdnolen_: mk: i've been doing some js myself recently, overall i've enjoyed it
17:38lancepantzthe api is a bit lacking
17:38lancepantzbut jquery makes up for it, although it does end up looking strange
17:38bsteubertechnomancy: is there something wrong with https://gist.github.com/2164741 ?
17:39mkdnolen_: it has a core that's rather nice, but a lot of bad things happened to it, probably because of how standardization went
17:39bsteubertechnomancy: it seems midje doesn't find its way into my classpath
17:39mkdnolen_: which languages was it influenced by, which were good?
17:40Bronsascheme i guess?
17:40dnolen_mk: Scheme & Self
17:41brehaut_and java in the wrong ways
17:41dnolen_mk: also I'm sure Brendan must have know something about the various 80s OO Schemes
17:42mkbrehaut_: that turned out for the best, I think - the familiar syntax etc. brought people into a functional language
17:42bsteubertechnomancy: nevermind, I'm a bit tired :)
17:42mkI didn't know that it was influenced by either of those
17:42bsteubertechnomancy: works now, thank you
17:45brehaut_mk, the classical OO notation bolted onto a prototypal OO system has done lasting damage to JS
17:46technomancybsteuber: cool
17:46mkthe elegant thing about js (I think) is its map chaining, which is used both for prototypes and for scope. The core of the language can be inefficiently implemented in not that many lines of code.
17:47mkbrehaut_: do you mean the dot notation? obj.foo and obj["foo"] ?
17:47bsteubertechnomancy: another thing I'm wondering about.. when I switch profiles, I'll have to manually clean stuff that has to be compiled differently, like cljsbuild advanced vs simple
17:47bsteuberbut of course it's a hard problem, unless you want to clean all the time
17:47brehaut_mk, no i mean needing a new keyword, not supporting prototypal operations (till recently or via crockfords functions)
17:48brehaut_the inclusion of privileged constructors is a bit horrible in general actually
17:48bsteuberit would be great though if leiningen could somehow discover which parts have to be cleaned with the new profile
17:50technomancybsteuber: hm; yeah. maybe some kind of mechanism plugins could use to specify staleness
17:51technomancya staleness predicate that could write checksums of relevant project map entries to disk
17:52bsteubertechnomancy: sounds cool - but I guess there are more important things on your lein2 list ^^
17:53technomancybsteuber: well, that's something that sounds like it would require some solid design since it could affect a number of 3rd-party plugins
17:53bsteuberindeed
17:54technomancybsteuber: feel like starting a github issue or mailing list thread on which to brainstorm?
17:54bsteubertechnomancy: sure, I'll open one :)
17:55mkbrehaut_: yeah, all of that wasn't done very well. It seems to be getting patched up now, though.
17:55bsteubertechnomancy: one more thing - is there a simple way to find out from my (non-plugin) code in which profile I am?
17:55technomancybsteuber: no, I don't see that as a good idea.
17:56technomancybsteuber: consider parallels between user-agent sniffing and checking for specific features.
17:57bsteubertechnomancy: the problem I'm trying to solve is having a single view deal with both advanced and simple cljs compilation depending on the profile
17:57bsteubermy current way is adding a different implementation of the same tiny namespace to the classpath in both profiles
17:57technomancybsteuber: you'd want to check for a specific value within the profile rather than the name of the profile
17:58dnolen_mk: it's going to be a while before we see the benefits. Clojure already covers pretty much all the interesting JS.next territory under discussion and way, way more.
17:58bsteubertechnomancy: and how could that be made available to normal code?
17:58technomancybsteuber: you could have the profile put something in :injections if you must
17:59technomancythat should be a seq of forms that get inserted into every eval-in-project call
17:59technomancybut there's probably a better way to do this; maybe emezeske understands the problem better than I
18:00bsteubertechnomancy: possibly I am doing something fundamentally wrong here
18:00bsteubermaybe I'll open another discussion in a cljsbuild issue :)
18:01bsteubertechnomancy: so injections will be evaluated even in compiled code?
18:01bsteuberaot, I mean
18:01technomancythey will be evaluated while performing AOT, but they don't happen inside the call to clojure.core/compile
18:02dnolen_bsteuber: I was actually surprised by the fact that cljsbuild takes a vector instead of a named map of builds.
18:02dnolen_emezeske: ^
18:03emezeskednolen_: Yeah, I guess that would make sense, so you could build specific ones by name?
18:04dnolen_emezeske: yeah - "lein cljsbuild once :adv"
18:04technomancyalso probably "lein cljsbuild" should do something useful
18:05emezeskednolen_: I like it... feel free to open a case ^_^
18:05emezesketechnomancy: That should print out a help message, does it not?
18:06bsteuberemezeske: I guess your default solution to multiple views for adv vs nil is not using nil as optimization level?
18:06bsteuberthe problem is, without the out/ folder being used, the chrome js debugger is way less useful
18:06technomancyemezeske: I'd recommend having it do the most commonly-used subtask
18:07emezesketechnomancy: Hmm, I might have to figure out what that is :). Probably 'cljsbuild once' if I had to guess. But I should measure...
18:07emezeskebsteuber: I don't know if I understand the problem fully
18:07technomancyonce is probably more commonly-invoked just because by nature it needs to be run more often than auto =)
18:08dnolen_emezeske: done.
18:08emezeskednolen_: thanks!
18:09dnolen_bsteuber: hopefully all of this will be resolved when we start producing source maps
18:09emezeskesweet, sweet delicious source maps
18:09bsteuberemezeske: I use :optimizations nil and :output-dir together so the js doesn't get compiled in just one file for better debugging
18:10bsteuberbut that means, I'll have to change the view again for loading goog.base and so on
18:11emezeskebsteuber: Ah, I see. I do something similar, but I compile in debug and prod at the same time, and just switch which I include in the views
18:11emezeskebsteuber: But either way you do have to change the way the javascript is included
18:12bsteuberand that's what I am trying to get rid of
18:12bsteuberwell, actually I did, but it's really ugly :)
18:13emezeskeI haven't thought much about how to avoid that, really
18:13bsteubermaybe I'm just too lazy :)
18:18bsteuberdnolen_: what are source maps?
18:18dnolen_bsteuber: everything you ever wanted http://www.html5rocks.com/en/tutorials/developertools/sourcemaps/
18:18dnolen_bsteuber: you could just always develop in advanced mode. and you'd get sexpr level stepping during debugging.
18:19emezeskeSource maps fix 99% of my complaints about clojurescript
18:19bsteubercooooool
18:21bsteuberwill it also help finding out which file is breaking advanced compilation? :)
18:23bsteuberdnolen_: by the way, how's your research on predicate dispatch going?
18:24bsteuberrecently, I've used some sort of poor man's dispatch several times
18:24dnolen_bsteuber: moving slowly , though some new steps will land in the next core.match alpha.
18:25bsteubercool, I'll check it out then
18:26bsteuberwith a problem this hard, slow progress is already awesome..
18:27dnolen_emezeske: bsteuber: the main challenge is that I think we'll need to analyze the Closure advanced sourcemap and use that to map to generated JS and then back to ClojureScript
18:27dnolen_and use that info to produce our own sourcemap.
18:29emezeskeYeah, that is definitely the tricky bit
18:29emezeskeTwo levels of indirection need to be melded into one
18:30emezeskeSeems like a general purpose sourcemap merging utility could be of use. I wonder if such a tool would be applicable to other languages?
18:31dnolen_emezeske: hmmm ... that's not a bad idea, and yes I think it would be applicable - coffeescript will probably need the same thing.
18:32ibdknoxI looked at it a bit and that was my assessment as well - reconciling the two steps will be the hard part
18:33emezeskeBwuaha, if we write the sourcemap merge in clojure, we can sneak clojure into all the other languages' build processes
18:33dnolen_ibdknox: I don't think so hard actually, just work.
18:34ibdknoxdnolen_: yeah, I guess that's a better qualification. None of it looked particularly hard, just time consuming
18:34emezeskeSeems like we'd want a basic sourcemap library for clojure, then the CLJS compiler could use that, and the merger tool could use it as well
18:34dnolen_ibdknox: for example we don't need mappings for intermediate things really - we produce a lot of generated symbols which are irrelevant for debugging.
18:35ibdknoxalso true
18:35dnolen_emezeske: yes exactly
18:35dnolen_anyways exciting times!
18:35ibdknoxI was wondering how many problems macro expansion would cause
18:36emezeskeibdknox: Ooh, interesting
18:36ibdknoxhaha
18:41eggsbyif I have a vector of ~things~, and I want to iterate over those ~things~ until some condition is met, and then change that ~thing~ and return the new set, what would be the easiest way?
18:42eggsbyso like say is5 if the number is 5 turn it into 20 instead where [1 2 3 4 5 6] will return [1 2 3 4 20 6]
18:42arohnereggsby: for a vector (or map), you can use update-in
18:42bsteuber,(map #(if (= 5 %) 20 %) (range 1 6))
18:43clojurebot(1 2 3 4 20)
18:43arohner(update-in [1 2 3 4 5 6] [5] + 15)
18:43patrikkarlinyou only whant to change one of the items?
18:43arohner,(update-in [1 2 3 4 5 6] [5] + 15)
18:43clojurebot[1 2 3 4 5 ...]
18:43eggsbyya basically I have 'buckets' and if something can fit in the bucket I want to shove it in there and recur on the rest of the things i'm testing
18:43mk,(map #(if (= 5 %) 20 %) (1 2 3 4 5 5 6))
18:43clojurebot#<ClassCastException java.lang.ClassCastException: java.lang.Long cannot be cast to clojure.lang.IFn>
18:44mk,(map #(if (= 5 %) 20 %) (list 1 2 3 4 5 5 6))
18:44clojurebot(1 2 3 4 20 ...)
18:44eggsbythanks that works mk
18:44mkit wasn't mine, I was just testing
18:44mkI think it fails because it updates all fives, not just the first one it sees
18:44eggsbyya
18:45eggsbyhm
18:45eggsbyright so map won't work...
18:45eggsbytime to read documentation for update-tin
18:45eggsbyer, -t
18:45mkarohner's is better, but it updates the rightmost 5
18:46arohner ,(update-in [1 2 3 4 5 6] [3] + 15)
18:46clojurebot[1 2 3 19 5 ...]
18:46arohnerstupid off-by-one. Actually, mine updates the index of the vector. I didn't read the original problem carefully enough
18:47eggsbythe index hmm
18:47eggsbyya, hm
18:47eggsbyI wrote some stupid nasty long piece of code full of conds and I don't like it :(
18:47arohner(map #(if ...)) sounds like a better fit for 'fix items matching this condition'
18:48arohnereggsby: update-in requires vectors or maps (not seqs or lists)
18:49eggsbyya, map would work if I could figure out how to say 'only meet this condition once'
18:49bsteuber,(split-with #(not= 5 %) [1 2 3 4 5 6 7 8 5])
18:49clojurebot[(1 2 3 4) (5 6 7 8 5)]
18:49bsteubermaybe work from here
18:50mkeggsby: what you need is to say "the leftmost one that meets this condition". A parallel scan, for example, might meet the condition in the middle of [5 5 5 5 5 5].
18:53arohneryou could use reduce to match once, but that feels a little more cumbersome than necessary
18:54arohneractually, map will do that
18:54emezeskeeggsby: have you looked at map-indexed?
18:54eggsbynope, I'm new to clojure in general. I wrote some 100 line function to do this but its terrible
18:54eggsbyI feel like I should be able to do it more elegantly
18:54arohner(let [found? (atom false)] (map #(if (and (not @found?) ....) (do (do-stuff) (swap! found? (constantly true))
18:55alexbaranoskyarohner, seems yucky to use an atom for that though, no?
18:55emezeskeyeah, don't use an atom
18:55arohneralexbaranosky: yeah
18:56alexbaranosky(update-in [1 2 3 4 5] [(idx-of-first-match [1 2 3 4 5])] + 15)
18:56bsteubereggsby: https://gist.github.com/2165263
18:57bsteuberthis is what I would write
18:57alexbaranoskythen just write idx-of-first-match
18:57mkthe clojure core docs suck. Why isn't there a categorized listing? Like functions that apply to lists, etc.
18:58alexbaranoskybsteuber, pretty nice
18:58alexbaranoskymk you haven't written it :)
18:58alexbaranoskyActually I think there are some cheatsheet style webpages out there
18:59aperiodicmk: you mean like http://clojure.org/cheatsheet?
18:59eggsbyhttps://refheap.com/paste/1307 is what I've got so far after scrapping my old monster implementation
18:59eggsbyi'll look at update-in alexbaranosky
19:00mkaperiodic: maybe :) I'm looking at http://clojure.github.com/clojure/clojure.core-api.html though, which is the first result, and it ain't pretty
19:00eggsbyerr, wrapping my head around that bsteuber
19:00eggsbythanks you guys
19:01mkwhat's wrong with using alexbaranosky's updatein + indexof?
19:01technomancymk: yeah, that's generated from the docstrings, which are reference material, not introductory
19:01alexbaranoskymk you have to write the index of function, though :)
19:01eggsbyoh mk these are all just new functions to me I have to learn to use them first mk :)
19:01mktechnomancy: yeah, but that's where I end up when I search
19:01eggsbyoops, didn't mean to doubleping
19:02technomancymk: yes, google is not kind to the aspiring Clojure learner
19:03bsteubersome day we will have something like hoogle using core.logic :)
19:03technomancythere's always findfn
19:04mktechnomancy: that can't be an excuse when we have control over the page it points to
19:04technomancyhuh?
19:05technomancyI don't think restructuring a web site based on referer logs and guesses is a good idea
19:07mkjust make the "core-api"... friendlier, without making it any less an api.
19:07aperiodica link to the cheat sheet somehere on the core-api page wouldn't be a bad idea
19:08emezeskehave you guys seen this super-epic cheatsheet? http://homepage.mac.com/jafingerhut/files/cheatsheet-clj-1.3.0-v1.0/cheatsheet-clojuredocs.html
19:08technomancymore links to the material people are likely to find helpful is a lot more productive
19:08mkor even a notice that says "this page is a mirror of doc, and won't help you find the function you're looking for - hit back and try again" :P
19:08technomancyunfortunately no one in here has permission to edit that page
19:09mkperhaps someone could send an email
19:10aperiodicoh awesome, cheat sheet on steroids
19:10aperiodicthanks, emezeske!
19:11emezeske^_^
19:11amalloyeggsby: 100 lines!? that is way too many lines for any function; i wrote a 50-line function once and it's very embarrassing. if you had a clear description of what you're trying to accomplish (i can't make heads or tails of the comment in your paste) it's probably possible in at most ten lines
19:11TimMctechnomancy: Not true.
19:11technomancyTimMc: ah, would love to be wrong on that one =)
19:11TimMctechnomancy: Well, replaca has access, maybe not *permission*. :-P
19:12technomancyclojurebot: epigram 71
19:12clojurebotNo entiendo
19:12technomancyclojurebot: 71
19:12clojurebotGabh mo leithscéal?
19:12eggsbyI know amalloy :(
19:12TimMc~71
19:12clojurebotExcuse me?
19:12technomancydang it clojurebot
19:12technomancy"Documentation is like term insurance: It satisfies because almost no one who subscribes to it depends on its benefits." - Perlis
19:12amalloy~#71
19:12clojurebot71. Documentation is like term insurance: It satisfies because almost no one who subscribes to it depends on its benefits. -- Alan J. Perlis
19:12technomancyah; there we go; thanks amalloy
19:13mkclojurebot needs a "did you mean" in place of its gibberish talk
19:14amalloybut how else would you learn to say "i don't understand" in welsh?
19:15technomancymk: he does have some kind of fuzzy matching based on edit distance
19:15mkmaybe we could set it up to say such things on a random timer
19:15aperiodic*that's* what that is
19:17TimMcmk: Or better, if the channel has been quiet for an hour?
19:17mkmuch better :)
19:18mkas if he'd been thinking about it for a while
19:18slyrusyay. after a many month hiatus, clojure/emacs/slime/swank-clojure are all playing nicely (roughly speaking anyway) with CDK and it's 2-d molecule rendering routines.
19:26bsteubertechnomancy: https://github.com/technomancy/leiningen/issues/468
19:26bsteuberwill be interesting to see where this leads
19:28technomancyyeah, definitely
19:31sandovertechnomancy: thanks for the tip on lein search --update
19:31technomancysandover: sure; no problem
19:31technomancyit sure would be nice if you could update the maven central search indices incrementally rather than blowing them away
19:55JetienHi! I'd like to (require) a clojure lib that doesn't live in a file but a buffer. Is that - or anything equivalent - possible somehow? do i need to write a class loader for that?
19:58ZokaTehnomancy: Do you have an idea how solve this little annoyance? http://groups.google.com/group/heroku/browse_thread/thread/2c7ed99b65531a75#
19:59technomancyZoka: no, unfortunately it's pretty common to do stuff like echo "\n" >> project.clj && git commit --amend -a && git push --force
19:59technomancyonce a slug is built it's immutable
20:00ZokaThanks
20:00technomancyif you load pomegranate you could do it via ringmon though =)
20:00technomancynoir
20:00technomancysorry
20:00technomancyhttp://sunng.info/blog/2012/03/my-favorite-feature-in-leiningen-2/
20:01ZokaI will have a look thanks
20:21FrozenlockOk, I know you guys must take it for granted by now, but I think the fact that -keys are funtions of a map- is incredible.
20:21FrozenlockAnd so Oh convenient!
20:22mkFrozenlock: and vice-versa, of course
20:23FrozenlockOf course :P
20:23FrozenlockEqually amazing.
20:23mkFrozenlock: I forgot the talk, but there was a sorting example
20:25erlang2clojurehello, java/clojure newbie here. Need help getting cascalog to work (within clojure)
20:25mkusually, that part in java is something like ... well, you define an anonymous comparator, and it takes about 7 lines of mess. In clojure, the equivalent part of the code is like... :lastname
20:26erlang2clojureOn ubuntu, created ~/cascalog directory then lein2 repl
20:26erlang2clojureould not locate cascalog/playground__init
20:27Frozenlockmk: coming from emacs and CL, I'm baffled by how much java is verbose. I'm happy to see Clojure didn't inherit this characteristic.
20:27mkerlang2clojure: try ctrl-f in http://clojure-log.n01se.net/date/2011-11-05.html
20:29mkFrozenlock: it's an adopted child. It inherits the platform without inheriting various language features
20:30qbgThough Java does occasionally rear its head
20:31bsteuberFrozenlock: but I believe you'll feel about CL in a similar way after using clojure for a while
20:31bsteuberof course it's not verbose
20:31bsteuberbut overly complex
20:32technomancyclojurebot: equal rights for functional objects?
20:32clojurebotEqual Rights for Functional Objects is Baker's paper on equality and why it's impossible to define sensible equality in the presence of mutable data structures: http://home.pipeline.com/hbaker1/ObjectIdentity.html
20:32bsteuberand somehow not fitting this time
20:32qbgbsteuber: More like old
20:32bsteuber^^
20:32mklooks like a dead link
20:33technomancywhat!? nooooo
20:33aperiodicarchive.org?
20:33technomancyhttp://www.pipeline.com/~hbaker1/ObjectIdentity.html
20:33bsteuberbut not just that, I mean, a language which is born out of a commitee merging 5 ancestor languages being pushed by different parties - that has to become messy
20:33technomancyanyway, that paper convinced me that CL's notion of equality is broken beyond repair
20:34erlang2clojure@mk -- thanks. reading. I had done git clone cascalog to get the cascalog in, then lein deps brought in deps, but lein compile failed. So I figured if I do lein repl within cascalog directory it will just create all that's necessary automagically
20:34technomancyclojurebot: forget Equal Rights for Functional Objects |is| Baker's paper on equality and why it's impossible to define sensible equality in the presence of mutable data structures: http://home.pipeline.com/hbaker1/ObjectIdentity.html
20:34clojurebotI forgot that Equal Rights for Functional Objects is Baker's paper on equality and why it's impossible to define sensible equality in the presence of mutable data structures: http://home.pipeline.com/hbaker1/ObjectIdentity.html
20:34technomancyclojurebot: Equal Rights for Functional Objects |is| Baker's paper on equality and why it's impossible to define sensible equality in the presence of mutable data structures: http://www.pipeline.com/~hbaker1/ObjectIdentity.html
20:34clojurebotAlles klar
20:36mkwhat's the summary of that paper?
20:37technomancydefining meaningful equality semantics between mutable objects is impossible
20:37mkwhy?
20:37clojurebotmk: because you can't handle the truth!
20:38qbgMutable objects change
20:38qbgI love that Clojure has egal
20:38qbgLife is so much better than it was in CL...
20:38mksure, but presumably you can define equivalence between what we always refer to as identity
20:38bsteuber"two changing things are only equal if they will be equal all the time"
20:39technomancymk: sure; should have said "meaningful equality semantics between different mutable objects"
20:40technomancythe paper actually does argue that "identical?" is the only meaningful equality for mutable objects
20:41mkso comparing the values of two unequal identities at a point in time is useless?
20:41technomancywell... not if they're truly values
20:41technomancybecause values are immutable by definition
20:42amalloymk: you asked for a summary of the paper, and now it seems like you're quizzing technomancy on all the details. why not just read it?
20:42technomancyit's pretty accessible
20:43mkamalloy: baker might have a knockdown point that's easy to mention, but which he omits in the abstract because he doesn't want to ruin the fun
20:44muhoohow would i start a clojure process as a daemon from lein, with a repl port i can connect to, but no stdin/stdout (no repl on controlling terminal?)
20:44mkI get that the paper's saying "you can't have equality", I'm wondering why. I'll skim the paper, though :)
20:44muhooi have :repl-port set in the project.clj
20:46muhoocircular... source code?
20:46qbgIn CL you can read circular structures
20:47qbg#1=(1 . #1#) if I remember the syntax
20:47mkcyclical?
20:47qbgAny graph really
20:47muhooah, i see, lein run will do it.
20:48qbgQuines become too easy
20:50TimMcIn JS too.
20:50TimMcWell, depends on the impl. I think Mozilla's JS does that.
20:52muhoono, that's a fal
20:52muhoofail
20:53muhoolein trampoline run does NOT start up the repl listener, even if :repl-port is set in project.clj
20:53muhoolein trampoline repl DOES start up the socket listener, but only if it has a controlling terminal :-(
20:54rhchmm, is there a good way to get a monotonically increasing timer in clojure?
20:55rhcor should i just use java.util.Date
20:55technomancy(System/currentTimeMillis) is what you want
20:56rhcah, thank you technomancy
20:56muhootechnomancy: any thoughts on how to get a repl on a socket from lein, starting lein without a controlling terminal?
20:57technomancyyou can just eval-in-project the repl-form stuff from the repl task
20:57technomancywith your own task
20:58muhooah, ok, thanks.
21:03TimMcrhc: There is also a nanos timer that guarantees better precision but no accuracy
21:04rhcTimMc: i saw that, i also laughed at the caveat
21:04rhcDifferences in successive calls that span greater than approximately 292 years (263 nanoseconds) will not accurately compute elapsed time due to numerical overflow.
21:04TimMc2^63
21:04rhci like to think my programs will be around for awhile... but i'm also realistic :)
21:04TimMcclipboard format conversion fail :-)
21:05rhcah, yeah, on the site the 63 is shifted vertically :)
21:05rhcsuperscripted
21:08muhoohmm, not quite
21:08muhooif i start clojure.main/repl from inside the project, the socket doesn't start
21:09muhoook, eval-in-project. gonna have to dive deep, looks like.
21:11mstumpgiven an uberjar I created via lein how can I invoke some class? the machine doesn't have lein installed, if it did I could just use that.
21:13muhoomstump: i think the classes show up if you unzip the jar and loook at it
21:13muhoolike lancet$untar__405.class , those ugly names, you can call from java i bet
21:14mstumpwill that avoid "Failed to load Main-Class manifest attribute from"
21:22mephist0hi there: i thought (reduce + 1 {:a 1, :b 2}) should return 4 but it says "clojure.lang.MapEntry cannot be cast to java.lang.Number". Is there a function capable for this? Thanx
21:23ibdknox,(reduce + 1 (vals {:a 1 :b 2}))
21:23clojurebot4
21:25mephist0<ibdknox>: thank you very much.
21:39mephist0,(if true "yes im a bot")
21:39clojurebot"yes im a bot"
21:41brehaut_,"values are expression too"
21:41clojurebot"values are expression too"
21:42cjfrisz,"Functions are values."
21:42clojurebot"Functions are values."
21:44ibdknox,:scooby-doo?
21:44clojurebot:scooby-doo?
21:45scriptor,(if ((fn [] true)) "clojurebot does functions!" "No it doesn't :()
21:45clojurebot#<ExecutionException java.util.concurrent.ExecutionException: java.lang.RuntimeException: EOF while reading string>
21:45scriptor,(if ((fn [] true)) "clojurebot does functions!" "No it doesn't :(")
21:45clojurebot"clojurebot does functions!"
21:45scriptorwhee
21:48cafesofie,(list (take 48 (cycle (str (Math/sqrt -2)))) "Batman!")
21:48clojurebot((\N \a \N \N \a ...) "Batman!")
21:48cafesofieaww, truncated :(
21:49aperiodic,(list (take 16 (cycle [(str (Math/sqrt -2))])) "Batman!")
21:49clojurebot(("NaN" "NaN" "NaN" "NaN" "NaN" ...) "Batman!")
21:50cafesofiethe original haskell was better, but after a brief attempt i couldn't translate it
21:50cafesofie((++" Batman!") . take 48 . cycle . show) (0/0)
21:51ivanfailed port, you're supposed to get 17 NaNs ;)
21:51aperiodiccafesofie: the character literals were because you're passing the string itself to cycle, so it's being treated as a list
21:52cafesofieaperiodic: yeah once i hit the absence of 'show' i just gave up on translating it :)
22:00scriptorhmm, almost there...
22:00aperiodic,(apply str (concat ((comp (partial take 17) repeat) (Math/sqrt -1)) [" Batman"]))
22:00clojurebot"NaNNaNNaNNaNNaNNaNNaNNaNNaNNaNNaNNaNNaNNaNNaNNaNNaN Batman"
22:01aperiodicunfortunately the succinctness of Haskell's point-free syntax is hard to beat
22:01aperiodicthough i remember amalloy showing me a clojure DSL that came close
22:03arohnerdoes paredit break for anyone else, when there is a paren in a comment? i.e. ;; (
22:04scriptor,(->> [(Math/sqrt -2)] cycle (take 16) (reduce str) (#(str %1 " Batman!")))
22:04clojurebot"NaNNaNNaNNaNNaNNaNNaNNaNNaNNaNNaNNaNNaNNaNNaNNaN Batman!"
22:05scriptorsomewhat close to the haskell implementation, to make it cleaner you'd use join from clojure.string and some existing function to flip arguments instead of that ugly anonymous function at the end
22:05aperiodicof course, the threading macro!
22:05scriptor:)
22:19cgagi'm messing around with clojurescript, using noir/crate/jay, when I try to create some html using crate/html, then append it to a div, it only shows up if it's a single tag
22:19TimMcarohner: It can happen, yeah.
22:19cgagfor example appending (crate/html [:p "hello"]) works, while (crate/html [:p "hello"] [:p "goodbye]), does not
22:20lancepantzcgag: you are missing a '"'
22:20cgaganyone have any experience with those libs? also if i should be in a clojurescript chanel let me know
22:20lancepantzif you had a compiler error, that's why
22:20cgagthat was just a typo, i have it in my code
22:20lancepantzah, k :)
22:21lancepantzbut yeah, not familiar with them
22:25m0smithI have a noir/ring/jetty question
22:25m0smithhi all
22:31m0smithhello?
22:31clojurebotBUENOS DING DONG DIDDLY DIOS, fRaUline m0smith
22:32cgaghi
22:33m0smithI have a question about using JNDI with noir/ring/jetty. Where or where would I find some pointers?
22:33unlinkWhat is the conventional way to scope the lifetime of a resource in Clojure? In my case, I am okay with lexically scoping my resource management, but I would prefer not to bake a new macro for each kind of resource I am closing.
22:34ibdknoxcgag: you'd need to create them separately or wrap them in a container of some kind
22:38weavejesterm0smith: Isn't JNDI orthagonal to Ring?
22:39m0smithweavejester: how so?
22:40weavejesterm0smith: Well, JNDI is just a directory service, right? It could be accessed from a GUI, a CLI, or from a web app without the back end changing.
22:40weavejesterm0smith: Why would you need anything special for Ring/Noir?
22:40cgagah ok, doing something like [:div [:p "hello"] [:p "goodbye"]] worked
22:41m0smithJust wondering how to enable it in the underlying jetty
22:41m0smithSince Jetty is embedded I am having a hard time finding how to get it to work
22:41weavejesterm0smith: Jetty is a web server. How would JNDI be enabled?
22:42weavejesterm0smith: Do you mean using JNDI for basic auth or something like that?
22:42m0smithweavejester: no, for database connections
22:43weavejesterm0smith: But the web server has nothing to do with database connections
22:43weavejesterm0smith: Usually anyway
22:43weavejesterm0smith: There might be some weirdness in the Java web stack I'm unaware of.
22:43ibdknoxwhy aren't you using JDBC anyways?
22:43m0smithweavejester: I want my app to be able to rely on the container, be it Jetty, Tomcat, or Glassfish to use JNDI to retrieve the data source
22:44m0smithIibdknox: I am using JDBC (hibernate actually)
22:44m0smithibdknox: By moving the data base connection info into JNDI, I can deploy my app on several different servers
22:45weavejesterm0smith: Are you interfacing with a legacy Java app, then?
22:45cemerickm0smith: JNDI isn't in-scope for ring. You should just use the usual routes for configuring it (i.e. InitialContext, etc). You're going to need to use .war deployment and each container's specific configuration bits though.
22:46cemerickJNDI is crazy-overkill for nearly everything IMO, but to each his own.
22:46m0smithIt is a new Noir based app
22:46m0smithIn my case it works out nice to be able to separate the database configuration from the app
22:46weavejesterIf it's completely new, you should probably stay weeeeeell away from JNDI.
22:46cemerickIn that case, just use env vars or system properties for your JDBC props.
22:47weavejesterI prefer env vars myself. :)
22:47m0smithI am not sure if I can do that on jelastic
22:47cemerickI quite dislike env vars, but, yeah, sure. :-)
22:47weavejesterJNDI is very much a Java thing, and not very "Clojurey"
22:47ibdknoxenv var for mode + config maps = win ;)
22:47cemerickIt's not even a Java thing, really. It's easy to avoid it, regardless of the language you're using.
22:47m0smithIt is, but it is also well supported on all the platforms
22:48ibdknoxm0smith: what exactly does it provide you
22:48ibdknoxI can definitely deploy to all the things you mentioned without jndi
22:48cemerickweavejester: I wonder if I can reopen the notion of optionally getting e.g. :servlet-request into request maps in the jetty adapter with you?
22:49m0smithibdknox: I would like to know if oyu will share. My goal is to not have to change the WAR file regardless of where it is deployed
22:49cemerickI see it's come up before on the list. I ended up using hooke to get it into my request maps, so I could use a library that required an HttpServletRequest as a method parameter. :-(
22:49weavejesterHmm...
22:49ibdknoxm0smith: connecting to the DB has nothing to do with the war file?
22:49cemerickm0smith: system properties FTW :-)
22:50weavejesterMaybe if it was an option… by default turned off...
22:50cemerickyeah
22:51cemerickI didn't mind using a hook, but it'd get a lot messier if I happened to need the response (!).
22:51m0smithibdknox: The code needs to be able to find the database connection, even if it is at a different URL
22:51weavejesterI don't want to encourage HttpServletRequest use, but sometimes when all your fellow libraries are doing it, you need to give into peer pressure.
22:51cemerickThe odd thing to me is that it's the default in defservice, but totally absent in the jetty adapter.
22:51ibdknoxm0smith: so just have a couple of different config objects and read an env var to determine which to use
22:51ibdknoxm0smith: the only thing you fundamentally need to know is "what mode am I in?"
22:52ibdknoxeverything after that can be handled by the app
22:52weavejestercemerick: Well, defservice means you're interfacing with some legacy Java servlet container
22:53weavejestercemerick: Whilst an adapter is supposed to be free of that, or at least pretend its not there.
22:53weavejestercemerick: As you can't rely on an adapter being built on top of a servlet container like Jetty
22:53weavejestercemerick: And you should be able to switch adapters without changing your code.
22:54cemerickOK, I can see that. I had always thought of the defservice/adapter distinction as one of container vs. containerless deployment.
22:54m0smithibdknox: I am not sure how I feel about that .... Basically recreating the functionality that JNDI provides
22:55ibdknoxlol
22:55cemerickFWIW, here's the janky API that requires the actual servlet req: https://code.google.com/p/jopenid/source/browse/trunk/src/main/java/org/expressme/openid/OpenIdManager.java#86
22:55cemerickbleh :-|
22:55ibdknoxm0smith: okidoke, good luck with JNDI - I literally know nothing about it :(
22:56cemerickweavejester: anyway, just a data point. The workaround isn't tough, of course.
22:56ibdknoxfwiw, the funtionality we're talking about here is like 2 calls?
22:56ibdknoxso I'm not sure I understand the reservation, but to each his own :)
22:56weavejesterIt looks like jelastic is very "old-school Java"
22:57weavejesterNo 12-factor apps there
22:57cemerickm0smith: JNDI is basically a glorified key/value map. Not a lot special going on.
22:57m0smithweavejester: It is. I am creating a noir webapp and deploying to glassfish
22:57weavejesterIt doesn't appear as if you can set environment variables in jelastic
22:57weavejesterWhich is a little crazy.
22:58m0smithweavejester: exactlym hence the JNDI configuration
22:58weavejesterm0smith: Yeah, I can see why you're doing it now
22:58weavejesterm0smith: It looks like it's the way jelastic encourages
22:59m0smithweavejester: and to be honest, I have been writing Java webapps for a long time and it just makes sense to me
22:59weavejesterm0smith: But hang on, there's a Java example on how to use it.
22:59m0smithweavejester: use what?
22:59weavejesterm0smith: http://jelastic.com/docs/connection-to-db-via-jndi
23:00m0smithweavejester: Yes, my question is how to enable JNDI in jetty under ring. I know how to do it in a standalone jetty
23:00weavejester(-> (InitialContext.) (.lookup "java:comp/env/jdbc/jelasticDb") (.getConnection))
23:01weavejesterThat apparent gets you your database connection
23:01weavejesterAnd that should be it.
23:02weavejesterAs cemerick said, it's just a key-value lookup.
23:02m0smithit is. Unfortuntely it is not unabled in jetty by default and the lookup throws an exception
23:02lancepantzwhoa whoa whoa, wtf is this http://www.techworld.com.au/article/419328/clojure_inventor_hickey_now_aims_android/?fp=16&amp;fpid=1
23:02m0smithenabled I mean
23:03lancepantzdid i miss something?
23:03cemericklancepantz: ?
23:03cemerickm0smith: so deploy a war into jelastic and you have standalone jetty/tomcat/whatever?
23:04cemerickDunno, a host that requires JNDI for simple stuff is a host that I'd avoid. *shrug*
23:04lancepantzcemerick: rich is targeting android?
23:04m0smithcemerik: exactly, but I like to do my inital testing using "lein run" which starts up in jetty
23:04weavejesterm0smith: Oh, the configuration comes from web.xml...
23:04cemericklancepantz: There's various tweaks that have been on the table for a while for android. I have no idea how that tangent in the interview ended up being the headline.
23:05m0smithweavejester: exactly
23:05weavejesterm0smith: Hm. You might be on your own here. I need to get to sleep :)
23:05cemerickProbably the one that could get the most juice for the piece, I guess.
23:05lancepantzcemerick: yeah, i just noticed that too as i actually read it, all he says is "people are working on it"
23:05m0smithweavejester: thanks, just hoping someone know
23:05m0smithhow to configure jetty
23:05lancepantzjust a sensationlized headline
23:05weavejesterI'm inclined to agree with cemerick, though.
23:05cemerickyeah
23:05cemerickand a roughly-edited interview to boot
23:06weavejesterI'd avoid jelastic until it supports a third way aside from hard coding the database or using JNDI
23:06cemerickI've deployed to a lot of hosts, but never heard of one that *required* JNDI. That's nuts, even for a Java app.
23:07m0smithok, thanks for the advice
23:07cemerickAll FWIW, of course. :-)
23:07cemerickand worth every penny! :-D
23:10m0smithlol
23:42cemerickemezeske: that's rough (re: your ML post, which ironically arrived after 24 hours) :-(
23:42muhooheh, running a network connected repl from lein trampoline repl via a systemd startup service, it looks like this in ps: https://refheap.com/paste/1313
23:44muhoomy guess is that's the whole repl as source code
23:49emezeskecemerick: Heh, thanks :)
23:49lancepantzyes
23:50emezeskecemerick: Oh well, I'm not moderated in here (yet) !
23:50cemerickThere is an "always allow" option in the moderation panel…
23:50cemerickemezeske: you'll always be welcome here :-)
23:51cemerick(there's no op for the channel anyway)
23:51emezeskeHah
23:52cemerickwell, there is one, but *shrug*
23:55cemericknah, he's with the Allies :-P
23:55cemerickemezeske: did you enjoy the conf?
23:56emezeskecemerick: Most definitely! It was very cool to see the people behind the IRC handles :)
23:56emezeskeExcellent talks, all around
23:56lynaghk Too many cabbies demanding cash, I heard...
23:56emezeskeIncluding a certain talk about what sucks about clojure ^_^
23:56cemerickheh
23:56emezeskelynaghk: Seriously! Jerks!
23:57cemericklynaghk: what happened?
23:57cemerickemezeske: I was honestly happy that I got out of the room without being barraged. :-)
23:57lynaghkcemerick: emezeske and I shared a cab, and the guy just wanted cash. emezeske was unnecessarily upset about it, I thought = P
23:58emezeskecemerick: Nah, it was one of those "we need to talk" kind of things, where you know it must be said
23:58cemerickour cabbie had a square, so that worked well.
23:58lynaghkcemerick: I'm not so excited about that kind of future after the hotel lobby iPad refused to let me sign out
23:58cemerickYeah, I hope nothing presented was super-controversial.
23:58cemerickDebatable maybe, but…
23:59cemerickSo that's what those things were for. I always check the in-room TV, and then talk to the desk otherwise.
23:59lynaghkoh, no
23:59lynaghkI mean sign out of gmail
23:59lynaghkthe damn machine had an alert from my calendar on it the next day