#clojure logs

2012-07-16

00:07Raynessproc: I call it annoying.
00:07Raynes;)
00:12michaelr`good morning everybody!!!
00:21pppppaulwho here is on a mac?
00:31akhudekI am, can I help?
00:44duck1123"In a recent poll in #clojure, 100% of respondants reported using a Mac"
00:48musicalchairis there something I have to do to get local vars to show up in a slime stacktrace (using swank)?
00:48musicalchairAll I ever see is
00:48kreig1crime in the city
00:48scottjmusicalchair: clojure?
00:48musicalchair"[No locals]" (whoops, accidentally hit return)
00:49musicalchairyeah
00:49scottjmusicalchair: oh, thought I was in #emacs :)
00:49musicalchairscottj: heh
00:50scottjmusicalchair: I think you only see them if you call (swank.core/break) and then some are cleared. clojure 1.4 has an option to turn locals clearing off. I haven't done any of this in months though so my memory could be wrong.
00:54musicalchairscottj: hmm ok - that works. I'll dig around for the locals clearing toggle
00:55scottjmusicalchair: also ritz might support showing locals in more cases than clojure-swank.
00:57arrdemis there a better parser library for Clojure than fnparse?
01:01musicalchairscottj: cool, I'll look into that. Thanks
01:01arrdemand by better I simply mean more up to date... I see some updates on clojars but none which is a clear successor too joshua-choi's
01:01akhudekarrdem: not that I know of. You could always try using ANTLR (java lib) if fnparse doesn't work for you.
01:02akhudekalso, no updates is not necessarily a bad thing
01:03akhudekalthough I guess a proper clojure 1.3 update would be good
01:03arrdemakhudek: I've used fnparse before and I love it... but post-1.3 and not requiring clojure-contrib (which lein2 no longer supports) would be nice
01:03arrdemand is why I ask
01:04dakronearrdem: https://github.com/protoflex/parse-ez maybe?
01:05arrdemdakrone: that's cool...
01:05technomancyparsatron looks nice, but I haven't used it
01:05akhudekthis is always good to check too: http://clojure-libraries.appspot.com/
01:09technomancyclojurebot: ok, go get a mop
01:09clojurebothttps://github.com/technomancy/robert-hooke
01:10technomancythat'll do
01:10arrdemI..... what is this witchcraft
01:11arrdembesides awesome that is
01:38dsrguruis there a way to have lein download functions to use or require in the repl?
01:38dsrguru*download code containing functions I want to use ...
01:48ro_stdownload from where?
01:48dsrgurufrom their repositories
01:49ro_stfrom git?
01:49technomancydsrguru: pomegranate does that
01:49dsrguruas in, have lein do its magic from the repl
01:50dsrgurutechnomancy: I just did a brief google, but pomegranate's main functionality seems to be add-classpath, which I don't think is what I'm looking for
01:51dsrgurutechnomancy: I'm trying to find a way to have lein pull .clj files from wherever lein normally does, but from within the repl
01:51technomancysure; that's exactly what pomegranate's add-classpath does
01:51dsrguruoh really?
01:51dsrguruoh I see
01:51dsrgurutechnomancy: thanks so much
01:53dsrgurutechnomancy: but I have a bit of a chicken/egg problem--how do I load pomegranate from the repl to begin with? XD I'm not running this from within a project where I could add pomegranate to the project.clj
01:55technomancyyou could add pomegranate in your user profile
01:55ro_stor just paste the source of pomegranate into the repl
01:55dsrgururo_st: ^_^
01:55ro_st(hopefully it ain't too much)
01:55dsrgurutechnomancy: is a user.clj the same structure as a project.clj?
01:56dsrgururo_st: what if it depends on other libraries? =O
01:56ro_sthttps://github.com/technomancy/leiningen/blob/master/doc/PROFILES.md
01:56technomancyyeah, or `lein help profiles`
01:56dsrguruneither actually contains the text "user.clj" or anything.clj besides profiles.clj for that matter
01:56ro_sttechnomancy: curious about using MD for the help text. is there some way to get plain-plain text, or is it just because you re-used the github content?
01:57dsrguruoh it's just ~/.lein/profiles.clj
01:57dsrgurugot it
01:57technomancyro_st: no way to get plain text, no
01:57technomancyit'd be lossy; I think even if it's a bit ugly in places having the URLs is an overall win
01:58ro_sttrue
01:58ro_sti've been piping it to Mou anyways
01:58ro_sthttp://mouapp.com/
02:02xumingmingv,(meta pos?)
02:02clojurebotnil
02:02xumingmingvwhy (meta pos?) is nil? shouldn't it has some metadata such as :added and :inline?
02:02xumingmingv,(source pos?)
02:02clojurebotSource not found
02:02ro_st&(source pos?)
02:02lazybotjava.lang.RuntimeException: Unable to resolve symbol: source in this context
02:03dakrone,(meta #'pos?)
02:03clojurebot{:ns #<Namespace clojure.core>, :name pos?, :file "clojure/core.clj", :line 1183, :arglists ([x]), ...}
02:05dakronexumingmingv: you want metadata on the var itself, not the value
02:05xumingmingvthanks dakrone
02:06dsrgurutechnomancy: thank you so much, pomegranate is exactly what I needed
02:14ro_stdoes sorted-set return a set that automatically sorts itself when ever more stuff is added?
02:14ro_stor does it just do a one time sort
02:15ro_sti guess that's a misnomer, because you can't add stuff to a set, it's immutable :)
02:16ro_stso i'd have to use sorted-set whenever i want a fresh one with something added
02:17ro_sthuh. looks like the sorting is kept even when i conj
04:44steficiao
04:44stefi!list
05:42augustlwhy does .clj files have to use underscores in order to be found? Artifacts of the jvm classloader stuff?
05:56raekaugustl: I think it has to do with the names of the classes that clojure emmits
05:57raekclass names can not have hyphens in them
05:57augustlraek: ah I see
06:07hcumberdaleHi ;)
06:07hcumberdaleHow to provide webservices from clojure?
06:13augustlwill keywords always stay in memory once they're used, similar to Ruby symbols?
06:14augustlin Ruby, it's unsafe to use keywords for user input (like query strings), for example, as that gives users the ability to make the ruby process go out of memory
06:14augustls/keywords/symbols/
06:15Guest60085augustl: afair symbols are interned like strings
06:18hcumberdalecan't find a solution
06:18hcumberdalehttp://blog.japila.pl/2011/02/learning-clojure-and-jax-ws-at-once-clojure-supports-annotations-but-jax-ws-doesnt-like-it/
06:18hcumberdaleonly people trying it without success
06:23Guest60085hcumberdale: if you find no clojure lib, search a java lib for webservices that does not need annotations to work
06:25hcumberdaleGuest60085 there is clj-soap
06:26hcumberdaleIt uses Axis2 and the implementation is from 2011
06:26Guest60085Guest60085?
06:26hcumberdaleOnce you tried axis2, you'll likely never touch it again
06:27Guest60085because of configuration stuff? or runtime performance/quality?
06:28hcumberdaleGuest60085 yes
06:28hcumberdaleEverything!
06:28Guest60085humm, am I displayed as guest?
06:28hcumberdaleStarting with how webservices can be developed. There is no clear way
06:28hcumberdaleGuest60085 << yes?!
06:29hcumberdale~clgv@saturn.informatik.uni-ulm.de
06:29clojurebotHuh?
06:29Guest60085strange my client tells me different and had no auth problems
06:29hcumberdaleI'm using MIRC,... strange
06:29hcumberdaleAXIS is jut not simple
06:30Guest60085but if clj-soap does a good wrapper job, it could be simple with this lib. did you try it?
06:30hcumberdaleBut their homepage is crazy fast
06:30hcumberdaleNo, not yet. Sure I will
06:31hcumberdaleIt is crazy that this is the only one lib
06:31hcumberdaleAnd it is not 100% clojure ;(
06:31hcumberdaleWrap axis2 sounds not nice, cause there are so many ways how to deal with axis2
06:31Guest60085well, maybe the soap hype is over ;)
06:32hcumberdaleI think soap is a good thing
06:32Guest60085honestly, it has only one small source file, so I doubt there is much comfort built-in
06:32hcumberdalebut it is a bit complex. All the specifications (Assured delivery, security,...)
06:33hcumberdaleIt seems it is way too abstract.
06:34hcumberdaleHardcoded casting of objects,... no byte[] handling
06:34hcumberdaleAnd damn no MTOM support
06:34Guest60085do you need soap specifically?
06:34hcumberdaleyes!
06:34hcumberdaleCause part of my job is standard software integration
06:34hcumberdalethey rely on soap
06:35Guest60085you could use your favorite java lib
06:35Guest60085and maybe build a clojure wrapper-layer if it is worth it
06:36hcumberdaleYeah, but I have no favourite java lib
06:36Guest60085then one that gets the job done ;)
06:36hcumberdaleIt is like selecting bad or worse :)
06:37hcumberdaleServices and POX seem to work pretty well with clojure
06:37Guest60085well, then you can only start with the specification and build a 100% clojure solution ;)
06:37hcumberdalebut POX is missing binary attachments and so on
06:37hcumberdaleGuest60085, that will be the best possible
06:37Guest60085but a lot of work, I assume
06:38hcumberdaleyes that is what i'm affraid of
06:38Guest60085probably the spec has 300+ pages? ;)
06:38hcumberdaleIt is possible to run axis2 standalone, in a server as a servlet, as a embedded service (war),...
06:38hcumberdaleGuest60085 I think more
06:38hcumberdalethe most implementations are not 100% compatible
06:39hcumberdalethat's the pain of the companies using all the webservice stuff
06:40hcumberdaleGuest60085, ever worked with generated objects from a design model in java?
06:41Guest60085nope. tried that in a different environment, though
06:42hcumberdaleWebservices in java work in common with a contract (WSD)
06:42hcumberdaleand the frameworks are generating java pojos from that contract or a contract from java pojos
06:42hcumberdalewsdl2java.exe java2wsdl.exe
06:43hcumberdaleIt is insane what kind of bullshit is coming out of the code generators
06:43hcumberdalebut it works
06:43hcumberdaleAnd it's part of your code (you have to maintain)
07:11augustlI have an app that depends on a mongodb helper library. Is there a way to make hy app use my local file system version of the library, so I can integration test without deploying a new version of the mongodb helper?
07:11augustlthis is a leiningen question I guess
07:11augustlnot going to check this local file system dependency into git, it's just temporarily before I push
07:13Bronsals
07:13Bronsaops.
07:25tomojaugustl: you know about "checkouts"?
07:26tomojI think you can just `mkdir -p checkouts && ln -s /path/to/your/local/project checkouts/project`
07:27tomojleave the dependency in project.clj
08:51augustltomoj: ah, I'll try that, thanks
09:20gtrakduck1123: I managed to get the swank in java-app working pretty trivially, now I'm trying to see what it would take to proxy every spring bean in the app
09:20duck1123cool
09:20duck1123I didn't even bother to try that over the weekend
09:21gtrakhttps://gist.github.com/3122677
09:21gtrakI think it'd be fun to wrap every bean in clojure somehow
09:21gtrakthough probably totally useless
09:21gtrakspring has methods to generate a union interface of a list of interfaces from a class
09:22gtrakand a AOP post-processor
09:23gtrakI could totally abuse AOP
09:25gtraknot terribly useful since IDE's have hot code-reloading, but could be fun
09:54augustlafter http://pastie.org/4266135 I still get "com.fasterxml.jackson.core.JsonGenerationException: Cannot JSON encode object of class: class org.bson.types.ObjectId" - any ideas why?
09:56augustlI do a println the line before I add it and I see it print when running my tests so I'm pretty sure it's hooked up correctly ;)
09:57duck1123It doesn't know how to turn a object id into json
09:57duck1123nvm
09:59augustloh you seem to need to use the "encode" from the "custom" namespace
10:00wingyin a file i am using "ns" and i required a namespace :as another alias .. i run that file from the repl..switching to that namespace but i cant access the namespace via the :as alias
10:00wingyis there a way to do that? so i can interact with that namespace from the repl instead of from the file
10:00Guest60085wingy: in "lein repl" ?
10:00wingyGuest60085: yeah
10:01Guest60085wingy: how did you switch?
10:01wingyin-ns
10:01wingythe def vars i defined in that file worked
10:01wingybut the ns :require lib :as lib-alias didn't work
10:01wingyi mean i cant access it from the repl
10:01wingyonly from the file
10:02Guest60085try (require 'that.ns.you.were.talking.about) and then (in-ns 'that.ns.you.were.talking.about)
10:05wingyhere is an example about what im talking about: https://gist.github.com/3122894
10:05ro_stwingy, what Guest said
10:06ro_st(in-ns doesn't trigger the target ns's require/use statements
10:06augustlare there any generic ways of deep-mapping any sort of collection so that all keys or values matching a predicate gets filtered through a function?
10:06ro_staugustl: clojure.walk
10:06augustlwant to .toString all ObjectId instances in maps
10:06augustlro_st: looking it up, thanks
10:06Guest60085augustl: tree-seq might be an option as well
10:06ro_stlook at keywordize-keys for nice reference code
10:07wingyro_st: yeah but now i used "ns" from the repl but it still doesn't work
10:07ro_stdo a require of the aliased namespace, then a require of the target namespace, then in-ns the target namespace
10:07wingythe test file i ran with this could access the symbols without problems .. i wonder why i cant access them from the repl
10:07Guest60085wingy: "yi" cannot be resolved since it is only an alias. try to call a function with yi
10:07ro_styou could try inspecting the value of your alias in the repl as well
10:09duck1123does in-ns-ing into a non-existant ns still mess everything up?
10:09wingyGuest60085: oh right .. yi is a namespace :P
10:09Guest60085wingy: that worked (ns blubb (:require [clojure.string :as s])) s/replace
10:09Guest60085wingy: no! yi is an alias to a namespace
10:09duck1123I remember at one time, if you did this than you dodn't even have clojure.core
10:09Guest60085duck1123: exactly
10:10ro_stduck, afaik the ns form does in-ns internally?
10:10ro_styup
10:10wingyGuest60085: yeah to yobistore.core .. and typing yobistore.core yields the same problem since it's not a symbol .. anyway .. i get it now .. i accessed the vars in it and it works now
10:10timmc&(macroexpand-1 '(ns foo))
10:10lazybot⇒ (do (clojure.core/in-ns (quote foo)) (clojure.core/with-loading-context (clojure.core/refer (quote clojure.core))))
10:10wingythx for the help
10:11duck1123I was asking because he was in the ns before hand. (because of previous testing, no doubt)
10:11ro_stin-ns should be idempotent? make it if it aint there, otherwise just switch?
10:12duck1123well, looking at that expand, there really isn't much "making" the ns, just making sure that clojure is also referred
10:14ro_st,(doc 'in-ns)
10:14clojurebot#<ExecutionException java.util.concurrent.ExecutionException: java.lang.ClassCastException: clojure.lang.Cons cannot be cast to clojure.lang.Symbol>
10:14ro_st,(doc in-ns)
10:14clojurebot"([name]); Sets *ns* to the namespace named by the symbol, creating it if needed."
10:14Guest60085duck1123: especially not loading an ns with the same name from classpath ;)
10:16duck1123(doto 'the.ns.inquestion require in-ns) is always handy
10:16augustloh my, postwalk is brilliant :O
10:17ro_stduck1123: clever!
10:21wingyi know a great feature for lein repl
10:21wingy() matching
10:21gtrak`augustl: tree-seq?
10:22wingyso when i type ( it will give me () with the cursor in between
10:22ro_stwingy: emacs slime repl with paredit :)
10:22wingythat would save us a lot of times
10:22wingyro_st: but does that work in repl mode?
10:22ro_sti have full code completion and paredit and rainbow parens in my repl
10:22ro_stsource and doc lookup too
10:22wingyoh
10:22wingyare you new to emacs?
10:23duck1123wingy: it does, but IMHO it's more pain than it's worth
10:23wingyi guess i should give emacs a try
10:23ro_stquite new, yes
10:23wingyduck1123: why?
10:23ro_stswore like a trooper for the first week. all good, now
10:23wingy:)
10:23duck1123since enter in slime submits when you have matching parens, you can't enter a newline without accidentally submitting
10:23wingyro_st: you got good tutorials?
10:24wingyi guess that emacs is a better fit then vim for clojure?
10:24duck1123I love paredit, but everytime I turn it on in the repl, I get annoyed and turn it back off
10:24ro_stwingy, the emacs peepcode is good
10:24scriptorwingy: emacs has way better tool support for clojure, yes
10:24ro_stas for clojure in emacs, https://github.com/technomancy/swank-clojure
10:25scriptoralso much more clojure+emacs documentation around
10:25ro_stthe cheatsheet halfway down the page
10:25ro_stwrite it out and make the effort to use them
10:25ro_stalso http://emacswiki.org/emacs/PareditCheatsheet
10:26ro_stsome utterly indispensible ones that aren't on there: C-M-space to select entire form, and C-M-k to select-and-cut entire form
10:26ro_stgood luck, and apologies in advance -grin-
10:26ro_stmy uptodate emacs config https://github.com/robert-stuttaford/.emacs.d
10:27ro_stincludes symbol highlighting, where if you rest on a symbol it'll highlight all the occurences in the buffer. super useful when refactoring
10:28ro_stin my config, f11 opens the custom keybindings config file and f12 opens the main custom config file, where i set colour and fonts etc
10:28ro_stso you can see what i've added
10:28wingyoh emacs was already installed
10:29wingyemacs is written in common lisp?
10:29ro_stin emacs lisp
10:29timmcand C, probably
10:29duck1123F12 is hardwired into my brain for drop-down terminal now.
10:29ro_sti have iterm fullscreen on monitor 2
10:29ro_stbound to cmd-shift-` at the OS level
10:32wingybut when light table is coming out will you switch to it or still use emacs?
10:33ro_stemacs for sure
10:33ro_stwith the paredit editing shortcuts, all the bracket hopscotchery just melts away
10:34ro_stalso, midje-mode
10:36ro_sthttps://www.shortcutfoo.com/app/tutorial/emacs
10:37wingygreat link
10:37wingyalso there is a internal tutorial in emacs
10:37wingyi love such tutorials
10:37ro_styeah
10:37ro_styou can also C-h f clojure-mode
10:37timmcwingy: http://www.brainonfire.net/blog/emacs-n00b-start/
10:37clojurebotmake a note of http://scienceblogs.com/goodmath/2006/11/the_c_is_efficient_language_fa.php it is yet another article about picking c or c++ for performance being naive
10:38TimMcclojurebot: Hush.
10:38clojurebotCool story bro.
10:38vijaykiranwingy: The first thing to try will be C-h t in emacs - in built tutorial
10:44wingya little bit uncomfortable fingerposition to hit the CTRL all the time
10:45wingywhich finger do you use to press CTRL and ALT?
10:45vijaykiranI swap Ctrl - Capslock
10:45wingyhow?
10:45clojurebotwith style and grace
10:45wingywhat?
10:45clojurebotwhat is short for ,(doc ...)
10:45vijaykiranand for Alt - (C-x m) is mapped to Alt-x for looking up other commands
10:46vijaykiranwingy: on Mac, you can just change the keys in system settings
10:46gtrak`isn't the fastest math stuff in fortran anyway?
10:47wingyvijaykiran: yeah it worked
10:47wingyand you others .. which finger do you use for CTRL and ALT
10:52wingyhmm my ALT+v gives me a character
10:54wingyok now it works .. i changed what it meant in iTerm
10:54wingyyou have to have it meaning ESC
10:54wingyfor soem reason
10:55Guest60085clojurebot: botsnack
10:55clojurebotthanks; that was delicious. (nom nom nom)
10:55llasramI use a Kinesis keyboard and have the big left thumb keys which are typically Backspace and Delete mapped to Control and Meta
10:56llasramIt's a little sub-optimal using the same hand for pressing the modifiers every time, but since it's the thumb and doesn't need to move very far, it isn't too bad
10:57TimMcobligatory foot-pedal remark
10:57llasramYeah -- still need to give that a try :-)
10:58wingyseriously
10:58ro_sti'm on a mac, but i use an MS ergo 4000. i made the alt key trigger Cmd, and the win key trigger Alt (or meta). so i can cmd with my left thumb. then i made caps lock trigger Alt
10:58wingythat would be way better than having to press CTRL and ALT
10:59ro_stpinky on ctrl, ring-finger on caps, thumb on cmd. feels natural
10:59wingyro_st: is there a win key on mac
10:59ro_stya, the Command key
10:59uvtcUsing Emacs on a Mac was a pain for me due to that Cmd/clover key. Seems much easier on GNU/Linux where, for the most part, there's just ctrl and alt.
11:00gtraki like my little leopold KB: http://elitekeyboards.com/products.php?sub=leopold,tenkeyless&amp;pid=fc200rtab
11:00ro_sti'm using mac emacs, which supports cmd c/v/x for copy paste cut
11:00ro_sti also have find-file-in-project mapped to cmd-t, like textmate
11:00wingyro_st: isnt CMD reserved for other things
11:00wingyin iTerm
11:01ro_stit's not quite the same as textmate's fuzzy, but it's close enough
11:01ro_sti dont emacs inside a terminal
11:01ro_sti use this http://emacsformacosx.com/
11:01wingywow looks cool
11:01ro_stwith this, i can have emacs put windows on multiple monitors
11:01sh10151is there an idiomatic way to guard against closing *out* when using with-open and writer from clojure.java.io ?
11:01uvtcI meant that, in Emacs, you're using ctrl and alt all the time, but in mac-land you're using Cmd, and I didn't have any spare room on my keyboard to map Cmd to.
11:01sh10151or really, any already open stream
11:01ro_stso i've got 4 buffers open and visible at 120 characters wide
11:02sh10151i'd like to use with-open liberally but i don't want to close streams that are already opened by calling code, like *out*
11:03kreig1sh10151: hmm, why would with-open end up closing *out*?
11:03sh10151i think it closes anything?
11:03kreig1sh10151: no, it closes what you give it
11:03ro_stwhich is great for having a code file, a midje file, a repl, and stuff like compilation output and whatnot visible all at once
11:03sh10151right, so I want to use with-open and reader
11:03sh10151so if someone wants to they can pass a filename
11:04sh10151or an open stream
11:04sh10151or a URL
11:04sh10151the trouble is guarding against the open stream case
11:04kreig1sh10151: if they pass you an open stream, assume they are gonna take care of closing it
11:04kreig1sh10151: don't be closing my stream that I pass in, wether it's *out* or not
11:04sh10151right, so I have to special case and only use with-open if they don't pass a stream
11:04sh10151i was wondering if there is an idiomatic way to do that
11:05sh10151also it seems like something that might be nice to take care of in the macro
11:05sh10151confusing that with-open takes stream arguments and yet misuses them
11:05wingyro_st: i wonder if using that one is better than the terminal one
11:06kreig1sh10151: well, proly cause some streams are a little mroe involved to create
11:07kreig1so I want the operation to work on a stream too, even if I have to write some kind of complicated constructor, like for a video transcoding stream or whatever
11:07TimMcsh10151: Don
11:08ro_stwingy: for me, it certainly is
11:08TimMcsh10151: Don't use with-open, then. Get a stream for whatever it is, write to it, and done.
11:08wingyro_st but i lose the ability to run emacs in ssh session
11:09ro_stonly if you ssh into that mac from elsewhere
11:09sh10151TimMc: that's what reader is doing in all cases but when an already-open stream is passed in
11:09ro_stis that what you're doing?
11:09wingyyepp
11:10wingyno but i could use emacs instead of vim to edit remote files
11:10ro_stwingy: i'm not sure which parts of my config require the full ui. haven't bothered to check. pretty sure you get most of it though
11:10llasramwingy: Actually, you don't, or at least shouldn't if the backing Emacs version is up-to-date. If there's a running Emacs version, you can do `emacsclient -t` to create a new Emacs terminal frame backed by the existing Emacs process
11:10ro_stah, but that's emacs on a remote host, not the local emacs
11:10ro_st(inc llasram)
11:10lazybot⇒ 1
11:10TimMcsh10151: with-open doesn't know anything about streams.
11:10ro_stthat's very cool!
11:10wingyllasram: i see
11:10duck1123I find this alias helpful. alias ed='emacsclient -c -n -a ""'
11:11duck1123starts a server if emacs isn't running, connects otherwise
11:11wingyi heard that emacs is not an editor. it's an operating system
11:11sh10151TimMc: fair enough, my criticism is more directed toward clojure.java.io/writer I suppose
11:11TimMcduck1123: I couldn't have that alias without thinking ED IS THE STANDARD TEXT EDITOR every time.
11:12sh10151TimMc: it allows OutputStream/Writer parameters and the docs say "should be used inside with-open," but it doesn't guard against closing that stream
11:12duck1123I have run into that, but that was what the guy I copied it from had.
11:13TimMcsh10151: Ah, you want a close-shield.
11:13kreig1sh10151: yah, because sometimes if it didn't how would it work with compound streams and shit, like say, zip compression streams 8)
11:13kreig1sh10151: aka, things that are not magically construted by the cojure.java.io funcs
11:13sh10151I'd think that writer would not close things that it didn't open
11:14kreig1with-open is not opening anything
11:14kreig1it's always being given a reader
11:14sh10151I understand that now
11:14llasramI have wondered why it isn't called with-close instead...
11:14TimMcheh
11:14kreig1sh10151: indeed
11:14sh10151Or rather, I understand that it's reader/writer that I am concerned about
11:14llasram`with-closing` maybe?
11:14kreig1cause that's all it does 8)
11:14sh10151because it wraps the streams and writers without guarding against closes on the wrapper
11:14nDuffHas anyone poked at using one.test outside a ClojureScript One environment?
11:15kreig1yah, it's named as a throwback to a lisp func, but then got lobotomized in the proper clojure style and never had the name fixed
11:15kreig1that's my guess 8)
11:16sh10151so given that clojure.java.io/writer won't change
11:16ro_stwingy: and lisp isn't a programming language, it's a building material :-)
11:16sh10151what's an idiomatic way to guard these streams in my code, given that right now I am just delegating all of the logic of parameter parsing to reader/writer
11:17kreig1you need to see if you are being given a stream
11:17kreig1if so, set a bool
11:17sh10151um no
11:18sh10151how about an if either returning the writer in with-open or the original stream
11:18sh10151but at this point I'm just doing some kind of with-open-writer
11:18ro_stsh10151: wrap in a (cond stream? (do (work) (close thing)) :else (work)
11:18kreig1(let [close-sheild (class Reader arg) input (clojure.java.io.reader arg) ] (do (try (my shit) (finally (when close-sheild (.close input))
11:18llasramsh10151: You could have a function which accepts a writer/stream, generates a writer as necessary, then wraps that writer in a `proxy` which implements Writer and forwards everything but `.close` ?
11:19sh10151OK so the sense I'm getting is that there isn't an idiomatic way
11:19kreig1llasram: really?
11:19sh10151:-D
11:19kreig1llsaram just so it works with a macro?
11:19kreig1idiomatic?
11:19llasramkreig1: So it solves the general problem of wanting to pass off a writer to be something and be certain that recipient won't close it
11:20TimMcThat's called a close-shield.
11:20sh10151well, the general problem I am trying to solve is that clojure.java.io/writer does almost everything I need except in the case of being passed an OutputStream or Writer
11:20llasramTimMc: Cool! Does it exist already somewhere?
11:21sh10151or rather, the combination of with-open and writer
11:21kreig1sh10151: have you read the with-open macro?
11:21sh10151yes
11:21TimMcllasram: org.apache.commons.io.output.CloseShieldOutputStream :-/
11:21kreig1sh10151: so why not just have your own try finally clause that knows if the input arg was supposed to be closed by you or not
11:22TimMcCan't be hard to implement.
11:22TimMcSounds like sh10151 never wants to close streams.
11:22sh10151because that is just going to be a specialization of the writer/with-open combination that doesn't use with-open in the case of a stream
11:22TimMcand wants to prevent callees from doing so as well.
11:23kreig1TimMc: not impression I got
11:23kreig1sh10151: and what is wrong with that when it caries out the rather specific contract you want to present to the user?
11:23llasramTimMc: Awesome! V useful to know
11:23kreig1if you give me a filename, or a URL, I will read from it and close it, if you give me a stream, I'll read, but not close it
11:23sh10151in the context where I am using writer, I don't want anyone to close streams that were passed to writer
11:23sh10151so TimMc is right
11:24kreig1ah, ok, so you don't want them closing it outside of your func either?
11:24sh10151kreig1: but clojure.java.io/writer doesn't follow that rule
11:24sh10151kreig1: which is my whole point :)
11:24kreig1what rule?
11:24kreig1clojure.java.io does shit about closing
11:24sh10151"if you give me a filename, or a URL, I will read from it and close
11:24sh10151 it, if you give me a stream, I'll read, but not close it"
11:24kreig1I don't understand how it cannot follow a rule about closing 8)
11:24sh10151yes it does
11:24sh10151it allows you to close the streams it creates from streams
11:25sh10151and close on those streams closes the underlying streams
11:25sh10151so it does do shit about closing
11:25kreig1sure it ALLOWS you to close it
11:25sh10151not only does it allow you to close the streams it returns
11:25sh10151but that closes whatever stream it was passed
11:25sh10151which is counter to the advice "use with-open" in its docstring
11:25kreig1tht's a function of java streams if I recall
11:26kreig1aka, that's how streams work in java
11:26kreig1I could be wrong on that tho, been two years since I did raw java
11:26llasramsh10151: To be fair, in the Java I/O library/ies, I think that's usually what you want. You'll create a stack of writers on top of a stack of streams and then want to forget it's anything but a singular entity
11:28kreig1if you don't want your func to close the stream, don't call .close on it
11:28sh10151All right. So really what we have here is a documentation bug?
11:28kreig1there is no bug
11:28sh10151the docs for writer/reader shouldn't even mention with-open
11:29kreig1you want with-open to work in some context where you are trying to provide a specific contract to those who pass in some generating output argument
11:29kreig1go polish a turd somewhere else 8)
11:29kreig1there are many in clojure 8)
11:29duck1123in most (all?) of the cases where they show with-open, they create the reader right there
11:29kreig1sorry, that's how I refer to my own fixations on things like that, no personal jie meant 8)
11:29sprocAre there any built-in functions for converting a Java array into a vector or list?
11:30sh10151duck1123: yes, and that doesn't work if you say, pass *out* as the argument to reader
11:30sh10151er writer
11:30sh10151:-P
11:30sh10151or rather, calling code passes you *out*
11:30kreig1sure it does
11:30kreig1it just doesn't do what you want it to 8)
11:30cmiles74sproc: You can pass a Java array to vec.
11:31kreig1if I'm writing a script and want to make sure things get flushed out, it would be doing the write thing 8)
11:31cmiles74& (vec (into-array ["hi" "bye"]))
11:31lazybot⇒ ["hi" "bye"]
11:31TimMccmiles74, sproc: Note that the resulting vec is mutable if someone has access to that array.
11:32cmiles74TimMc: That I did not knwo.
11:32duck1123nDuff: Midje in cljs? You can find the time. :)
11:32TimMc&(let [a (into-array (range 5)) v (vec a)] (aset a 0 17) (get v 0))
11:32lazybot⇒ 17
11:33TimMcIf you're given an array to turn into a vec, best to pour it into a new one.
11:33TimMc&(let [a (into-array (range 5)) v (into [] a)] (aset a 0 17) (get v 0))
11:33lazybot⇒ 0
11:33kreig1&(true)
11:33lazybotjava.lang.ClassCastException: java.lang.Boolean cannot be cast to clojure.lang.IFn
11:34sprocThanks cmiles74 and TimMc, that was exactly what I needed.
11:34kreig1well, neither could let!
11:34TimMc...but if you created that array yourself and do not allow anyone else access to it, vec is fine.
11:35TimMckreig1: IFn was the compiler's last attempt at making sense of the head position there.
11:35kreig1TimMc: I know 8)
11:36pandeirocan anyone tell me what i need to do to get clojure-jack-in to work again after upgrading to lein2?
11:36kreig1pandeiro: add this to your ~/.lein/profiles.clj
11:37kreig1{:user {:plugins [[lein-swank "1.4.4"]
11:37kreig1 [lein-cljsbuild "0.2.4"]
11:37kreig1 ]}}
11:37kreig1err, you can drop the lein-cljsbuild bit, sorry
11:37kreig1in lein2 such plugins are installed at the "user" level
11:37pandeirokreig1: no that's great i use it, too - but can i just put it there and avoid having to list it in projects?
11:37kreig1yup
11:37pandeiro(ie, will lein only grab it if there's a cljsbuild key in the project?)
11:38kreig1no clue
11:38kreig1you still have to define hooks and stuff I assume
11:38kreig1it might show up in the help listing etc...
11:38pandeiroyeah but i guess the costs are minimal once it's already in my local .m2
11:38kreig1yah, only about 500g of disk space, three JVMs, and a Net4.0 runtime
11:39pandeirofor cljsbuild? that's reasonable
11:42nestastubbshardest part of clojure so far is unlearning all my Common Lispism
11:42nestastubbsI went and wrote a CLIM-like presentation-type system
11:43nestastubbsand then realized it was so delicate and enterprisey it was not worth the trouble over a couple of multi methods
11:43Hodappgaaah enterprise
11:44pandeironestastubbs: my repl's back; thanks
11:44Hodappenterprise has too much become synonymous in my head with "when this shit fails, you have NO chance of comprehending why"
11:44TimMc$inc Hodapp
11:44lazybot⇒ 1
11:44Hodappbah?
11:45TimMcKarma points. :-)
11:49uvtcWhen using Compojure, how can I try out (in the repl) the routes individually?
11:49uvtcIs there any easy way to do that?
11:50nestastubbsuvtc: to invoke a page programmatically?
11:50nestastubbsor to give it a url and have ittell you which route would be fired?
11:51uvtcI've got `(cc/defroutes app* (cc/GET "..." ...) (cc/GET ...) etc.`. I want to programmatically --- and from the repl --- try those "handlers" out...
11:51ro_sti made this fn uvtc:
11:51uvtcNot the "top-level" handler ("app*"), but the individual ones within it.
11:51pandeirowhat's the best way to do str manip on keywords? just do (name ...) and manip then go back to (keyword ...)?
11:52nestastubbspandeiro: that's how I do it
11:52nestastubbscurious as to what your output is tho
11:52nestastubbsaka, what kind of munging you are doing
11:52nestastubbsat most I am upcasing, or adding a prefix/suffix (rarely)
11:52pandeironestastubbs: trying to modify hiccup vectors on the fly
11:52pandeiroadd classes etc
11:53ro_stuvtc: https://www.refheap.com/paste/3629
11:53TimMcYeah, usually string manipulation on keywords means you shouldn't be using keywords. :-)
11:53nestastubbspandeiro: ah, how about just adding/modding the attrbute map?
11:53ro_stused from the repl, within the ns that defines it. usually the one that defines app*
11:53nestastubbspandeiro: this is something I am interested in a general solution for 8)
11:54nestastubbspandeiro: but I can't recall if the class attribute in the map overrides all classes in the keyword form
11:54pandeiroTimMc: nestastubbs: hmm, hadn't thought about just trying to add a {:class "foo"} to the vector... (won't that override any existing classes?)
11:54pandeiroyah
11:54ro_stis there another way other than (name) … (keyword)?
11:54nestastubbspandeiro: it might append
11:54nestastubbsI don't have a repl handy to test that
11:54pandeirooverrides
11:55nestastubbsdamn
11:55nestastubbspandeiro: I actually thinkg that id and class attributes should merge there
11:55nestastubbsI beelive that's how such things work in say, HAML
11:55pandeiroyeah would be nice
11:55nestastubbswell, fork hiccup 8)
11:55pandeiroso i just need to destructure from the keyword
11:55pandeirothat should be an easy fn
11:55pandeiroi can probably steal some of hiccup's own internals
11:55uvtcro_st: Thanks. Looking at your example...
11:56nestastubbslet's cahnge hiccup to do that
11:56nestastubbscause that's what I want it to do too 8)
11:56pandeironestastubbs: yeah seems like a more common use case to me
11:56pandeirobut i'm sure some people are relying on the current behavior
11:56nestastubbsany other hiccup users have a opinion on this?
11:56ro_stuvtc: ymmv. written by a newbie. works for me, though. and yes, it does trigger the top level app fn.
11:57uvtcOk. Each of those lines in my defroutes evaluates to a function ... `(cc/GET "/" request "Welcome!")` gives me a function. I suppose Compojure calls that function with the request map.
11:57pandeirowould it be idiomatic for hiccup to maybe have a *merge-attrs* that could be set?
11:58ro_styeah
11:58nestastubbspandeiro: hmm
11:58ro_stin my case, my api methods are returning a hash with :body set
11:58ro_stso that my json-response middleware can generate json appropriately
11:59pandeironestastubbs: i dunno if libs do that the same way clojure.core does? is that common?
11:59wingyi dont think im the emacs guy
11:59wingythe arrow keys is like WTF
11:59ro_stwhat's the prob, wingy? you can do it
11:59uvtcro_st: I don't know what you mean by "api methods" in the context of a compojure webapp.
11:59ro_stuvtc: i'm using compojure to write a json rest api
11:59ro_stso, in my case, all my routes are api methods
11:59wingyi just dont get why that is helpful to navigate with weird arrow keys
11:59ro_stsorry for the confuzz
12:00uvtcro_st: Oh, I see. Thanks.
12:00uvtcro_st: The api of your web service. :)
12:00wingywhy p b f n
12:01ro_stoui
12:01uvtcwingy: next/previous, forward/back.
12:01uvtcn/p, f/b
12:01nestastubbspandeiro: hiccup/core.clj:76
12:01ro_stwingy, remember, emacs is *old*
12:01nestastubbsthat is the line that would need ot change
12:01wingyuvtc: ok that makes more sense now
12:01nestastubbsit's just merging the parse of the keyword with the attr map
12:02nestastubbspandeiro: and since the attrs come last, they override
12:03pandeironestastubbs: what hiccup u lookin at?
12:03pandeiroold school?
12:03nestastubbsouch, 0.3.7
12:03nestastubbssheeeit
12:03nestastubbsI suppose I should update, what is latest?
12:03pandeiroget off my lawn style
12:03pandeiro1.0.0-beta1?
12:03nestastubbsoh, any big changes?
12:03nestastubbswill it fuck me if I upgrade a week before deploying a 20k line app 8^)
12:04pandeironestastubbs: huge re-arrangement of ns
12:04pandeirohiccup.core is 17 lines long now
12:05jsabeaudryFirebug is angry when I check if myvar is defined using (when js/myvar ...), what other method can I use?
12:06nestastubbsyou types tht into firebug?
12:06nestastubbsfirebug cannot compile clojurescript
12:06nestastubbsyou want to start a clojurescript repl
12:07nestastubbsand then tell your browser to connect to i
12:07nestastubbspandeiro: going thru commit logs now
12:07jsabeaudrynestastubbs, nah it gets translated to cljs.core.truth_(myvar), which firebug complains about because myvar is undefined
12:08jsabeaudryperhaps a more appropriated question is how to check for undefined vars in cljs
12:08nestastubbsjsabeaudry: ok, sorry, didn't mean to be pedantic about that, it's just cljs can be confuzzing
12:09nestastubbsjsabeaudry: how about (.typeof js/myvar)
12:10wingyro_st: ok . still in emacs .. phew .. the movements kinda makese sense after all :)
12:10uvtccemerick: In the CP-or book, url-shortener example (p.537), a Ref was used for `mappings`. My understanding was that you use refs for times when there's more than one of them, and changes need to be coordinated. Why use a Ref there instead of an atom? Was it because you check it for the given key before altering it?
12:10nestastubbssee fi that gives you "undefined"
12:10ro_stwingy: C-a and C-e was my bugbear. so used to home/end keys to move to begin/end of line
12:11ro_stwingy: try C-M-space somewhere. keep pressing it. you'll see it selects forms, always keeping the selection balanced on brackets
12:13nestastubbsjsabeaudry: luck?
12:13jsabeaudrynestastubbs, not on himera, will try directly in code
12:13ro_stgclosure has goog.isDefAndNotNull(); as the catch-all way to ensure a variable is good or not. not sure if cljs wraps it internally
12:32technomancyhttp://axisofeval.blogspot.com.es/2012/07/when-i-see-that-new-language-makes.html
12:33winkawesome gifs :)
12:36winkdoesn't beat http://runningastartup.tumblr.com/ though
12:37technomancythere's more though: http://axisofeval.blogspot.com.es/search/label/thispltlife
12:42dnolentechnomancy: it's pretty hilarious
12:43technomancydnolen: he's definitely a troll, but there's something to be said for appreciating a skilled troll =)
12:44dnolentechnomancy: agreed. I certainly prefer his style over the LoperOS drivel.
12:44nDuffHrm.
12:44cmiles74`Ugh, LoperOS.
12:46nDuff...ahh, moved to the analyzer.
12:57SegFaultAX|work2What's the purpose of the grave mark in: (list* `defn (with-meta name (assoc (meta name) :private true)) decls)
12:58SegFaultAX|work2How is it modifying defn? Or is it an entirely different function?
13:02TimMcSegFaultAX|work2: It's the reader shorthand for syntax-quote.
13:02TimMc&(+ 1 2)
13:02lazybot⇒ 3
13:02TimMc&`(+ 1 2)
13:02lazybot⇒ (clojure.core/+ 1 2)
13:03SegFaultAX|work2TimMc: Is there a good place to read about all the reader shorthands?
13:03TimMcIn this case, you are presumably looking at the internals of the defn- macro?
13:03TimMchttp://clojure.org/reader
13:03SegFaultAX|work2TimMc: Yes I am.
13:04SegFaultAX|work2TimMc: Actually maybe I should defer this conversation; I haven't yet got to the macro chapter in Clojure Programming.
13:05augustlare there any utils to list all namespaces in a directory?
13:05SegFaultAX|work2One of my biggest issues with this book is that the authors tend to introduce dozens of functions without ever saying what they do.
13:06SegFaultAX|work2So I constantly have to be going back and forth between the (sub-par) documentation and the text.
13:06TimMcSegFaultAX|work2: You can use ` outside of macros, too -- it's just not very common.
13:06technomancyaugustl: bultitude does that
13:07TimMcYes, clojure.core's docs are not the best. :-/
13:07augustltechnomancy: looking it up, thanks
13:07TimMcClojureDocs is pretty good.
13:07hxiaoI use the cheat sheet all the time
13:07augustlthe actual use case is for loading all my "model" namespaces so I can ensure mongodb indexes
13:07SegFaultAX|work2TimMc: I'll still read this page on Reader syntax. Just meant (future macro-discussion)
13:07hxiaohttp://clojure.org/cheatsheet
13:08TimMc&(let [middle [4 5 6]] `[10 11 ~@middle 12 13])
13:08lazybot⇒ [10 11 4 5 6 12 13]
13:08SegFaultAX|work2hxiao: Wow, that's super handy. Thank you!
13:08wingyshould we manually have to worry about when to use java.math.BigDecimal instead of java.lang.Double?
13:09wingy,(= (java.math.BigDecimal. 10.67) 10.6699999999999999289457264239899814128875732421875M)
13:09clojurebottrue
13:09technomancyaugustl: if you're thinking of adding side-effects at the top-level you should reconsider
13:10wingy,(= (-> 10.67 .toString (java.math.BigDecimal.)) 10.67M)
13:10clojurebottrue
13:11wingyshould i have to use java.math.BigDecimal manually like this when dealing with math precision or should i just use the numbers directly?
13:12SegFaultAX|work2wingy: That probably depends heavily on what you're doing.
13:12wingySegFaultAX|work2: i will handle financial numbers
13:13wingyso it has to be specific results
13:13wingyin Java they tell you to use java.math.BigDecimal when dealing with accuracy
13:13wingyhow is it in Clj>
13:13wingyis it taking care of that in the background for me using BigDecimal?
13:14SegFaultAX|work2wingy: I don't think being explicit in this case could hurt.
13:14SegFaultAX|work2Eg using BigDecimal literals.
13:15SegFaultAX|work2But I'm not a Clojure expert so my opinion is worth very little.
13:15SegFaultAX|work2(If anything)
13:16wingyi forgot there is M
13:16wingy(not= 10.67M 10.6699999999999999289457264239899814128875732421875M)
13:16wingy,(not= 10.67M 10.6699999999999999289457264239899814128875732421875M)
13:16clojurebottrue
13:16wingyseems to work better
13:22cheaterwhat does M do?
13:23SegFaultAX|work2cheater: It's BigDecimal literal syntax.
13:23cheaterthx
13:26augustltechnomancy: the models just define the data structures, then a separate task will read the data and create the indexes
13:27technomancygotcha; carry on
13:27augustl:D
13:28arrdemis there a good way to do Clojure generation in Clojure? I'm trying to write a program which will generate the FNParse gramar for a BNF input, and I can't find a clear way to manipualte the expressions without evaling them to code
13:30SegFaultAX|work2arrdem: Macros are a form of code generation in Lisps, generally speaking.
13:32arrdemSegFaultAX|work2: thanks for the hint... all I needed was some backquotes and an unquote
13:35SegFaultAX|work2TimMc: So, what exactly is the purpose of the syntax-quote in the case of defn?
13:35SegFaultAX|work2TimMc: Other than just qualifying all of the symbols.
13:37ibdknoxSegFaultAX|work2: the ability to unquote things into the structure you're building
13:38SegFaultAX|work2ibdknox: Hmm, could you explain that a bit futher?
13:38ibdknoxyou can do it with standard quote, but it requires a lot more manual lifting - it's the difference between concating strings and using format
13:38technomancySegFaultAX|work2: in the case of the example you gave, it's only for qualifying
13:38SegFaultAX|work2Are lists the only type that can be used in unquote-splicing?
13:41ibdknoxSegFaultAX|work2: vectors should work too I believe
13:41emezeske,`(1 2 ~@[3 4] 5)
13:41clojurebot(1 2 3 4 5)
13:41emezeskeSegFaultAX|work2: ibdknox is right ^
13:41SegFaultAX|work2Neat!
13:41emezeske,`(1 2 ~@#{3 4} 5)
13:41clojurebot(1 2 3 4 5)
13:41emezeskeApprently sets too
13:41ibdknox,`(1 2 ~@{:a 3})
13:41clojurebot(1 2 [:a 3])
13:42ibdknoxanything seqable
13:42emezeskeWell I'll be
13:42SegFaultAX|work2That's useful.
13:48TimMc&['a `a]
13:48lazybot⇒ [a clojure.core/a]
13:49TimMc&(apply str `[\a ~@"bcd" \e])
13:49lazybot⇒ "abcde"
13:50wingyclj has made me hate syntax .. looking at java makes me think it's messy
13:52amalloyunquote-splicing just uses apply/concat
13:52amalloy&'`(x ~@y)
13:52lazybot⇒ (clojure.core/seq (clojure.core/concat (clojure.core/list (quote clojure.core/x)) y))
13:53TimMc&'`[~@a]
13:53lazybot⇒ (clojure.core/apply clojure.core/vector (clojure.core/seq (clojure.core/concat a)))
13:53emezeskeamalloy: Interesting, thanks!
14:00gtrakthere seems to be some difference in semantics with reduce in 1.4, anyone seen this before? java.lang.AbstractMethodError: null https://gist.github.com/3124046
14:03jsabeaudryFinally found a satisfying solution to my undefined problem for me and firebug, I use (not= js/undefined (.-myvar window)) (just for the channel records)
14:03jsabeaudryoops i meant js/window
14:04amalloy&(reduce + 0 nil)
14:04lazybot⇒ 0
14:04amalloygtrak: no, sounds like you have some mismatched AOT versions or something
14:04gtrakamalloy: ah I thought I was careful about that, I'll look into it some more
14:05Zeldan_Could anyone help me out with problem? Described it on SO: http://stackoverflow.com/questions/11508881/clojure-repl-unable-to-resolve-symbol-for-all-functions
14:06d0c0nnorDoes anybody know the easiest way to transform just the values of a map ? Say, to make the city names uppercase here: {"Kansas" "Lawrence" "Oregon" "Salem" "Ohio" "Columbus"} Is there a function for that ?
14:08d0c0nnorWhen I say 'transform' I mean return a new map with the transform applied ..
14:08llasramd0c0nnor: `update-in` simulates "updating" the values
14:09nDuffd0c0nnor: I tend to use zip-map and just pass the keys through unmodified.
14:09llasramd0c0nnor: Well, individual values
14:09llasramnDuff's idea sounds better for hitting everything
14:09d0c0nnorllasram: I'm not sure that that will work because I don't know the keys
14:10d0c0nnorWill try the zip-map, cheers!
14:10amalloy&(into {} (for [[k v] {"Kansas" "Lawrence" "Oregon" "Salem" "Ohio" "Columbus"}] [k (.toUppercase v)]))
14:10lazybotjava.lang.IllegalArgumentException: No matching field found: toUppercase for class java.lang.String
14:10amalloy&(into {} (for [[k v] {"Kansas" "Lawrence" "Oregon" "Salem" "Ohio" "Columbus"}] [k (.toUpperCase v)]))
14:10lazybot⇒ {"Oregon" "SALEM", "Kansas" "LAWRENCE", "Ohio" "COLUMBUS"}
14:11amalloyalthough as always, let me recommend that if you're using a map for something *other* than fast lookup by key, you treat it as a seq of tuples until you finally do need fast lookup, and then make it back into a map
14:12d0c0nnoramalloy: Makes sense, thanks.
14:17jsabeaudryamalloy, if I understand correctly, the transformations on a tuple seq are fast so better do all the manipulation on that and use the map solely for lookups?
14:18amalloywell, more accurately, it's expensive to build a map, and if all you're going to do is tear it back down into tuples...
14:18jsabeaudryok! thanks
14:34mononofuI'm currently looking for useful libraries, but everywhere I go I see "___ is not under active development"
14:35kreig1welcome to a new language
14:35mononofueg penumbra as an OpenGL wrapper
14:35mononofuyes, but I'd expect libraries which are updated a lot
14:35mononofunot libraries which haven't been touched in over a year
14:36gtrakwhine whine whine :-)
14:36dnolen_mononofu: ztellman has a paying gig at Runa, so I think most of his Clojure energies go into Aleph. Penumbra was something he did in his free time.
14:36amalloymononofu: github.com/flatland/useful
14:36technomancyalso sometimes projects are done
14:36dnolen_mononofu: I think he's mentioned several times that he'd be happy to pass the torch on Penumbra.
14:37dnolen_mononofu: but no takers yet.
14:37kreig1yah, but you also have lot sof experiements
14:37kreig1see Clojure LWGL as well
14:38kreig1hehe, useful 8)
14:39kreig1dnolen_: my CA was mailed, if that patch for cljs use didn't already make it in...
14:39cbrozefskythere we go
14:40dnolen_cbrozefsky: oh, howdy :)
14:40dnolen_cbrozefsky: I think you'll be happy to hear that reflection is just around the corner for CLJS. Some HackerSchool folks are putting together a patch.
14:40cbrozefskyoh good
14:41cbrozefskyI do fine in messy opaque places, myself
14:41cbrozefskywhich is why I prolly write messy opaque code, ha
14:42madsydnolen_: Hooray
14:43dnolen_madsy: yes, finally docstring, macroexpand, etc should all be just around the corner.
14:43cbrozefskyhow you getting macroexpand?
14:43madsyHopefully someone will pick up the torch and make a better repl
14:43dnolen_cbrozefsky: there'll be a new ns cljs.reflect or some such, JS can query the REPL server
14:43cbrozefskymadsy: agreed, what do you think a better repl shoud look like?
14:43cbrozefskyah
14:44dnolen_madsy: the improvements are REPL implementation agnostic.
14:44cbrozefskymost of my bitching about the repl is namespace related
14:44cbrozefsky(in-ns ..) doesn't pick up the ns-aliases
14:45amalloydnolen_: what is reflection in javascript? just iterating over the object's properties?
14:45cbrozefskyor it doesn't in the revision I am using
14:45hiredmandnolen_: I assume cljs.reflect will be extensible? like could you replace repl querying with a static data set?
14:45cbrozefskydnolen_: metadata too?
14:45dnolen_amalloy: no querying the compilation environment
14:45dnolen_cbrozefsky: anything the compiler has that the evaluation environment does not.
14:45madsycbrozefsky: The usual stuff. Breakpoints, stackframes, autocompletion. But I have only limited experience with SLIME so..
14:46cbrozefskyhmm, so no squirting this stuff into the JS objects represeting the namespace then?
14:46cbrozefskyor maybe a canonical runtime dictionary of metadata?
14:46madsyI'm sure more knowledgable people than me have a better idea
14:46dnolen_madsy: breakpoints & stackframes etc are not really a part of this.
14:46cbrozefskyI was thinking more like reflection that works at runtime without the repl link (macroexpension would be out of course)
14:47dnolen_cbrozefsky: yes non-goal at this point.
14:47madsydnolen_: I answered cbrozefsky on the side topic
14:47madsyBut yes
14:47cbrozefskymadsys: ok, I see now
14:48cbrozefskydnolen_: ok, so this is mostly about reflection into the compiler runtime while hooked up to the repl
14:48dnolen_cbrozefsky: yep.
14:49cbrozefskydnolen_: that's welcome improvement. Was stuffing reflection data into the runtime world withdrawn from consideration for a reason other than resource/time/complexity?
14:49madsydnolen_: I didn't mean to imply that reflection has anything to do with the current REPL lacking features. It's just the two biggest disadvantages with CLJS right now
14:49cbrozefskydnolen_: pointing me at this converstaion iN JIRA or whatever is sufficient answer 8)
14:50dnolen_cbrozefsky: resource is a big one. non-reified namespaces & vars allows us to leverage aggressive GClosure compression.
14:51cbrozefskyok, and non-reified namespace is why for instance when IN (in-ns someplace in the REPL, I don't have a way to identifying the aliases active when it was compiled
14:52dnolen_cbrozefsky: yes ... tho that seems like it wouldn't be hard to handle.
14:53cbrozefskydnolen_: I don't know much about gclosure compression, so can't comment on that, but it seems that a significant part of reflection could be done by throwing the metadata into a array that is just not made if being aggresive in compilation
14:54cbrozefskydnolen_: I thinka hybrid is gonna be the end result
14:54dnolen_cbrozefsky: dump cljs.analyzer/namespaces and let me know how big it is ;)
14:55dnolen_cbrozefsky: when running under the JVM this stuff doesn't matter, targeting JS becomes an issue.
14:55cbrozefskydnolen_: checking...
14:57cbrozefskydnolen_: I think I misunderstood you statementabout dumping cljs.analyzer/namespace
14:58cbrozefskydnolen_: you mean froma running repl
14:58dnolen_cbrozefsky: cljs.analyzer/namespaces holds all the metadata plus information that's missing without reified ns'es & vars.
14:58cbrozefskyyah, got that part now
14:59dnolen_cbrozefsky: repl or no repl. cljs.analyzer/namespaces is not small. 6000 lines of cljs.core + whatever code you ship.
14:59cbrozefskysorry, I was looking for namespaces function, as in, I thought you were trying to show how complicated namespace compilation was 8)
14:59dnolen_cbrozefsky: plus a lot of info won't matter since GClosure dead code eliminates.
14:59cbrozefskyyup
14:59cbrozefskyyou enter into the world of PDB files basically
15:00cbrozefskyaka, your reflection/debugging data is seperate and loaded on demand
15:00cbrozefskyhaha
15:00dnolen_cbrozefsky: even a namespaces outside of dev function makes no sense - all those names will be rewritten.
15:00cbrozefskyyup
15:00cbrozefskyI usually run with whitespace optimization only BTW
15:00cbrozefskyso I often debug by reading the JS
15:01dnolen_cbrozefsky: yes I think most folks do.
15:01cbrozefskydnolen_: see the point now
15:02cbrozefskydnolen_: in this deployment environment, performance is prolly a higher priority
15:02dnolen_cbrozefsky: yep. it's easy for the generated JS to be 600-700k.
15:02dnolen_space savings from GClosure can be 7X
15:03cbrozefskywow
15:03cbrozefskymine is 1.2m
15:03cbrozefskyfor libre
15:03cbrozefskywith whitespace only
15:04dnolen_heh yep. if you want macros and compiled JS perf w/o producing a bloated monster - CLJS strategy is the best I've seen for Lisp->JS.
15:05sauathere's one thing I'm not getting. When googling i see a lot of references to libraries located in clojure.contrib, but that's been discontinued right?
15:05TimMcsaua: Correct, monolithic contrib is no more.
15:05TimMc~contrib
15:05clojurebotMonolithic clojure.contrib has been split up in favor of smaller, actually-maintained libs. Transition notes here: http://dev.clojure.org/display/design/Where+Did+Clojure.Contrib+Go
15:05cbrozefsky1.2m with whistepsace optimization, 215k with :advanced
15:06cbrozefskyis there a performance win with those optimizations as well?
15:06dnolen_cbrozefsky: + gzip you're down to what 60k? 70k?
15:06dnolen_cbrozefsky: yes, we do whole program optimizations that don't kick in outside of :static-fns true or :optimizations :advanced.
15:07dnolen_cbrozefsky: mostly around fn invocations and protocol representation - many more improvements still to come.
15:07cbrozefsky47k
15:07dnolen_cbrozefsky: :D
15:08cbrozefskysmaller than a gzipped processing.js 8)
15:08dnolen_cbrozefsky: tots
15:09augustlhow do you get a "def" from a namespace that might or might not be present?
15:09sauaty TimMc
15:10cbrozefskyaugustl: in cljs or clj?
15:10augustlcbrozefsky: clj
15:11cbrozefskytry and resolve th var
15:11cbrozefskyif cannot, then require the namespace?
15:12cbrozefskyweavejester: me and another hacker were talking about hiccup earlier today
15:12augustltrying `(get (ns-publics ns) 'my-thing)`, it yields `#'my-ns/my-thing`
15:12augustlnot sure how to get the actual value from that :)
15:12cbrozefskyweavejester: we were thinking that the classes in the attr-map should append to the ones defined in the element keyword
15:13cbrozefskyweavejester: thoughts?
15:13amalloy,@#'*clojure-version*
15:13clojurebot{:interim true, :major 1, :minor 4, :incremental 0, :qualifier "master"}
15:13weavejestercbrozefsky: They should
15:13weavejestercbrozefsky: Send me a patch, I'll add it in.
15:13augustlns-resolve yields the same thing
15:13cbrozefskysweet, I'll have to update to the latest revision first tho
15:14cbrozefskyweavejester: also, on that whole ring-csrf token thing, I discovered that I really needed it working at the noir level
15:14augustlit's `type` is "Var", odd
15:14cbrozefskyweavejester: so I ended up redoing it there, sorry to drop that without a note
15:14augustlor clojure.lang.Var to be specific
15:14weavejestercbrozefsky: Working at the Noir level? What do you mean?
15:15cbrozefskyI wanted it to use noir sessions
15:15weavejestercbrozefsky: I thought Noir sessions were built on top of Ring sessions.
15:16cbrozefskyyes, they are, but there was something else that came up, and I need a minute to recall
15:17augustlah, I had to dereference it
15:19cbrozefskyweavejester: sorry, I can't recall now. I also added a bypass hook for my case, but that's not the "reason" I was thinking of. Just ignore I said anything 8)
15:19amalloyaugustl: i did try to show you that. not explicit enough, i guess
15:20augustlamalloy: oh I didn't notice, sorry
15:20augustland thanks :)
15:22TimMc&(let [r (atom nil)] (reset! r r))
15:22lazybotjava.lang.StackOverflowError
15:22TimMcThis is not what I expected.
15:24ToxicFrogTimMc: that's pretty cool
15:24TimMc&(let [a (atom 1) b (atom 2)] (reset! a b) @@a)
15:24lazybot⇒ 2
15:24TimMc&(let [a (atom 1) b (atom 2)] (reset! a b) (reset! b a))
15:24lazybotjava.lang.StackOverflowError
15:25joly&(let [a (atom 1) b (atom 2)] (reset! a b) (reset! b a) nil)
15:25lazybot⇒ nil
15:26faust45hi guys
15:27faust45if i have type storing in var, how i can make instance ?
15:27TimMcjoly: Arg, it's the printing! Got it.
15:27faust45any suggestins?
15:28amalloyshort answer, faust45: you can't
15:28faust45(var-storing-type. "data")
15:28amalloylong answer: you can't in any way that is fast or reliable
15:28faust45like this
15:28faust45amalloy: so i need macros ?
15:30TimMcfaust45: No one can tell you that without knowing more about your specific problem.
15:31gtrakamalloy: re 1.4 AOT, yep you were right
15:31faust45TimMc: i have https://friendpaste.com/53MKnWboUIKj7JwCqIQCCp
15:31faust45TimMc: need to build chess figures
15:31faust45in simple way
15:32cmcbrideis there any core function for parsing boolean-like values?
15:32cmcbrideI'm writing a noir app and I want to parse GET params
15:33cmcbrideso I'd like "0" to return false
15:34TimMcfaust45: And Queen is some class you don't control?
15:34TimMcAnyway, what's wrong with (Queen. 'd1) ?
15:38faust45TimMc: Queen is my typedef, (Queen. 'd1) not working for me i want be able to build few same figures in diff positions
15:38faust45like [Elephant 'c1 'f1]
15:39amalloyfaust45: i think everyone in this room would recommend against defining new classes for the different pieces
15:40amalloyjust use a keyword or symbol to represent the kind of piece (eg :queen), and define functions that contain the polymorphism you want (eg, a multimethod like (get-legal-moves piece-type current-location board))
15:49faust45thanks for suggestions guys
15:52kovasbdnolen_: what is the new cljs repl goodness?
15:54augustlare there any html form builder libraries out there? Something that takes a data representing the HTML, the values and validation errors, and spits out a string of HTML or hiccup data.
15:54dnolen_kovasb: having access to analyzer info / compiler at the repl.
15:54augustl"takes a data" :)
15:54kovasbnice. that would be useful
15:55dnolen_kovasb: docs strings, namespace introspection, var inspection, macroexpand etc.
15:56kovasbdnolen_: cool. would also be useful to have that info when the compiler complains
15:56dnolen_kovasb: have you checked out the CLJS reactive thread yet?
15:56dnolen_kovasb: can you be more specific?
15:56kovasbdnolen_: yes but i was not approved for dev mailing list memberhsip
15:56kovasbdnolen_: is it for CA'ed people only?
15:56kovasbdnolen_: yeah, like my mysterious "this is not a protocol" error
15:57kovasbdnolen_: would be nice to know what exactly the analyzer was thinking
15:57kovasbdnolen_: i don't have a printer so I haven't mailed the CA
15:57dnolen_kovasb: :P
15:59dnolen_kovasb: can you make a ticket + minimal repo case in JIRA - also you are using CLJS head right?
16:00wingytime for cljs!
16:01kovasbdnolen_: not using head, since I don't know how to do it in conjunction with cljsbuild
16:02emezeskekovasb: https://github.com/emezeske/lein-cljsbuild/wiki/Using-a-Git-Checkout-of-the-ClojureScript-Compiler
16:02kovasbdnolen_: i mean, i know i can built it manually but haven't had the time
16:02kovasbnice
16:03kovasbdnolen_: its pretty hard to use git bisect since the namespaces changed with the analyzer breakout
16:03kovasbbut ill try head and see if it works now
16:03dnolen_kovasb: yeah, can't help much unless you were against head.
16:03dnolen_s/were/work
16:04kovasbdnolen_: is there any chance my tagged literals thing will get worked on?
16:04kovasbdnolen_: or should i just plan on doing it myself
16:04wingycan't the PDF be made online in http://himera.herokuapp.com/index.html
16:04wingyso you don't have to download it
16:04dnolen_kovasb: if you work on it :) or bug fogus, I haven't looked at the reader literal stuff closely.
16:05kovasbdnolen_: alright ill try bugging him on twitter :)
16:06dnolen_kovasb: or bring it up on regular ML and CC him.
16:06kovasbok
16:07kovasbi see stuart sierra is gonna come to the next meetup
16:07kovasbhe's also involved with this on this clj side
16:07dnolen_kovasb: right
16:08kovasbletting undefined tags pass through without meltdown is pretty important
16:09dnolen_kovasb: yes, you've brought it up before - always worth rebumping and mentioning Session - folks know about that.
16:10kovasbdnolen_: yeah. last week or two i've been more focused on drinking beer etc but time to ramp up again
16:10dnolen_kovasb: sounds like fun :)
16:10kovasbmid-air refueling :)
16:11technomancykovasb: would it make sense to connect alternative clients to a session server? seems like the reified history would be useful in other contexts
16:11kovasbtechnomancy: by clients, you mean the evaluation services?
16:12technomancymore like what if you wanted to use something other than webkit to view a session session
16:12technomancyerr--something other than a browser
16:12kovasbtechnomancy: i see. Yes, absolutely
16:12kovasbtechnomancy: the idea is, if its just this declarative data structure, you can build other tools on it as well
16:13kovasbtechnomancy: like slide show view, or whatever
16:13technomancyis that stuff factored out from the browser-centric UI?
16:13kovasbtechnomancy: also the graphics stuff should be portable to swing and other hosts
16:13kovasbtechnomancy: not yet, but that is the intention. the blocker is that the user-defined tagged literal support is not there yet
16:13technomancycool
16:14kovasbtechnomancy: so its all hacked into one project at the moment
16:14nDuffHrm.
16:14technomancyI wonder if it would make sense as an nrepl middleware
16:14kovasbtechnomancy: that would be cool. hiredman tried to do that but hit some issue
16:15kovasb"I think the issue is the nrepl requests are not stateless, and so the session/cookie info is being lost across requests. There doesn't seem to be a quick fix for that"
16:15kovasbnot sure what that means. but nrepl support would be great
16:15technomancyoh, as a middleware even
16:16hiredmankovasb: oh, it works now, except for the last bit in the cascalog example, which I haven't looked in to, but I think it comes down to how cascalog tries to map classes to vars
16:16kovasbtechnomancy: what would a middleware do?
16:17hiredmanmiddleware is a different beast entirely from evaling via nrepl
16:17technomancykovasb: just makes it easier to tie into an existing stack IIUC
16:17kovasbtechnomancy: like, send the output to get rendered in session or something?
16:18SegFaultAX|work2I don't suppose there is an automatic administration panel library like ActiveAdmin, RailsAdmin, or Django Admin, is there?
16:19kovasbhiredman: i definitely want cascalog to work, so will look into it
16:19technomancyI was thinking something like content-negotiation where if a client indicates he's compliant with session-style reified history then he gets it, otherwise it falls back to regular nrepl
16:19hiredmankovasb: it is a sweet demo
16:19kovasbhiredman: thanks :)
16:19gtrakSegFaultAX|work2: most of the web frameworks are tiny
16:19kovasbtechnomancy: i see. interesting
16:21gtrakSegFaultAX|work2: maybe try https://github.com/macourtney/Conjure/ ?
16:27wingywhen do you think that cljs will be out of its alpha status and have most of the clj features in place?
16:27kovasbwingy: what features are you thinking of?
16:28wingyall that are still missing that could be implemented
16:28wingyhttps://github.com/clojure/clojurescript/wiki/Differences-from-Clojure
16:30kovasbwingy: the vast majority of that stuff is "intentional differences" and thus unlikely to change anytime soon
16:30dnolen_wingy: the remaining ones will happen as people submit patches.
16:35wingywhat does this mean: Macros are written in Clojure
16:35wingyi write them in Clojure and they are converted into cljs?
16:36wingyor js i mean
16:36TimMcwingy: They are written in cljs and convert cljs to other cljs.
16:36TimMcarg
16:36TimMc*written in clj
16:36wingyi write them in clj and its converted into cljs?
16:36kovasbwingy: macros execute in the JVM, but the code they transform is cljs
16:37wingyi c
16:37RaynesIt's WEEEEEEEEEEIRD
16:37kovasbwingy: macros only need to execute once to achieve their code transformation purpose, so don't need to run in js (unless you have eval in cljs which we dont)
16:37wingyyeah i get it
16:38wingyi write in clj .. the macro should convert cljs to cljs
16:38wingy:)
16:38kovasbit is a little weird
16:38kovasbright
16:38wingycool . that means i can use original clj
16:38dnolen_wingy: pretty much.
16:38kovasbyou just need to remember that the output needs to be valid cljs (with the correct namespaces, not references java classes etc)
16:38SegFaultAX|work2wingy: Presumably as long as the expanded code is valid cljs.
16:39wingyi actually like original clj better since its more powerful in server side .. are there strong reasons to use cljs on node.js on server side?
16:39dnolen_wingy: on trick I used in core.match is to simply call the macros with a dynamic var *clojurescript*
16:39kovasbwingy: not yet
16:39SegFaultAX|work2wingy: There is no reason to use node.js, no.
16:39wingy:)
16:39wingysince you lose concurrency and other good stuff
16:40brehautbut you lose startup latency right?
16:40wingyyeah
16:40technomancybrehaut: yeah, but CLI apps are just a different kind of client
16:40wingybut i have realized i dont wanna run a script each time from the cli
16:40SegFaultAX|work2wingy: Since you lose the ability to write your server code in a sane language.
16:40wingyi wanna run a repl and run everything inside it
16:41brehauttechnomancy: perhaps its too early here, but i dont understand
16:41kovasbwingy: yes, you can still execute cljs code at the repl
16:41wingyeg. instead of "lein test" i wanna do "(run-tests 'myapp.core-test)" from the repl instead
16:41HodappSegFaultAX|work2: eh, I've never used JavaScript much.
16:41wingybrehaut: so the latency doesn't matter in clj land
16:41HodappSegFaultAX|work2: why do folks like writing server-side JS?
16:41technomancybrehaut: oh, I thought he was asking about client-side vs server-side
16:41SegFaultAX|work2Hodapp: Mental illness, probably.
16:41kovasbwingy: there is the browser-connected repl, and the rhino one
16:42HodappSegFaultAX|work2: this is true.
16:42brehauttechnomancy: he may well be
16:43kovasbthough i don't understand if its possible to define and use a macro at the cljs command line
16:48wingyi dont quite get bindings .. so i define a Var with "def" and then I can rebind it to another value that is thread-local .. why would i wanna do that and not just use another local?
16:48gtrakwingy: dynamic scoping
16:49duck1123As an example, bind a var at the start of a web request, it''ll be bound for only that request's thread
16:49alandipertwingy: you might also have code you didn't write inside your binding, and you want it to "see" your new value
16:50duck1123makes sense
16:50wingyalandipert: yeah that one i get
16:50gtrakconsider as an example.. (maybe bad design but whatever), you need to alter the behavior of a function by a switch, but you don't want to change its signature, add a var with the default behavior, bind it to another value to change it.
16:50duck1123mt
16:50gtrakwingy: real world example ^
16:51wingyperhaps i dont understand how threads are working explicitly
16:52kovasba pretty typical example is binding the database resource
16:52wingyif i have a source code and run it it will be run by a main thread
16:52wingy(def ^:dynamic a 1) (binding [a 2] a) vs (def a 1) (let [a 2] a)
16:52gtrakhaving them be thread-local is for safety in a multithreaded environment... you don't want to change behavior for other people's requests when you bind a var, do you?
16:53kovasbwingy: the binding only happens within the (binding ..) clause, and when the execution emerges, its back to its original value
16:53wingygtrak: so in the second example if that happened in one thread all other threads will see the value of a as 2?
16:54kovasbin the let case, a is for all intents and purposes a unique name
16:54kovasbrather than overriding an existing one
16:54gtrakwingy: no... other functions can't see what's in your let unless you pass the value along
16:54gtrakdynamic vs lexical scoping
16:55gtrakin your binding example, other threads will see whatever the value was before you bound to it
16:55gtrakit's a stack
16:55kovasbits not just other threads
16:56kovasbin this case
16:57kovasb(def a 1) (def b a) (let [a 2] b) --> 1
16:57gtrak(def ^:dynamic *a*) (binding [a 1] (binding [a 2] (binding [a 3] (println a)) (println a)) (println a)) ; prints 3 2 1
16:57amalloywingy: forget threads entirely; the thread-locality of vars is just a safety feature, not the important point
16:58_zachDoes clojure support native string interpolation? I'm seeing a lot of "~{}"-like things in the clojurescript source, but there's likely some cleverness I'm missing
16:58duck1123didn't a library recently add that officially?
16:58amalloy(def a 1) (defn foo [] a) [(foo) (let [a 2] (foo)) (binding [a 2] (foo))] returns [1 1 2]
16:58dnolen__zach: js* is an implementation hack which should not be relied on.
16:58duck1123incubator?
16:59SegFaultAX|work2wingy: This concept is called shadowing. The value in the local binding is shadowing the binding in the level above.
16:59SegFaultAX|work2kovasb: Overriding means something slightly different.
16:59alandipertduck1123: : yes i think cemerick's string interp. stuff is in core.incubator
17:00kovasbduck1123: theres a variety of string templating projects on github
17:01cemerickduck1123: FWIW, https://github.com/clojure/core.incubator/
17:02cemerickThere's really no such thing as "native string interpolation", though. Just fast compile-time templating, or slow runtime templating. :-P
17:03_zachcemerick: I kinda just meant built-in when I said native :). I was just reading some cljs source incorrectly.
17:03brehautcemerick: you missed out very slow runtime templating
17:03wingyhttp://emacswiki.org/emacs/DynamicBindingVsLexicalBinding lets see if i get any smarter
17:04cemerick_zach: yeah, no worries, I was just being snarkily pedantic. :-)
17:05_zachcemerick: that's the best kind of snarky, and the best kind of pedantic :)
17:05kovasbwingy: lexical just means the code that literally exists inside the let statement. if the symbol you are let'ing is not literally present in that block of code, it isn't effected
17:06kovasblexical, e.g. like find/replace in the text editor
17:07gtrakkovasb: huh?
17:07gerunddevIs there a form of map equality that ignores order?
17:07gtrakfind/replace sounds like alter-var-root to me
17:07gerunddevBasically permo for maps.
17:08amalloygerunddev: yes, every form of map equality
17:08kovasbhttp://en.wikipedia.org/wiki/Lexicon
17:08gtrak,(= {:a 1 :b 2 :c 3} {:b 2 :a 1 :c 3})
17:08clojurebottrue
17:08kovasblexicon is the words and phrases
17:08gtrak,(.equals {:a 1 :b 2 :c 3} {:b 2 :a 1 :c 3})
17:08clojurebottrue
17:09gtrak,(.identical {:a 1 :b 2 :c 3} {:b 2 :a 1 :c 3})
17:09clojurebot#<IllegalArgumentException java.lang.IllegalArgumentException: No matching method found: identical for class clojure.lang.PersistentArrayMap>
17:09Raynes&(identical? {:a 1 :b 2 :c 3} {:b 2 :a 1 :c 3})
17:09lazybot⇒ false
17:09gerunddevOk, that makes sense.
17:09gtrakquickdraw Raynes: :-)
17:09kovasbnot having to do with meaning, e.g. value
17:09gerunddevSo then I should blame this on clojure.test:
17:09gerunddevactual: (not (= {:include_docs false, :limit :21} {:limit 21, :include_docs false}))
17:09gerunddev?
17:09Raynesgerunddev: :21 != 21
17:10RaynesNotice that one of those is a keyword.
17:10wingydamn my finger nails are too long .. it hurts when i type
17:10technomancygerunddev: lein-difftest will help you spot those issues
17:10Raynes&:21
17:10lazybot⇒ :21
17:11gtrak,(= {:include_docs false, :limit (int (name :21))} {:limit 21, :include_docs false})
17:11clojurebot#<ClassCastException java.lang.ClassCastException: java.lang.String cannot be cast to java.lang.Character>
17:11kovasbdynamic scoping is perhaps an unfortunate phrase, perhaps more accurately "runtime" scoping
17:11technomancy"deep" binding helped me understand it
17:11Raynesgerunddev: It's okay. I've done worse.
17:11gtrak,(= {:include_docs false, :limit (Integer/valueOf (name :21))} {:limit 21, :include_docs false})
17:11clojurebottrue
17:12Raynesgtrak: Think we get the point. ;P
17:13wingyi start to get the diff
17:13logancampbellsay i am modeling a file system in datomic. i have folders and they may have many children. (:folder/child has a cardinality of many). how could i write a query that returns all folders with no children?
17:14gtrakwingy: I feel like vars are controlled global variables
17:14wingylexical/static binding is resolved by looking _where_ the identifier is used .. while dynamic binding is resolved by looking at _when_ the identifier is used
17:15wingythe former is about place .. the latter is about time
17:15kovasbyes
17:15TimMcspacebinding and timebinding
17:15wingyyes!
17:15technomancynice
17:15TimMcWinner of the prestigious 2012 Sounds Cooler Than It Is Award.
17:15gtrakcan we really decouple time from lexical bindings?
17:16gtrakthat'd be a neat trick
17:16kovasbyes, it essentially happens at compile time
17:16gtrakerrr... in some sense I guess
17:16gtrakthat seems strange to say to me, being a von-neumann guy first
17:18gtrakmaybe if everything was lazily evaluated I'd believe you
17:20gtraklookup parameterization vs actual values at runtime I guess is what we're arguing about
17:22gtrakI suppose jvm overhead and GC is kinda like laziness
17:24siscia(Hi everybody, I have a little question about the design of a bayesian network, direct acyclic graph, anybody has a little of experience and can help me ?)
17:24hiredmankovasb: https://github.com/actsasgeek/nota-bene
17:25hiredman:( noir
17:25technomancyhiredman: `lein deps` =(
17:25kovasbhiredman: whoa
17:27wingywow .. read the first section of http://c2.com/cgi/wiki?DynamicScoping .. another perfect explanation
17:27kovasbwho knows what lurks on github..
17:29hiredmaninterestingly doesn't store the result of a computation in the work book
17:29wingybut that is the same as the place and time explanation .. lexical: where is the identifier used? inside this scope, that is inside this scope, that is …. dynamic: when is the identifier used? when this fn is called, which is called by this fn, which is called by...
17:29kovasbwell, thats a problem :)
17:29penthiefHow do I add tools.jar to the maven-clojure-plugin clojure classpath?
17:30amalloyoh, i like the time/place explanation. that's cute
17:31wingyfor someone that is interested: http://info.rjmetrics.com/blog/bid/51652/Lexical-vs-Dynamic-Scope-in-Clojure
17:35wingyin a let binding the symbol is directly naming the value whereas in a def the symbol is naming the var that is pointing to a value?
17:40gtrakwingy: I was reading that one
17:40gtrakyes, what you said is correct
17:40wingygreat :)
17:40gtrakif you want to get at the var itself when you reference it, you can use (var ..) or #'
17:40wingyyepp
17:40gtrak,(var +)
17:40clojurebot#'clojure.core/+
17:41gtrak,(class (var +))
17:41clojurebotclojure.lang.Var
17:41gtrak,(class +)
17:41clojurebotclojure.core$_PLUS_
17:41wingydynamic binding is so powerful
17:42RaynesTHE POWER. IT CONSUMES ME! ARRGGGGGG
17:42gtrakkinda like global variables
17:42wingywith great power comes great responsibility
17:42RaynesYeah, except not at all. ;)
17:44arrdemWell I mean if you rebind + to - don't come crying here
17:44siscia(Hi everybody, I have a little question about the design of a bayesian network, direct acyclic graph, anybody has a little of experience and can help me ?)
17:45brehaut~anyone
17:45clojurebotJust a heads up, you're more likely to get some help if you ask the question you really want the answer to, instead of "does anyone ..."
17:45brehaut^ siscia
17:45gtrakarrdem: actually not sure if that will totally break
17:46gtrak,(letfn [(test [] (+ 1 2))] (with-redefs [+ -] (test)))
17:46clojurebot3
17:46gtrakturns out + is inlined
17:48gtrak,(letfn [(test [] (println 1 2))] (with-redefs [println -] (test)))
17:48clojurebot-1
18:00sisciaI was wonder if in the designed of a graph would be better have a very basic "node" (name, table, childs) and have more complex function in the graph. Or it would be better have more complex node (name table parents non-descendants child) and simpler function for the graph structure... It is making any sense ? It's not easy to explain...
18:02kovasbsiscia: what is "table" referring to?
18:03sisciakovasb: i am trying to build a bayesian network, every node should have a probability table to work...
18:06aaelonysiscia: have you looked at cemerick's talk? http://blip.tv/clojure/chas-emerick-modeling-the-world-probabilistically-using-bayesian-networks-in-clojure-5961126
18:08sisciaaaelony, yes i did thanks... but it didn't really give me a lot of ideas for the designed...
18:08sisciaI guess that the better way could be keep the node as "easy" as possible...
18:08aaelonysiscia: after minute 23 he shows how he represents models
18:13gtrakoo, I found something fun
18:13gtrak&(let [m (zipmap (range 10000) (range 10000))]
18:13gtrak (time (dotimes [x 100] (into {} m))))
18:13lazybotjava.lang.RuntimeException: EOF while reading, starting at line 1
18:13gtrak(let [m (zipmap (range 10000) (range 10000))] (time (dotimes [x 1000] (into {} m))))
18:13gtrak&(let [m (zipmap (range 10000) (range 10000))] (time (dotimes [x 1000] (into {} m)))) ; sorry
18:13lazybot⇒ "Elapsed time: 5322.963618 msecs" nil
18:14gtrak&(let [m (zipmap (range 10000) (range 10000))] (time (dotimes [x 1000] (persistent! (reduce-kv (fn [acc k v] (assoc! acc k v)) (transient {}) m)))))
18:14lazybot⇒ "Elapsed time: 2385.999993 msecs" nil
18:14gtrakreduce-kv is a faster into for maps
18:16sisciaaaelony, yes i saw that, but... The better way to represent a node for a bayesian network should be (:name (parents) (non-descendants)) that is what you want if you need to find independence between node in order to get faster query. But in this way is gonna be very hard given a node find the child.
18:19sisciaaaelony, its looks like that cemerick has just memorized the child and he will pass the model in a function to get the parents and non-descendants, but now i also need to make sure that is a DAG (direct acyclic graph) and not just a graph.
18:19sisciawell I guess i am going for the cemerick way anyway, it's look smarter...
18:20sisciathe talk is very interesting...
18:22kovasbwhat up talios
18:22talioshola - not much this morning yet is up.
18:26cemericksiscia, aaelony: https://github.com/cemerick/raposo is indeed the right link, though I've not yet fixed the implementation enough to be comfortable putting it out there.
18:27cemerickIn hindsight, I shouldn't have promised it in the first place, since it wasn't tightened up yet by the time the conf rolled around, and it ended up needing more than I originally expected.
18:29technomancycemerick: having a conference talk blocked on writing code that doesn't exist yet is the worst thing =\
18:29sisciacemerick, I completely understand it is harder that what it looks in the books... I am implementing the DAG like a set what you think is so stupid like idea ?
18:30cemericktechnomancy: well, the shitter of it is that the code *does* exist. But, the week prior, I had a friend of mine look it over that had expertise in that area; he pointed out some serious flaws in the maths that, by happenstance, didn't manifest themselves with my dataset.
18:31cemerickBut, mea culpa in any case.
18:32cemerickAt this point, I feel better about leaving the repo empty than putting out stuff that probably will have undefined results with someone's protein analysis or something.
18:33technomancyouch =(
18:35sisciacemerick, i would suggest to just push the infractuture and not the math part... it is still a lot of work...
18:35cemerickmeh, the maths are the real meat of it
18:38sisciaI know but maybe someone that has time to work on the math would find your repo...
18:42aaelonysiscia: I would look to see how Weka and Mahout implement BNs and also perhaps other packages that (may not) scale but take other approaches
18:43sisciaaaelony, thank for the hit
18:43brehautive never understood why they chose the name Weka for an AIish system
18:43brehautthose are some pretty dumb birds
18:43aaelonyhehe...
18:44aaelonymaybe see how matlab or octave implements as well
18:44brehautoh. its an acronym
18:46aaelonysiscia: maybe this is also helpful (??) https://code.google.com/p/bnt/
18:48sisciaaaelony, yes it is definetily is, thanks
18:49sisciathe real problem is that oo code helps (weka and mahout) but not so much...
18:50aaelonysiscia: yeah, performance will be key
18:50aaelonysiscia: there is likely (somewhere) a github fork of Bradford Cross' old Infer library code that might have something as well, not sure
18:52sisciaaaelony, https://github.com/aria42/infer this ?
18:53aaelonysiscia: possibly, there exist some machine learning stuff in there, don't remember if there was any BNs
18:54sisciaaaelony, i will give a look
18:54sisciathank you anyway, I appreciate
18:54aaelonysiscia: sure. also take a look at incanter. http://incanter.org/docs/api/
18:56sisciaaaelony, right, thanks again... Now it is about 1 AM in my country I should go to sleep... Thank again
18:57aaelonythe sun never sets on Clojure IRC ... :)
18:58sisciaLOL
19:01gfredericksI dunno. when it's 1-4am in the US it can be pretty quiet
19:01gfredericksmaybe 3-6 more accurately
19:08aaelonysiscia: for when you're up tomorrow, perhaps a graph db like jiraph will be worth looking into as well? https://github.com/flatland/jiraph
19:09amalloy$mail siscia forwarded message from aaelony: siscia: for when you're up tomorrow, perhaps a graph db like jiraph will be worth looking into as well? https://github.com/flatland/jiraph
19:09lazybotMessage saved.
19:10aaelonyamalloy: that is cool
19:10amalloythat's why Raynes wrote it!
19:10aaelonyRaynes is cool
19:14gerunddev(defprotocol P (f1 [x] [x y] [x y z]))
19:59mindbenderhow do I make heroku use lein2? It's insisting on using a cached version of 1.7.
20:00technomancymindbender: heroku config:add BUILDPACK_URL="http://github.com/heroku/heroku-buildpack-clojure.git#lein-2&quot;
20:00technomancymore details at https://github.com/heroku/heroku-buildpack-clojure/tree/lein-2
20:03kovasbdnolen: unleashed a rant on the ML. feel free to chime in with a +1 or something :)
20:10dnolenkovasb: cool, you really need to get your CA in :)
20:11kovasbyeah, too bad there is no e-signature option
20:11kovasb"who uses dead trees anymore"
20:12gfrederickswhat on earth does an e-signature mean?
20:12kovasbsigning pdfs
20:12gfredericksoh like a scanned hand-signature?
20:13technomancygpg signature =)
20:13gfrederickstechnomancy: srsly
20:13hiredmanI signed all the forms for work by using latex to place an eps of my signature on the pdf
20:13dnolenkovasb: I don't have much to add since I'm not actively working with literals. A Confluence page at this point would be better - I'm still not sure I understand the nuances.
20:13hiredmanSuper Secure(tm)
20:13kovasbdnolen: content less important than visibility in this case
20:14gfredericksmy favorite is "click this button to e-sign."
20:14kovasbdnolen: i mean, if you totally flamed me, that would also work :)
20:14technomancygfredericks: "click this button if you think there's any validity at all in this process"
20:14gfredericks:)
20:14hiredmanbeing able to work with unknown instance literals would be useful
20:14gfredericksdoesn't the IRS use something equivalent?
20:15technomancygfredericks: "if you question the usefulness of a signature mechanism that can be trivially forged, turn to page 45."
20:15gfrederickslol
20:15kovasbhiredman: without that, its basically no better than arbitrary reader macros, where everyone needs the exact same setup
20:16hiredmankovasb: maybe a better approach is the ability to define a cache all reader
20:17hiredmanmight be more flexible
20:17hiredmancatch all :)
20:17hiredman(catch all? fall back? something like that)
20:17kovasbhiredman: that could work. though i figure you can extend-type on the UndefinedLiteral as well
20:18dnolenkovasb: I could chime in but I don't think it would help. A Confluence page w/ a design / solution could spark some focused discussion. Then a patch could fall out of that.
20:18hiredmanwith the fallback, you could just define it as identity, and get the unprocessed value
20:19dnolenkovasb: basically, people work on what they need. If you need it - then you probably need to work on it.
20:19kovasbhiredman: yeah but if you need to transmit the data to the next guy, you need to reconstruct the literal
20:19hiredmankovasb: *shrug* if you need to do that, then you set the fallback reader to something that lets you do that
20:19kovasbdnolen: alright looks like there is a kinkos within a couple of blocks from me. will put on my big boy pants
20:20kovasbhiredman: i think that is the most common case, that should just happen automatically
20:20penthiefIs there a maven-cljsbuild plugin yet?
20:21kovasbhiredman: though for my solution to work, you effectively need a catch-all anyway
20:21kovasbhiredman: so one should be able to redefine it as well
20:27emezeskepenthief: You don't like leiningen? :)
20:30penthiefI don't think so, there are better tools for maven.
20:33penthiefAre we trying to take over the entire stack?
20:35emezeskepenthief: Well, Leiningen uses maven repositories, so I don't think it's replacing the entire stack, just the frontend.
20:35amalloy&((fn x [] (x))) ;; we did it, took over the whole stack!
20:35lazybotjava.lang.StackOverflowError
20:35kovasbdestroying the village in order to save it
20:46wingyOracle is porting JavaScript to JVM .. does that mean ClojureScript will be using that one instead of Rhino?
20:56emezeskewingy: ClojureScript doesn't target any one virtual machine
20:56emezeskewingy: So presumably Oracle's JS port to JVM will just add another platform for ClojureScript to run on
20:56wingyhm
20:56wingyyeah im reading https://github.com/clojure/clojurescript/wiki/The-REPL-and-Evaluation-Environments
20:57wingyso you start your JVM and then you start the JS repl inside of it it seems
20:57emezeskeCLJS runs on rhino, node.js, v8, spidermonkey, etc
20:57emezeskewingy: The backend for running REPL commands is configurable
20:59wingyemezeske: im trying to get how it all works
20:59wingywhat is the best guide to use cljs in my browser app?
20:59emezeskewingy: If you're just getting started, I'd start with lein-cljsbuild (shameless plug)
21:01dnolenemezeske: that said if Nashorn is significantly faster than Rhino, which is cruelly slow, I'm all for it :)
21:02emezeskednolen: Oh, hell yeah
21:05kovasbthey are claiming its 3-5 times faster, but i fail to see the point
21:05dnolenkovasb: hmm 3-5 faster? That's it? Forget about it.
21:06kovasbaccording to some random info world article
21:06dnolenkovasb: I thought idea was to be competitve w/ things like V8, JSC, and SM
21:07kovasbdnolen: granted it is brand new
21:08wingyoracle want a piece of the pie
21:08dnolenkovasb: I suppose perf is tied to perf of invokeDynamic.
21:08jhultenwingy: Oracle wants to own the means of pie production...
21:09wingy:D
21:13dnolenkovasb: did you take a look at halgari's reactive lib?
21:14kovasbdnolen: yes i've looked at all that stuff to some degree
21:14dnolenkovasb: thoughts?
21:15kovasbi haven't had that magical "this is it" feeling yet
21:16kovasbI'm not sure what to think, other than its good people are exploring the domain
21:19kovasbdnolen: "Special macro code is needed for if, and let." not a good sign
21:25kovasbdnolen: i do agree that its better to have a dsl than to manually connect the pieces together
21:25wingyis this a nice way to get how to use cljs with clj? https://github.com/brentonashworth/one
21:25dnolenkovasb: I think part of the problem is that people are thinking about DSL instead of thinking about what the machinery should look like first.
21:26kovasbdnolen: yes i agree
21:26kovasbdnolen: one big thing that is getting complect here is, the sources and sinks of the events are mutable objects
21:27kovasbdnolen: so we are have an impledence mismatch problem as well as a "reactive update" problem
21:28kovasbdnolen: i basically got my DSL as far as i could go before realizing i couldn't really conceptualize what was actually happening
21:28wingyclojurescriptone seems outdated
21:28dnolenwingy: there's an up to date branch M003 or something.
21:30wingydnolen: yeah
21:31wingydnolen: im not very good at git . do you know how i fetch that branch?
21:31gfredericksgit fetch; git branch -a; git co branch-name
21:32gfredericksby "co" I mean "checkout"
21:34wingygfredericks: thanks
21:34wingyhttps://github.com/brentonashworth/one/tree/M003
21:34wingyit says that i should run lein bootstrap but there is not such task
21:35kovasbdnolen: the dsl is describing the relationships better, but overloading the existing the constructs of clojure to do it doesn't quite cut it
21:37kovasbdnolen: reminded of how the reducers library deconstructs the concept of map. need something like that for programming constructs in this domain
21:37dnolenkovasb: hmm, RxJS really doesn't look that bad.
21:38dnolenkovasb: I'm looking at drag & drop, http://theburningmonk.com/2011/03/drag-and-drop-using-reactive-extensions-for-javascript/
21:38cbrozefskywingy: bootstrap is a addon for lein or part of lein2, I can't recall specifics
21:38cbrozefskyyou'll also need git-deps
21:39wingycbrozefsky: git-deps?
21:39dnolenkovasb: for starters I wonder if simply attaching observers could be made functional.
21:39wingyhttp://comments.gmane.org/gmane.comp.java.clojure.user/57636
21:40cbrozefskyyou want lein2
21:40wingy"I suspect it's an incompatibility with lein2. Try leiningen 1.x."
21:40wingy:(
21:40cbrozefskyoh the other way? I don't think so
21:40wingyim on lein2
21:40kovasbdnolen: that part is a good idea
21:40cbrozefskyhehe
21:40dnolenkovasb: (subscribed (observable x)) returns a new observable, no mutation of the observe list.
21:40dnolener subscribe.
21:40wingynoway i got back to lein 1
21:41cbrozefskyhttp://clojurescriptone.com/documentation.html#leiningen.bootstrap
21:41cbrozefskyso if I am correct, those come in as files lein will load up
21:41cbrozefskyyou know, you can download lein 1.X call the script lein1
21:41cbrozefskyand run it
21:41kovasbdnolen: definitely a better idea than attaching event handlers for sure
21:42cbrozefskythat's what i do
21:42cbrozefskywingy you can also just try running "lein deps; lein git-deps"
21:42cbrozefskybut I bet the git-deps will fail
21:42wingyyeah there is no such task
21:42wingywtf
21:43wingyi dont get this
21:43cbrozefskyWell, CL One goes against the suggestions of the lein maintainers, this is what happens
21:43wingya pity i was looking forward to this
21:44cbrozefskyyou can also get rid of the git deps, replace them with proper deps
21:44cbrozefskyad skip git-deps and bootstrap alltogether
21:44dnolenkovasb: I suppose there still a bit of a resource problem. (observable x) still needs to mutate x.
21:44cbrozefskywingy: sorry dude
21:44wingycbrozefsky: i dont have the experience to do so
21:44cbrozefskyits clojure and domina it wants right?
21:45wingyill just watch for other tutorials
21:45cbrozefskyopen project.clj
21:45cbrozefskylook, learning your packaging tools it part of it 8)
21:45cbrozefskyI'll walk you thought
21:46dnolenkovasb: tho I'm not sure that's actually a real problem ...
21:46cbrozefskyopen up project.clj, see where the git-dependencies statement is
21:46cbrozefskyremove that, and then see where the :dependencies list is?
21:47kovasbdnolen: i don't think its a problem
21:47kovasbdnolen: my problem is not what these things do, its what they don't do
21:47dnolenkovasb: ?
21:47kovasbdnolen: they don't really help you with higher-level representations
21:48wingycbrozefsky: and next?
21:48kovasbdnolen: like, i want the changes to have an effect on a more abstract structure
21:48kovasbdnolen: and then percolate the changes down
21:48cbrozefskyadd dependencies for domina
21:48dnolenkovasb: does Rx not handle that?
21:48kovasbdnolen: its just a more elegant way of handling events, not a way of keeping representations in sync
21:50kovasbdnolen: responding to events is different from generating a representation from scratch
21:50cbrozefskyand clojurescript
21:51dnolenkovasb: what's the simplest example of something you find problematic?
21:52kovasbdnolen: representing a hiccup datastructure as a dom element
21:52wingycbrozefsky: https://clojars.org/ibdknox/clojurescript ?
21:52cbrozefskywingy: I'll put my project.clj in a gist
21:52wingywhy is it on ibdknox namespace :)
21:52cbrozefskyit just worked for me
21:52kovasbdnolen: you update your hiccup structure.. and then what
21:53cbrozefskyhttps://gist.github.com/3126459
21:53cbrozefskythat is the project.clj I used for one
21:53cbrozefskyreplace yours with that
21:53kovasbsame problem for any higher level representation that needs to be compiled to a lower level one
21:53cbrozefskyI then, with lein2, did: lein deps; lein repl
21:53cbrozefskyand it appears to work
21:54cbrozefskythat is as far as I tested it at least
21:54cbrozefskywingy: good luck 8)
21:54dnolenkovasb: right you're talking about the problem that you want to listen at the level of hiccup?
21:55kovasbdnolen: thats one way to put it
21:55kovasbdnolen: in the case of the drag and drop example, i would want the coordinates in my hiccup to change
21:55kovasbdnolen: and then the dom would just react accordingly
21:55wingycbrozefsky: it says Could not find artifact org.clojure:clojurescript:pom:0.0-1069 in central (http://repo1.maven.org/maven2)
21:56wingyand all other
21:58cbrozefskylein2 clean
21:58cbrozefskylein2 deps
21:58cbrozefskythat is an old version
21:58cbrozefskyand that doesn't appear in that project.clj I gave you
21:59kovasbdnolen: if you have that, then you can build higher level declarative stuff, like the thing the drag and drop represents
21:59dnolenkovasb: hmm what's the problem with the Pods approach? You can (manipulate immutable-hiccup) -> mutable hiccup which handles synchronization. any attempt to read produces something persistent?
21:59wingycbrozefsky: thats the weird part .. why is it trying to get that one
21:59wingyi onlu changed clj version to 1.4
21:59cbrozefskyold dep data around?
22:00kovasbdnolen: yes, but how do you write the synchronization function
22:00kovasbdnolen: thats the missing piece
22:01kovasbdnolen: in a way that is built up from some reasonable constructs, not some ugly hack that is a pain to write every time
22:01kovasbdnolen: and not special-cased to the dom
22:02cbrozefskykovasb: so you don't want to rerender the hiccup and then replace it wholesale in the dom, right?
22:02wingyimpossible i deleted it and git clone it again
22:02wingystill the same
22:02dnolenkovasb: ? I don't see the problem. The hiccup has to be annotated somehow with events.
22:02kovasbcbrozefsky: no, that would be easy, but too slow
22:02cbrozefskywingy: did you copy that project.clj I linked too into the dir
22:03wingyyeah i used your one
22:03cbrozefskyok, and when you git clone again you nuked it
22:03wingyyeah
22:03wingybut i checkout the remotes/origin/M003 branch
22:04wingyperhaps that one is weird?
22:04cbrozefskyI have no clue what you are talking about now
22:04dnolenkovasb: it doesn't sound like to me for interaction you need the whole structure - only for serialization right?
22:04kovasbdnolen: the problem is you are translating between mutable and immutable things
22:04kovasbdnolen: with some fairly involved logic
22:04cbrozefskykovasb: yah, so rendering the whole thing is costly, however, if you know what you changed, and then can ap that to the DOM, like say, via IDs...
22:05kovasbdnolen: and you need to update the mutable thing in the correct way
22:05wingyfuck this
22:05dnolenkovasb: I guess I don't see the problem. Mutating is easy. Annotating is easy. Copying is easy. What else is needed?
22:05cbrozefskykovasb: ok, so your hiccup data structure is manipulated via something using a tree zipper to get around
22:05wingyif its that hard to use it perhaps its not meant for me
22:05kovasbcbrozefsky: yes, you can do it, but we want to do it not just for the DOM, but at higher levels of abstraction as well
22:05wingyi dont even know why i wanna use it
22:06wingyill read some other tutorials how to use cljs
22:06cbrozefskykovasb: when you make a change, you san back up the list for your the elements that are tagged with an ID, you make a list of them
22:06dnolenkovasb: at no point have I mentioned the DOM - that's part of the event architecture.
22:06cbrozefskyyou can then render just those fragements and update the same elements in the DOM
22:06dnolenkovasb: events are constraints that keep things in sync.
22:06ibdknoxdnolen: kovasb: I think we need to take a step back, because the FRP discussion seems like 4-5 different problems
22:06cbrozefskyor whatever other structure you want to sync with
22:06kovasbdnolen: think about how complex the logic is for the hiccup-to-dom function
22:06ibdknoxand we're conflating their solutions
22:07kovasbdnolen: how do you trace through that logic and determine the exact mutation that should occur
22:07kovasbdnolen: when a tiny piece of your hiccup changes
22:07dnolenibdknox: agreed. Events is one thing. Abstracting data structures is another.
22:07dnolenkovasb: you don't need to trace. You have events mutating a mutable thing.
22:07kovasbi am ignoring events here
22:07ibdknoxdnolen: if you guys can wait until after my oscon presentation (thursday) I'll chime in with something
22:08kovasbsuppose your hiccup changes because you got new data from the database
22:08cbrozefskyibdknox: thanx for noir, jayq, korma 8^)
22:08ibdknoxcbrozefsky: np :)
22:08null-you are still working on noir?
22:08dnolenibdknox: excellent :)
22:08kovasbibdknox: will there be a live stream?
22:08ibdknoxdnolen: kovasb: but I think we should center the discussion around the code we want to write - it's not clear to me what that is quite yet
22:08ibdknoxthen worry about the "how" ;)
22:09kovasbright
22:09dnolenkovasb: I think I'm forgetting to say something here.
22:09kovasbi want to write high-level tagged literal representations of the UI
22:09ibdknoxkovasb: I don't think so.. I think they're trying to sell videos or something
22:09kovasbibdknox: self-record your screen and audio :)
22:10ibdknoxnull-: not focusing on it, Raynes has been helping me there, but I use it for Light Table so it's not ignored completely by any means
22:10dnolenkovas: in my mind you have annotated hiccup -> DOM. When we put it in the DOM we get back something which we can read which can reconstruct the hiccup (I personally don't see another way).
22:10dnolenkovasb: kind of like working with source code, parse / unparse
22:11kovasbdnolen: I'm thinking of e.g., the slider example - you move the slider, a value changes, and then you need to update another graphics based on that new value
22:11dnolenkovasb: but all that happens in the mutable world. But you'll get back handles that reconstruct the Hicucp.
22:11null-ibdknox: ok cool
22:12ibdknoxit's safe to assume it's not going anywhere, if that's your concern
22:12kovasbdnolen: yeah, i get that. but you need to be able to change your models in other ways as well
22:12dnolenkovasb: an example you have in mind you haven't mentioned so far?
22:12kovasbdnolen: hiccup is just a very low level example of a model. but it captures the essential point
22:13kovasbdnolen: sure, pretty much every construct in session
22:13kovasbdnolen: the loops, the sub sessions, the session
22:14kovasbdnolen: higher-level widgets of various sort
22:14kovasbdnolen: graphics
22:15kovasbdnolen: those should all be declarative things, that get recursively expanded to lower and lower level representations
22:15null-ibdknox: yeah, good to know
22:15dnolenkovasb: I don't see how the unparse / parse model doesn't support those as well. Your issues seem to be completely about serialization. But maybe I missing something.
22:16kovasbdnolen: a representation may not contain all the info needed to reconstruct
22:17kovasbdnolen: for instance toggling detail level
22:17dnolenkovasb: why wouldn't it have that?
22:17kovasbdnolen: like, you are zoomed in an an area of the graph
22:17kovasbdnolen: not showing the whole thing
22:18kovasbdnolen: i mean, in general you don't want to have only a 1-to-1 model-view relationship
22:18kovasbdnolen: where you only have exactly one view for the model
22:18dnolenkovasb: but something is storing that state, regardless of whether it's on the graph itself or not.
22:19kovasbdnolen: yes
22:19dnolen@(go! graph-of-constraints) -> copy
22:19kovasbnot following
22:20dnolenkovasb: you start with a data rep + constraints (events), go! realizes it (puts it in the DOM), you need to serialize - start at the root producing the immutable copy.
22:21kovasbdnolen: you think we should get rid of models and just store all the data in the dom?
22:21devthhow would you transform [1 2 3 4] into {1 1, 2 2, 3 3, 4 4}?
22:22dnolenkovasb: this is what I mean about a parse / unparse model
22:22dnolenhiccup can parse to DOM
22:22dnolenbut DOM can't unparse to hiccup
22:22kovasbok
22:22dnolenso make the DOM smart enough to unparse itself.
22:22brehaut,(mapcat (juxt identity identity) [1 2 3 4])
22:22clojurebot(1 1 2 2 3 ...)
22:22kovasbok, yes, you can try to do that
22:22kovasbthat is basically what mathematica does
22:23devthbrehaut: ty
22:23dnolenkovasb: I guess I don't see any other way. It's also a pretty tried and true way with compilers :)
22:23kovasbright
22:24kovasbi mean, fair enough
22:24kovasbI'm trying to invent something new in this department
22:24kovasb:)
22:24kovasbits intuitive to me why i want it, maybe not to others
22:25dnolenkovasb: heh, it seems to me a protocols really wouldn't be enough - you'd need some kind of specialized data structure - and I'm not sure it would work for all cases.
22:25kovasbthough i think its a good argument that 1) you want models distinct from views and 2) you want it to be easy to create layers of abstraction
22:25dnolenkovasb: putting things in the DOM is fast - based on your use case you don't need to unparsing all the time.
22:25kovasbdnolen: yes protocols are not enough
22:26dnolenkovasb: do you need to unparse on every mouse movement? I doubt it. Only at mouse up.
22:26dnolenyou've got about 300ms to unparse after a mouseup before a human notices.
22:26dnolenI don't see any challenges here.
22:26brehautdevth: a more sensible implementation uses (partial repeat 2) in place of (juxt
22:27kovasbdnolen: I'm less worried about going from dom to data than from data to dom
22:27kovasbdnolen: the assumption here is your program is dealing at the level of abstract logic, and updating clojure data
22:28kovasbdnolen: so low level dom events get converted into something with semantic meaning
22:28dnolenkovasb: I'm not so sure.
22:28kovasbdnolen: and which then in turn changes some data
22:28kovasbdnolen: i mean, thats the backbone way right :)
22:29dnolenkovasb: I think you want to bridge the two worlds in a way that's not necessary.
22:29dnolendeclare your mutable world - run it - get immutable copies is what I'm suggesting.
22:29dnolendon't make it chatty.
22:29kovasbdnolen: its not necessary, since people have been writing apps the old fashioned way forever
22:30kovasbdnolen: i think the update interval is an optimization
22:30dnolenkovasb: well gotta run for a bit - let's chat on Wednesday :)
22:30kovasbdnolen: cool, talk to you later!
22:39gnarmishey does anyone know where clojure.contrib.string went in the whole 1.3 diaspora?
22:39aperiodicclojure.string
22:39gnarmisah really?
22:39aperiodicyup
22:40gnarmiswas just looking for substring? in there
22:41devthbrehaut: i really just wanted to know the function to use. the value of each item would actually be computed based on the key.
22:41gnarmishmm can't find substring?, maybe it got renamed or deprecated or something
22:41brehautsubs
22:41brehautor .substring
22:42jweissis there a good reason Delay objects don't support metadata? or just that no one has added it yet?
22:42brehautoh, sorry missed the comma there
22:42aperiodici don't thing substring? made the trip
22:43gnarmishmm ok, .substring's there i guess
22:44aperiodic(def substring? [needle haystack] (>= (.indexOf haystack needle) 0)))
22:44aperiodics/def/defn/
22:45devthbrehaut: so if i need to compute the value based on key, would i use this? (map #(hash-map %1 (* %1 %1)) [1 2 3 4])
22:45brehautdevth: im not sure what you are doing sorry
22:46devthbrehaut: ok np. that code works - i just don't know if it's idiomatic.
22:46devth,(map #(hash-map %1 (* %1 %1)) [1 2 3 4])
22:46clojurebot({1 1} {2 4} {3 9} {4 16})
22:46gnarmisawesome, was about to do something with indexof
22:47gnarmisalthough re-seq seems even more handy
22:50devthactually that doesn't work. i want {1 1, 2 4, 3 9}. arg, so rusty after not touching clojure in several months :(
22:52brehaut,(into {} (map (fn [i] [i (* i i)]) [1 2 3 4]))
22:52clojurebot{1 1, 2 4, 3 9, 4 16}
23:02amalloy'into and 'for go together like bagels and cream cheese though, guys! ##(into {} (for [i [1 2 3 4]] [i (* i i)]))
23:03lazybot⇒ {1 1, 2 4, 3 9, 4 16}
23:03devthbrehaut, amalloy thanks!
23:05dsrguruin common clojure style are earmuffs only used for thread-local dynamic vars or do they get used for things like agents too?
23:09amalloyearmuffs strongly suggest dynamic vars
23:16dsrguruamalloy: so for agents in web app code that get read from and written to by each browser session, don't use earmuffs, correct?
23:16amalloyright
23:16dsrguruthanks
23:22iDesperadOwhat's the problem of my gcd function?(defn rgcd [a b] (if (= a 0) b (rgcd [(rem b a) a]))). when I call it with (rgcd [24 36]), the repl errs me with a ArityException
23:23tmciver(defn rgcd [a b] (if (= a 0) b (rgcd (rem b a) a))) ;; lose the square brackets on the recursive call.
23:24iDesperadO(clojure.core/defn rgcd [a b] (if (= a 0) b (rgcd [(rem b a) a])))
23:24iDesperadOsorry about that
23:25whamiedThe problem is that you're passing in a vector as an argument
23:25dsrguruas in call it with (rgcd 24 36)
23:25whamiedright
23:26whamiedarity is the number of parameters, the problem is you're passing in only one as opposed to the two you specify
23:26iDesperadOI've both passed the arguments as vector and as individual numbers...both errs the same error exception
23:26whamiedright, the recursive call is also a vector
23:26whamied(rgcd [(rem b a) a])
23:27dsrguruit should say (clojure.core/defn rgcd [a b] (if (= a 0) b (rgcd (rem b a) a)))
23:27whamiedso, lose the square brackets, as tmciver said above
23:28dsrguru(you don't need the clojure.core; I was just copying what you wrote)
23:28dsrguru(unless you've redefined defn in the current namespace, but I hope you didn't)
23:28iDesperadOso..that's the problem of my definition when i call the rgcd passing a vector instead of two actual arguments?
23:28dsrguruit would be fine if you had written (defn rgcd [[a b]] ...
23:28dsrgurubut the parameter list that defn takes
23:28dsrgurudoesn't create a single vector parameter
23:29dsrguruit creates any number of separate parameters
23:29dsrguruthat's just how it works
23:29dsrguruso (defn foo [a] a)
23:29dsrguruis a function of single arity
23:29dsrguruone parameter
23:29amalloyiDesperadO: the problem is that (f x y) is not the same as (f [x y])
23:29dsrguruand it returns that one parameter
23:29dsrguruamalloy: I think iDesperad0 is confused because in the call to defn, you enclose the parameter list with square brackets
23:30dsrguruso iDesperadO might think that the parameter list is specifying something like a destructured vector
23:30dsrguruiDesperadO: it's just the grammar of the Clojure language that you put square brackets around the parameters when you define the function using defn
23:31dsrgurubut that creates a function
23:31dsrguruthat gets called with those parameters as separate arguments
23:31dsrguruso (defn add [a b] (+ a b)) gets called (+ 3 4) not (+ [3 4])
23:32iDesperadOthen my second wonder is if the calling part is not right, why the repl didn't errs right after my finishing the definition?
23:32dsrgurucan you paste the definition you're referring to right now?
23:32iDesperadOuser=> (clojure.core/defn rgcd [a b] (if (= a 0) b (rgcd [(rem b a) a])))
23:33iDesperadO#'user/rgcd
23:33iDesperadOuser=> (rgcd [24user=> (rgcd [24 36]) 36])
23:33dsrgurubecause the recursive call (rgcd [(rem b a) a]) part
23:33dsrguruhasn't been evaluated yet
23:33iDesperadOArityException Wrong number of args (1) passed to: user$rgcd clojure.lang.AFn.throwArity (AFn.java:437)
23:33dsrguruwhen you define it
23:33dsrguruso even though the function isn't correct
23:33iDesperadOhasn't been evaluated...hmm...lazy evaluation right?
23:33dsrguruit generates a runtime error
23:33dsrgurunot a compile-time error
23:33dsrguruwell no
23:34dsrguruit's just that you haven't called rgcd
23:34dsrguruso
23:34dsrgurufirst you type the code in
23:34dsrguruthe (defn rgcd ...) stuff
23:34dsrguruthen clojure reads when you typed
23:34dsrguruand it assigns the function you defined
23:34dsrguruto the name rgcd
23:34dsrgurubut it doesn't execute the function yet
23:35dsrguruthen once you try actually running it
23:35dsrgurusuch as (rgcd 24 36)
23:35iDesperadOOh...first read, then compile, then evaluate...
23:35dsrguruyes
23:35dsrguruwell
23:35iDesperadOi get it
23:35dsrguruit reads defn
23:35dsrguruand it evaluates defn
23:35iDesperadOthank you guys
23:35dsrgurubut it doesn't exexute the function yet
23:35cshellit defines a function
23:36cshelland binds it to the sybol rgcd
23:36dsrguruevaluating defn just means compile the function and assign it to the name rgcd
23:36dsrguruwhen you type (rgcd 24 36)
23:36dsrguruthe repl reads that just like it did the defn expression
23:36iDesperadOso I should still define a function with parameters in a vector or just list them....I'm afraid I want to vector form....since I can expand the arity using a & when i need it
23:36dsrguruand then it evaluates it
23:36dsrguruand when it evaluates it
23:36dsrguruit tries running the function
23:36dsrguruand sees the problem
23:37dsrguruyes parameters get defined in square brackets
23:37dsrguruyou're just listing them
23:37dsrgurubut in square brackets
23:37dsrgurubut the way defn is defined, the function created is not taking a single argument of vector type
23:38dsrgurubut rather as many arguments as you enclosed in the square brackets in your defn expression
23:38iDesperadOso ...it's just two phases. read/evaluate(compile and run), right?
23:38dsrguruessentially
23:38dsrguruyes
23:38dsrgurubut they're not always separate phases
23:39iDesperadOdsrguru: ok, I define with parameters in vectors and call it with individual arguments listed one by one...
23:39dsrguruyes
23:39dsrguruthe reason btw that they're not always separate phases
23:39iDesperadObecause we can use a macro?
23:39dsrguruyes
23:39dsrguruso for example
23:40iDesperadOto stop evaluation at the moment?
23:40dsrguruduring the reading of (defn ...)
23:40dsrguruthe repl says
23:40dsrguruoh wait
23:40dsrgurudefn is a macro
23:40dsrguruso let me translate this whole expression into something else
23:40dsrgurubefore evaluating it
23:40dsrguruand certain expressions
23:40dsrgurulike regexp patters
23:40dsrgurucan be evaluated at read-time
23:40dsrguruand you can call the read function
23:40iDesperadOOh
23:40dsrguruwhich reads
23:40dsrguruwhen it is evaluated
23:40dsrguruso like
23:41dsrguruboundaries are kinda flexible
23:41dsrguruunlike non-lisps
23:41dsrguruwhere you can't easily interact with different phases of compilation at runtime
23:42iDesperadOhm....code is data is code...as Fogus says in the book The Joy of Clojure
23:42dsrguruexactly!
23:43iDesperadOah...my function is right
23:43dsrgurugood
23:44iDesperadOand ... I'm wondering the calling part of rgcd is at tail position?
23:44iDesperadOit's at the else part of it with is the body of the function
23:44iDesperadOI guess it is
23:45iDesperadOso it can be optimized
23:45dsrguruyes
23:46dsrgurubut had you put the recursive call to rgcd inside of the call to rem, it would not be
23:46iDesperadOit's at the else part of if statement which is the body of the function...sorry for my typos...
23:46dsrguruexcept
23:46dsrguruin clojure
23:47dsrguruthere's no tail-call optimization :)
23:47dsrguruyou'd have to use loop/recur
23:47dsrgurubut it *is* in tail position in your example
23:47dsrguruso it would be optimized in, say, scheme
23:47iDesperadOso a better implementation of rgcd is to use recur, I guess
23:48iDesperadOI'm confused by recur...esp. with loop
23:49dsrguruit'll be confusing in this example
23:50dsrgurulet's use an example more suited to loop/recur
23:50dsrguruhave you seen the factorial function implemented in clojure or another functional language?
23:50dsrguru(or recursively in any language for that matter)
23:51iDesperadOah...I can't understand others implementation using loop and recur..but I can't write my own
23:51dsrguruso first start with something where tail recursion makes sense
23:51dsrgurulike
23:51iDesperadOI'm writing a better version of rgcd using loop and recur and kinda stuck
23:51dsrguruthe simplest factorial implementation
23:51dsrguruwould be:
23:52dsrguru(defn factorial [n] (if (= n 0) 1 (* n (factorial (inc n)))))
23:52iDesperadO(defn fact [n] (if (= n 0) 1 (fact (- n 1)))?
23:52dsrguru*dec n
23:52dsrgurushould be
23:52iDesperadOforget to multiply by n
23:52dsrguru(defn factorial [n] (if (= n 0) 1 (* n (factorial (dec n)))))
23:52iDesperadOok
23:52dsrguruyeah
23:52dsrguru(dec n) means (- n 1)
23:52lazybot⇒ -1
23:52dsrguruwhat you said
23:52dsrguruyeah
23:53dsrguruso
23:53dsrguruif we called let's say (factorial 2)
23:53dsrguruwe'd be evaluating:
23:53dsrguru(* 2 (factorial (dec 2)))
23:53dsrguruwhich itself evaluates to
23:54dsrguru(* 2 (factorial 1))
23:54dsrguruand then (* 1 (* 2 (factorial 0)))
23:54iDesperadO(* 2 (factorial 1) -> (* 2 (* 1 (factorial 0)))
23:54iDesperadOand it evaluate to base case
23:54dsrgururight
23:54dsrguruso
23:55dsrgurua bunch of stuff has to be evaluated
23:55dsrgurubefore getting to the base case
23:55dsrguruof (factorial 0)
23:55iDesperadOso how to change that to use loop and recur?
23:55dsrguruso what you could do is
23:55dsrguru(defn fac [n]
23:56dsrguru (loop [new-n n
23:56iDesperadOloop to binding variable recur to call from intermediate phases...
23:56dsrguru acc 0]
23:56dsrguru (if (= new-n 0)
23:56dsrguru acc
23:57dsrguru (recur (dec new-n) (* new-n acc))))))
23:57dsrguruso
23:57dsrguruloop sets up temporary let-style bindings
23:57Rayneshttps://www.refheap.com
23:57dsrgurubut also says everything inside here is a function
23:58dsrguruand then it can be called recursively by the keyword recur
23:58iDesperadO(defn fact [n] (loop [new-n n acc 0] (if (= new-n 0) acc (recur (dec new-n) (* new-n acc)))))
23:59dsrguruyou could use n instead of new-n btw since you never need to refer to the old n value
23:59dsrguruso
23:59dsrguru(defn fact [n] (loop [n n acc 0] (if (= n 0) ...
23:59dsrgurushould work too
23:59iDesperadOI usually don't know what to bind and when to recur
23:59dsrguruand then every time you type n
23:59dsrguruit will evaluate to the n defined inside loop
23:59dsrgurunot the old when
23:59dsrguruoh
23:59dsrgurukk