#clojure logs

2012-11-27

00:00bbloomclj_newb_2345: hm, might be just because all the hot spots have been inlined into your program
00:00clj_newb_2345my cojurescript code is so shitty that my laptop's fan audibly spins up when I run my code
00:00bbloomis it faster? heh
00:00clj_newb_2345it's interactive gui; don't have a nice test suite yet
00:00bbloomclj_newb_2345: you know what they say right? lisp is two languages: one for writing programs fast, and another for writing fast programs :-)
00:01clj_newb_2345why hasn't someone written macros for writing fast programs fast?
00:01clj_newb_2345i'm sorely tempted to switch back to java grpahics 2d
00:01dnolenbbloom: source mapping is making me realize two things - it's insane that we don't have position information on symbols - and the CLJS compiler doesn't generate proper AST for many things.
00:02bbloomdnolen: yes, the AST is broken in a whole bunch of places
00:02dnolenclj_newb_2345: problem #1 for fast graphics - SVG
00:02bbloomdnolen: i had a core.logic idea: data validator!
00:02clj_newb_2345dnolen: oh, don't use svg?
00:02clj_newb_2345dnolen: I was hoping to write something like mathjax, but interactive
00:02dnolenclj_newb_2345: it really depends
00:02clj_newb_2345dnolen: what should I use instead?
00:02bbloomdnolen: you should be able to describe a validator for a clojure data structure and poof have it run
00:02dnolenclj_newb_2345: but if you have a lot of entities - it sucks
00:02clj_newb_2345dnolen: I'm actually using svg inside of chrome, using javascript to dynamically create/delete nodes
00:02clj_newb_2345dnolen: I do, I need a single svg group for each character
00:02bbloomdnolen: for example: http://code.google.com/p/closure-compiler/source/browse/trunk/src/com/google/javascript/jscomp/AstValidator.java
00:03clj_newb_2345currently, I have a torture test of simulating a 80x20 terminal, where instead of using a svg:text per line, it's a svg:text per character
00:03clj_newb_2345and i'm manuappy placing the characters
00:03dnolenclj_newb_2345: yeah for intense drawing you gotta go low level w/ canvas
00:03bbloomyou should work your cljs/logic magic and come up with a data validator library and then apply it to the ast :-) then we could have a "formal" ast spec too
00:03clj_newb_2345is canvas or graphics2d faster?
00:04dnolenclj_newb_2345: I'm not sure that comparison even makes sense
00:04dnolenclj_newb_2345: but canvas is not bad
00:04dnolenbbloom: well hugod and lynaghk are kinda blazing that trial - if not using it for validation specifically.
00:05bbloomdnolen: well lynaghk wants to use it for term rewriting, right?
00:05bbloomdnolen: what is hugod using it for?
00:05dnolenbbloom: they both are
00:05dnolenconstraints and rewriting
00:05bbloomdnolen: what's hugod's use case?
00:05dnolenbbloom: configuration for pallet it looks like
00:05clj_newb_2345does java (not chrome/web) have a nice way to organize a scene graph of javagraphics2D objects?
00:06bbloomdnolen: neat.
00:06bbloomdnolen: well i have a bunch of thoughts about the AST
00:06dnolenbbloom: I know
00:06bbloomdnolen: i really hate the :children property :-)
00:07bbloomthat and :env make printing the trees kinda annoying
00:07dnolenbbloom: the last big debate about CLJS AST, suggestion was to move into :children to avoid duplication.
00:07dnolenand not have things outside.
00:08bbloomdnolen: i liked the children as a vector of keys approach, but it didn't play nice with bindings
00:08dnolenbbloom: :env makes AST pretty printing annoying, but it's pretty darn nice in the compiler itself.
00:08dnolenbbloom: binding should become a proper AST node I think.
00:09bbloomdnolen: yup, let is currently a macro that compiles to let*, but i think there needs to be a let*-just-one-binding node… the issue is then that loop supports simultaneous bindings, so it's the odd man out again
00:10bbloomdnolen: also, we need a root level AST node: :op :script or something
00:10dnolenroot might be useful - skeptical about let*-just-one-binding
00:11bbloomdnolen: i understand the skepticism, i'd like to prototype it first
00:11bbloomdnolen: but binding as an ast node is a similar idea
00:12bbloomdnolen: fixes the interleaved ordering problem
00:13bbloomdnolen: the biggest issue i ran into is that not every spot has a "body env" .. there needs to be some kind of synthetic empty blocks, so there is somewhere to hang an :env … as it is, if you have (let [x 1]) then there is no way to get the env at (let [x 1] THIS EMPTY SPOT)
00:13dnolenbbloom: yes I know you mentioned that was a problem in your CPS adventures
00:13bbloomdnolen: sorry if i'm repeating myself :-)
00:14bbloomdnolen: just thinking aloud
00:14dnolenbbloom: heh I know, I'm mostly concerned atm w/ fixing the AST enough for good source mapping - that's a bit of work as it is.
00:14bbloomdnolen: i believe it
00:15bbloomdnolen: do you know for sure what needs to change in the upstream reader?
00:15bbloomdnolen: or maybe it's time to move to the self hosted reader? :-)
00:15dnolenyes, col and line info on all symbols
00:16dnolenBronsa's already pitched blind as a contrib - just waiting to here from the powers that be.
00:16dnolensoon as it's I plan on switching to it - waiting on the Clojure reader is just crazy.
00:16Sgeo__blind?
00:17dnolenSgeo__: Clojure (not Java) reader for Clojure source
00:17krl_ok, i guess this comes up a lot, and might be a slime issue, but is there a way to have printlns inside of functions being used as predicates for maps act in the same way as those outside?
00:18Sgeo__krl, the issue isn't println behaving different, it's a matter of whether or not println gets run
00:18bbloomdnolen: does blind reuse any of the code in the cljs reader?
00:18bbloomdnolen: or it a THIRD reader?
00:18Sgeo__Erm, wait, by maps, do you mean like (map println [1 2 3])?
00:18Sgeo__Or do you mean {} and I just have no idea what you're asking
00:18dnolenbbloom: no, it's a pure Clojure port of the Java version of the reader
00:18dnolenbbloom: cljs reader is just EDN, doesn't count
00:19bbloomdnolen: oh
00:19dnolenyou can't bootstrap a compiler w/ it
00:19bbloomdnolen: gotcha
00:19Sgeo__Ooh, so Clojure-in-Clojure is doing well?
00:19leo2007which jvm to use, 1.6 or 1.7?
00:19krlin emacs, using slime, this code (map #(println (format "hello %s" %)) ["world"]) works differently than just (println "hello world")
00:19bbloomdnolen: I'm peeking at the source now… i like my implementation of syntax-quote better ;-) heh
00:20Sgeo__krl, with the former, is it just not getting run?
00:20krlwhy would it not be getting run?
00:20Sgeo__map returns a so called "lazy seq"
00:20dnolenSgeo__: a pure Clojure reader would be a big step. But to really know if we're doing well some one has to reuse these tools for something that's not JS.
00:21Sgeo__That is, it merely describes how to get the elements
00:21bbloomdnolen: we really should namespace all the special forms too :-)
00:21Sgeo__It won't actually do the println until needed in order to get at the elements
00:21krlSgeo__: hmm. could be. it does print in the minibuffer though for some reason
00:21Sgeo__One way to force it is to call doall or dorun on it. doall returns all the elements, dorun returns nil, and uses less memory
00:21Sgeo__Oh
00:22dnolenbbloom: heh you like to think about long-term improvements ;) The list of things worth fixing now for people actually using CLJS is not short.
00:22krlSgeo__: but actually using doall made it print in the right place.
00:22Sgeo__bbloom, PLEASE namespacing of special forms in Clojure
00:22bbloomheh see dnolen Sgeo__ wants it :-)
00:22dnolen:P
00:23bbloomdnolen: I just like to set the bar high
00:23bbloomdnolen: sometimes, i fail miserably
00:23Sgeo__,(let [do concat] (do [1 2] [3 4]))
00:23clojurebot[3 4]
00:23bbloomdnolen: but sometimes i get way further than i expected :-)
00:23Sgeo__,(let [-> concat] (-> [1 2] [3 4]))
00:23clojurebot(1 2 3 4)
00:23Sgeo__&(let [-> concat] (-> [1 2] [3 4])) ; wrong behavior
00:23lazybotjava.lang.IllegalArgumentException: Key must be integer
00:24Sgeo__,(-> [1 2] [3 4])
00:24clojurebot#<IllegalArgumentException java.lang.IllegalArgumentException: Key must be integer>
00:24Sgeo__..I don't entirely get why that error in particular
00:24dnolenbbloom: I'm all for these kinds of improvements - but I think we have to addres some underlying issues first.
00:24bbloomdnolen: which ones?
00:24bbloomdnolen: besides source maps, of course
00:24bbloomand everything leading up to source maps haha
00:25dnolenbbloom: after source map it would be nice to do a sanity pass on the AST and acutally document it.
00:25dnolenbbloom: whatever we come w/ should be able to accomodate CLJ JVM
00:25bbloomdnolen: yeah, i really think more formality with the AST would be good. hence the core.logic validation idea :-)
00:25dnolenthen we can start having discussion about building cool stuff on top of that.
00:27dnolenbbloom: that sounds like a fun (and useful) side project, yes. but I think just having a design, discussion, eyes, patches is a good start.
00:28bbloomdnolen: fair enough. should we just start a wiki page?
00:28bbloomoh wait
00:29bbloomdidn't somebody alreayd start with a google doc a while back?
00:29dnolenbbloom: yep, jonasen tho it would be nice to get that directly on the wiki page.
00:32bbloomdnolen: yeah here https://docs.google.com/document/d/1DRN-tBIqhqVVyoHIDs7CMkduBFk-vqd_958ojeIBLHQ/edit
00:34dnolenbbloom: right - should probably link to that from wiki
00:36bbloomdnolen: for now: http://dev.clojure.org/display/design/Formalize+AST
00:36bbloomi gotta run, but i'll write up my thoughts neatly soon
00:37dnolenbbloom: cool thx
00:39seangroveOh man, I can't figure out how to get a single reasonable test to run in cljs
00:39wingyi have a form-params map and want to return a response depending on what keys/values are present in the map using pattern matching instead of nested (if) forms .. how is this done in clj?
00:43dnolenseangrove: what are you trying to do?
00:43dnolenseangrove: test at command line? in browser?
00:48seangroveI'd like to run "lein cljsbuild test" and have it run the cljs tests in an environment that has access to a dom.
00:49seangroveI've been trying to figure out how to run a cljs test in phantomjs based on cljs-bootstrap, but it really seems like it's not all there
00:50dnolenseangrove: so is this something that lein cljsbuild test supports?
00:50seangroveAnd I can't seem to find any examples of how people are doing it elsewhere
00:51seangroveReally not sure. I suppose "lein cljsbuild test" was incorrect, I meant "$ <something>" and my cljs test suite runs and tells me what, if anything broken
00:51seangroveAre you running any tests at all on any of your cljs projects?
00:52dnolenseangrove: in a very hacky way yes - just w/ a script and a CLJS test file of asserts
00:52seangroveOk, and that's not in a browser, right?
00:52dnolenseangrove: for CLJS proper - it's somewhat necessary because we want to test at commandline against a variety of JS engines
00:52dnolenseangrove: yeah not in browser
00:52seangroveAh, I might have found something, let me give it a try
00:53seangroveI'll commit to porting clojure.test to cljs once I have the bare minimum environment running
00:53dnolenseangrove: I guess you're following this and it's not working - http://github.com/emezeske/lein-cljsbuild/blob/0.2.9/doc/TESTING.md
00:53dnolenseangrove: heh no need to commit - but I definitely think people would use it if were available.
00:54seangroveYeah, exactly. I'll stepped away for 20 minutes though, and I'll give it another try now
00:54seangroveWell, it'd be a good project, and I'd like to get more involved with cljs where possible to help out
00:56dnolenseangrove: emulating cljs.test would require some help from the compiler - we could use the namespaces atom (which holds all defs in the compiler) to figure what the tests are in a namespace and generate some CLJS that runs them all.
01:01bbloomseangrove: I'm about to run into the browser-level cljs testing issue myself
01:01bbloomnot sure what i'm gonna do about it yet
01:01bbloomi've been manually running asserts on refresh
01:04seangrovebbloom: Would running the tests in phantomjs be acceptable, or do you need actual browsers?
01:04bbloomseangrove: I haven't used phantomjs ever before, but my experience with DOM testing is that browser quirks are kinda important to fix
01:04bbloomdnolen: what now? :-/
01:05bbloomseangrove: the strategy i've used to good effect is to write a little test runner page and then load tests in an iframe
01:05dnolenbbloom: just all these places where we don't have real ast nodes and call munge directly
01:05bbloomseangrove: this way test runs are manual-ish
01:05dnolenthat should never happen - we want everything to go through emit :var so we can put source mapping logic in one place
01:05bbloomdnolen: at least all the munging is in the code generator now :-)
01:05seangrovebbloom: Used to work at Sauce Labs, I'd like everything to be automated as much as possible :)
01:06bbloomseangrove: heh. my experience with selenium was rather poor
01:06seangroveYeah, it was a janky project. Web-driver seems like a better approach
01:06bbloomseangrove: ultimately what my startup did was use JUUUUST ENOUGH selenium to navigate to /test.html and wait for "finished" to appear and then extract the number of tests/asserts/passes/fails and print that
01:07bbloomseangrove: that let us test everything except for some more subtle platform things, like file pickers
01:07bbloomseangrove: so we just tested those by hands
01:07bbloomall the actual tests were pure javascript, no browser driver
01:07seangroveAh, ok
01:07seangroveSo you could potentially have just run it in v8?
01:07bbloomv8 doesn't include a dom
01:08seangroveHeh, so not pure js ;)
01:08seangrovejs + dom
01:08bbloomsorry, i mean pure js in the sense that it wasn't external browser automatino
01:08bbloomit ran IN a *real* browser
01:08seangroveOk, got it
01:08bbloommuch faster than selenium tho
01:08bbloomi've been meaning to get skrenzel to open source that damn test library. it was amazing :-)
01:09seangroveI think with phantomjs it should still be very fast, can have it run on commit hook, and have cross-browser tests run in CI
01:09seangroveWhat startup was it, by the way?
01:09bbloomthinkfuse
01:10seangroveWow, great - you still at Salesforce then?
01:10bbloomnope
01:11seangroveWell, let me see if I can put together a reasonable package for running automated tests with DOM access via phantomjs
01:11seangroveFeels like it could fill a need
01:11bbloomseangrove: would be nice if you can contribute it to cljs-build
01:12seangroveFeels like it should be a separate project that can work with cljs-build. Early projects always tend to be pretty bad, and are supersceded by someone who knows what they hell they're doing later.
01:12bbloomhaha fair enough
01:31tomojhmm.. (range a (inc b))
01:32tomojthat sometimes bothers me, but if I read it as a little flag that says "inclusive", great!
01:35bbloomtomoj: heh, great mnemonic
01:38seangroveHeh, nice
01:42mpanis there an equivalent to proxy for a superclass known at runtime?
01:42mpanor perhaps I may be trying to do something wrong here
01:49mpanwhat I would have liked was to do something along the lines of this: (let [o Object] (proxy [o] []))
01:49mpanbut perhaps that's a sign I'm going about it the wrong way
01:50tomojwhat are you actually trying to do?
01:51mpanthis weird framework has multiple interfaces which for my purposes are the same
01:52mpanalthough I need to double check this now that I think about it because it sounds very wrong in my head
01:52seangroveOk, so in the advanced lein-cljsbuild project, it has a build section :test
01:52mpanI have no idea why it seems to be OK with me leaving out a method that the interface specifies
01:53mpangranted, the interface says the method returns void, but interop seems happy to let me just leave it out entirely
01:53seangroveThat outputs to resources/private/js/unit-test.js. In it, it has code included from the compiled tests, but also from the main cljs as well - the cljs test ns does a (use :main.project.ns)
01:53SegFaultAXRe: lein-ring, when is it appropriate to use an uberwar over a normal war?
01:54seangroveI can't get that same output in my project - the compiled unit-test.js *only* has my unit-test.cljs in it, it doesn't seem to be including the other cljs source at all
01:57mpanquite strange, the proxy is willing to lie about implementing an interface and then when used at runtime complains otherwise
01:57seangroveI can't tell if there's some magic that knows to include the source cljs in the unit-test, or I'm just configuring things incorrectly
02:00leo2007has nrepl completely replaced slime+swank?
02:05seangroveleo2007: Yes, swank-clojure has been deprecated
02:05tomojmpan: why do you only know the interfaces at runtime?
02:06leo2007seangrove: nrepl is a strict superset of swank-clojure?
02:06mpantomoj: it's one from a list, but which one depended on some runtime into, which I figured I should probably restructure because that sounded wrong
02:06seangroveleo2007: Not really, no, but is there anything you're looking for in particular?
02:07leo2007Nothing in particular. I already have swank-clojure running from months ago.
02:07leo2007Just want to know the community's opinion on the new tool.
02:08seangroveI switched form swank-clojure to nrepl.el about a week or so ago, no complaints
02:08tomojI switched and had to switch back, but don't remember why :/
02:08seangroveM-. and friends all work :)
02:08tomojI use slime-inspector quite often
02:09Raynestomoj: Inspector need somebody who cares about it to get it working with nrepl.
02:10leo2007I guess I will get it running to test out!
02:12tomojRaynes: you mean get slime-inspect working? or write a new inspector? either way, I still use swank-clojure for work right now. since I haven't figured out how to get them to play nice in one emacs, I guess I should start another emacs and do scratch work in it with nrepl
02:17echo-areaI use ritz + swank. But the java process uses more and more memory. Does anyone know why?
02:19unic0rnthe memory allocation strategy of java can be described in 3 words.
02:19unic0rnnom nom nom.
02:19mpanwhere is the correct place to put the equivalent of "static initializers" i.e. stuff that needs to be run exactly once and before other stuff
02:20mpanmy current example is loading a table of values into a def'd atom
02:20nightfly_defonce is useful :)
02:20mpaner, rather, my current process is to def it as an atom to nil and then initialize it
02:22mpanshould I switch to defonce and just move that call into the defonce?
02:29nightfly_Not sure really. I'm working on something right now that uses a global ref that is defonced and then is populated my a function that is called in main. I'd be interested in the best way of handling this too.
02:30mpanI suppose part of my problem is I don't currently have a single "main"
02:57jondavidjohnhow would I go about reducing a vector of vectors?
02:57jondavidjohnmaking this.. [[1 2] [3 4]] into .. [1 2 3 4]
02:58tomojyou already said it :)
02:58tomoj&(reduce into [[1 2] [3 4]])
02:58lazybot⇒ [1 2 3 4]
02:59Raynestomoj: Well, the existing inspector is written in Clojure. It just needs to be changed to work with nrepl.
02:59tomojslime-inspector is certainly not written in clojure - are we talking about the same thing?
03:01tomojhmm
03:01tomojis it?
03:02tomojI mean certainly parts of what make slime-inspect work are in slime
03:07Raynestomoj: https://github.com/technomancy/swank-clojure/blob/master/src/swank/commands/inspector.clj
03:07RaynesI meant one would want to get that working with nrepl. Might require a whole rewrite. *shrug*
03:08RaynesI don't really know how it all works because I've never used nor cared about the inspecotr.
03:14jondavidjohntomoj: I ended up using (flatten [[1 2] [3 4]])
03:14jondavidjohnis that ok? any reason to use the reduce method?
03:16jyuhello, any distribution library in clojure?
03:17tomojflatten is overkill
03:17tomojand it doesn't give you a vector back
03:18tomojRaynes: ah right. biggest problem for me is the elisp involved..
03:18jondavidjohnright, i had to do (vec (flatten ...) )
03:18jondavidjohncool, I'll use reduce, thanks!
03:19tomojunless you really want to flatten
03:19tomoj&(flatten [[[1 2 3] [4]] [5 6] [7]])
03:19lazybot⇒ (1 2 3 4 5 6 7)
03:19tomoj&(reduce into [[[1 2 3] [4]] [5 6] [7]])
03:19lazybot⇒ [[1 2 3] [4] 5 6 7]
03:20jondavidjohngotcha, so if i was working with deeper data structures, flatten might be a better idea, but since I'm only ever working with one deep, reduce is more performant?
03:29foodoo&(apply concat [[1 2] [3 4]])
03:29lazybot⇒ (1 2 3 4)
04:52tomojsimplify: (map (partial map f) coll)
04:53tomojhmm
04:54unnalinon-trivial?
04:54Sgeo__So coll is a collection of collections?
04:55unnaliif we go all Haskelly
04:55unnalif :: a -> b
04:55unnalipartial map f :: [a] -> b
04:55unnali[a] -> [b]*
04:55unnalitypo
04:55unnalimap (partial map f) :: [[a]] -> [[b]]
04:55unnaliso coll is [[a]]
04:55unnaliwhere a is the input of f
04:56tomoj(fmap.fmap)
04:56unnaliSgeo__: yeah, I know ;-)
04:56tomojI expected (comp r/map r/map) to work
04:56tomojit sort of does I think
04:56unnaliit should.
04:57Sgeo__It's because fmap takes a function and returns another function, whereas map takes two arguments.. maybe?
04:57tomojyou must supply the final collection curried, though
04:57Sgeo__Why r/map and not map?
04:57Sgeo__What's r?
04:58tomoj(((comp r/map r/map) inc) [[1 2 3] [4] [5 6 7]]) seems to work
04:58tomoj((comp r/map r/map) inc [[1 2 3] [4] [5 6 7]]) blows up
04:58tomojr is clojure.core.reducers
04:59Sgeo__tomoj, well, that
04:59Sgeo__well, that's not necessarily unexpected
04:59tomojyeah
04:59tomojI didn't expect it because all my functions are curried here
05:00tomojthe functor is never passed with the, uh, functand?
05:02tomojs/sort of //
05:05tomojhmm
05:18borkdudefunctions that are evaluated in the REPL are just as compiled as any others right? how does this work again? where does clojure emit a .class file for a function defined in the REPL?
05:19p_lborkdude: you can generate the bytecode and load it without creating a file
05:19borkdudeah
06:06p_lgah. Forgot how memory-hungry java is
06:13echo-areap_l: I use nrepl + swank, and have kind of the same issue.
06:13Bergle_2get more ram :)
06:14p_lBergle_2: 6G here
06:14Bergle_2if its swapping :) its not enough.
06:14echo-areaBut that becomes ridiculous for running a REPL
06:14Bergle_2i bought 16GB recently for like $80 lol
06:14p_lBergle_2: work machine
06:14p_lcan't just add ram
06:15Bergle_2that sucks, but at least your using clojure at work :)
06:15p_l(also, unclear if it doesn't require rare FB-DIMM)
06:15p_lBergle_2: only by own initiative, which is waning right now
06:15Bergle_2i usually amazed how many companies dont make sure the devs have good performance machines.
06:15p_lBergle_2: it's good enough performance for most
06:16Bergle_2first thing i did at last company was get 3 ssd's for dev's and more ram.
06:16p_lalso, government procurement is slow
06:16Bergle_2ahha double whammy - work + govt :) heh
06:26p_leh, maybe I'll manage to ease the memory pressure by modding OS params
06:39wingywhat middleware should i add to get a stacktrace on the web browser when ring is encountering an error: https://www.refheap.com/paste/7016
06:43borkdudewhy is the news info gone from clojure.org?
06:48xeqiwingy: http://clojuredocs.org/ring/ring.middleware.stacktrace/wrap-stacktrace
06:49wingyxeqi: why can't i find it in https://github.com/ring-clojure/ring/tree/master/ring-core/src/ring/middleware
06:49xeqiwingy: https://github.com/ring-clojure/ring/blob/master/ring-devel/src/ring/middleware/stacktrace.clj
06:49xeqiits under ring/ring-devel
06:51wingyxeqi: thx
06:51wingyworked great
06:58borkdudewhat is the recent stabile clojure version, still 1.4?
07:00foodooborkdude: yes
07:00foodooborkdude: although 1.3 is also marked as "stable" http://clojure.github.com/clojure/
07:19wingythe difference between def and atom is that atom can be changed later on while def vars cannot be changed?
07:21HolyJakWell, you can redefine a variable (unless you used defonce) but I feel it is kind of evil :)
07:21HolyJakatom is better if you actually want to share state between threads safely
07:24borkduderedefining vars is only allowed for REPL-purposes I think
07:24wingyHolyJak: but i can't redefine a variable from a fn right?
07:24wingyi can't use (def) inside a fn
07:24wingyyeah
07:24wingyso atom it is
07:24borkdudewingy you can, but it's not "idiomatic"
07:24wingyyeah .. looks weird
07:26HolyJaknot idiomatic - or, in other words, evil :)
07:28wingyit's even forbidden
07:28wingyjudge dredd will come after you
07:30borkdudeyou can however use def in a macro (like defn)
07:33wingyi c
07:37josteink_Im trying to create a "self-aware" object in clojure, but I cant get it right
07:37josteink_Im trying something akin to
07:37josteink_https://www.refheap.com/paste/7017
07:37josteink_anyone have any leads on what Im doing wrong?
07:37josteink_the compiler basically says that "me" cannot reference "me"...'
07:39rodnaph_josteink: i know it's not the answer you want, but why are you trying to do that? is there a better solution (clojure is complaining because the second "me" doesn't exist until the first "me" is created)
07:39madsyjosteink: Because "me" isn't bound yet when you call the function. What you probably want is let* instead of let
07:39josteinkrodnaph_: Im trying to create a system where components can distribute messages, and every message needs to have a caller to avoid causing endless loops
07:40rodnaph_josteink: sounds like lamina might help you out (https://github.com/ztellman/lamina)
07:40josteinkIm trying to -implement- something like that myself
07:41josteinknot reuse others implementation
07:41josteinkeducational stuff ;)
07:41josteinkmadsy: let me look into that
07:43josteinkmadsy: got any links?
07:43josteinkexamples?
07:43clojurebotexamples is api examples
07:44madsyjosteink: Hm.. maybe Clojure didn't have let*. I'm puzzled now.
07:44josteinkso in clojure a thing cannot reference itself ever?
07:44josteinkthat sounds like a odd limitation
07:45madsy,(let [a 1] [b (+ a 2)] b)
07:45clojurebot#<CompilerException java.lang.RuntimeException: Unable to resolve symbol: b in this context, compiling:(NO_SOURCE_PATH:0)>
07:45josteink,(let [a 1 b (+ a 2)] b)
07:45clojurebot3
07:45josteinkbut this is a no go
07:46josteink,(def x (let* [boo { :self boo :hoo "zoo" }] boo))
07:46clojurebot#<Exception java.lang.Exception: SANBOX DENIED>
07:46josteink,(let* [boo { :self boo :hoo "zoo" }] boo)
07:46clojurebot#<CompilerException java.lang.RuntimeException: Unable to resolve symbol: boo in this context, compiling:(NO_SOURCE_PATH:0)>
07:46rodnaph_josteink: the let macro is really just sugar over the identity monad.
07:46josteinkso
07:46josteinkin clojere no entity can know its own identity?
07:47josteinkhow do you auto-establish callers in messaging scenarios then?
07:47josteink"you dont" sounds like a pretty odd limitaion :P
07:48mpanjosteink: how do you propose to evaluate that self reference? I'm confused
07:48rodnaph_i'm afraid i don't really understand what you're trying to do, but i doubt there is any limitation.
07:49rodnaph_(no limitation on achieving your goal i mean)
07:49mpanyou want a circular reference? I thought they tried hard not to let you do that directly
07:49mpanor am I misreading your question?
07:49josteinkrodnaph_: I want a function to have equivalent of "this" in java or C#
07:50josteinkmpan: I want a self-reference
07:50josteinkso I can make "signed calls" from an object to another
07:50josteinkIm trying to cheat with atoms here
07:50mpanwith regards to interop, the interop calls have special features for "this"
07:50mpanwith regard to outside of interop, I think I recall hearing that it's intentionally not allowed directly
07:51mpanyou can use e.g. an atom to do it but that would be stylistically very strange
07:51mpanmay I ask, why do you want "this"?
07:51rodnaph_if you want objects i think unless you use interop you're out of luck. you probably need to rethink your problem with FP in mind.
07:51josteinkhttps://www.refheap.com/paste/7018
07:51josteinkIll try something like this then
07:51josteinkI need to be able to identify myself as a caller
07:51josteinkor else the system will have those circular loops you're not supposed to have :P
07:51mpancan you use some concept of "names" instead?
07:52mpanrather than references?
07:52josteinkI like self-contained ID systems
07:52josteinkotehrwise I would need a mutable name-caller structure
07:52josteinkwith global scope
07:52josteinkand that is even worse
07:52ChongLidoes calling reify on protocols count as interop?
07:53josteinkI just want component A to be able to call component B saying (hey , Im compont A) so that component B can authorize the messager
07:53josteinkI dont want a framework
07:53josteinkI want simple inter-function identity :)
07:53mpanwhy can't A send some concept of a name?
07:53josteinkbecause component B should be able to call back to component A
07:53josteinkand names is misdirection
07:53mpanput something to dispatch
07:54josteinkinstead of compoent B going straight at A, it needs to look up As identity in a table
07:54josteinkand then call it
07:54josteinkinstead of just passing it along directly
07:54josteinkthats inefficient, obscures the code, and doesnt add any value
07:54mpanif you want to directly be able to have that sort of reference then you need something like e.g. an atom
07:54josteinklike I said
07:54josteinkhttps://www.refheap.com/paste/7018
07:54josteinkIll try something like this
07:54mpanwas just trying to clarify what it was you wanted
07:55josteinkyeah
07:55josteinkI want a object to know its own identity
07:55josteinkI find it strange that is should be so much work
07:55josteink:)
07:55mpanmaybe I shouldn't be suggesting this because stylistically it would be strange, but have you considered e.g. an atom containing another one?
07:56mpanI guess that doesn't help much either though :/
07:56josteinkexample?
07:56clojurebotapi examples is examples
07:56mpannever mind actually, it wouldn't work how I initially thought it might
07:56mpansorry to confuse you there
07:59josteinkhehe
07:59josteinknp
07:59mpanjosteink: this is an alternative idea you might want to try
07:59josteinkw00
07:59josteinkit compiles :)
07:59mpanevery action you take on something, you could pass itself in
08:00josteinkmpan: that is what Im trying to do
08:00josteinkbut to do so, I need to know my own identity
08:01mpanif you pass the value in, then in the function the value is known? why does the value need to be special beyond just an atom?
08:01mpansorry I don't follow why you need the extra layer if you're doing that
08:01josteinkbecause Im using message-passing style objects
08:02josteinkI want to pass an object in to another object
08:02josteinkand I want the object to be able to act on that
08:02solussdjosteink: I'm not sure what you're trying to accomplish, but you can declare a var before it is bound, e.g. (declare selfaware) (defn selfaware [] selfaware)
08:02si14how would you guys do a cross-platform app on Clojure with sub-100ms startup time?
08:02josteinksolussd: that is global scope
08:02josteinksolussd: I want function-local
08:02solussdah
08:02mpansi14: is prestarting jvms an option for you by any chance?
08:03josteinkmpan: I want a object A, to be able to call object B's method "somethin" with itself as a parameter, so that object B can call back to ibject A's "some-other" function
08:03solussdsi14: clojurescript + node.js?
08:03josteinkusing message-passing style object calls
08:03mpanI'm gonna try to write up an example of what I was trying to say
08:03si14mpan: it's definitely an option, but the question is how do you talk to Clojure server from shell in cross-platform way
08:03josteinkthats as simple as I can explain it
08:03si14solussd: it's an option, but full-blown Clojure is nicer IMO
08:03mpansi14: there was a project which did this but I don't remember the name at the moment :(
08:04mpanpreloading jvms, that is
08:04josteinksi14: "drip"
08:04josteinkdoes preloading of JVMs
08:04josteinkhttps://github.com/flatland/drip
08:04josteinkworks on unixes, not windows AFAIK
08:04solussdyeah, if "full-blown" = java interop, prestarting is the way to go
08:05si14it's definitely the way, but how to talk with JVM is a question :)
08:05si14preferrably without binaries at all
08:05si14not sure that's not doable on plain shell
08:05si14not know how to do it either :)
08:06si14josteink: I need Windows too, unfortunately
08:06solussdjosteink: is this acceptable? (let [self (defn self [] self)]) :)
08:06josteinksolussd: no
08:06solussd:(
08:06josteinksolussd: the (defn inside the let binding WILL create a global scope binding
08:07josteinklike I said
08:07josteinkIve settled with a construct like this
08:07josteinkhttps://www.refheap.com/paste/7018
08:07josteinkdirty but it works, and is pretty obvious
08:07solussdwell so will your original example
08:07josteinkno
08:07josteinkanyway, I was wondering if there was a simple way to create a self-referencing entity in clojure
08:08solussdyou mean you dont want a global binding for self?
08:08josteinkno
08:08josteinknever
08:08solussdsomething common lisp is bubbling yup to the surface in my head
08:08josteinkI want each and every tiny little object I create of the million objects I create to each have their own "self", which refers to themselves
08:08josteinkanyway, I was wondering if there was a simple way to create a self-referencing entity in clojure
08:08josteinka simple yes no question
08:08josteinkI guess the answer is "no"
08:08josteink:P
08:08mpanjosteink: I think I've got an example of "explicitly passing in self"
08:08josteinkgot any code to share?
08:09josteinkto compare with what ive already done?
08:09mpanlet me make it correct first
08:09mpan=p
08:10clojure-newbhey guys, I'm currently doing (ffirst (reverse (sort on a collection to get the item with the latest date in a hash set… its a bit newb.. whats the idiomatic way to do this ?
08:10mpanjosteink: ok I meant something like https://www.refheap.com/paste/7020
08:11mpanyou have functions and atoms, and you pass the atoms into the functions, specifically that the functions take an explicit "this"-equivalent as first arg
08:11alexnixonclojure-newb: something along the lines of (apply max-key :date [coll])
08:11mpannote that if you wanted the fn to know the caller, the caller can explicitly pass its atom
08:12clojure-newbalexnixon: thx I'll have a look
08:12josteinkmpan: "def" is evil
08:12mpanlike foo could have taken an extra arg that's "the atom of who it's from"
08:12josteinkhttps://www.refheap.com/paste/7021
08:12mpanjosteink: but you could do the same thing locally
08:12josteinkdef bleeds to the global scope
08:12mpanas in, a didn't need to be def'd
08:12mpanyou could just as well have created an atom in local scope and done the same things to it
08:13mpanas in, my example could be entirely rewritten with a let
08:13mpanand they're just plain atoms, so you could hand them around as you like
08:14josteinkmpan: I think youve missed my two pastes so far
08:14josteinkwhich shows you that Ive already solved this using an atom :P
08:14mpanit's very similar
08:14mpanand I was saying, you can use an atom
08:15mpanbut you didn't need to go and make something special to "get this"
08:15josteinkanyway
08:15josteinkthanks for the help
08:15mpanis the point I was trying to make
08:15josteinkbut you can stop
08:15mpanok
08:15mpanhope it was useful for you
08:15josteinkI see that to reference yourself you need to trick around with atoms
08:15josteinkyes yes
08:15josteinkabsolutely
08:15josteinkbut you went on far beyond what was needed ;)
08:16mpanI hope you get my bigger point, though, which is that sometimes it's not very clean/nice to try to convert java verbatim
08:16mpananyway have a nice day then
08:16josteinkfunny how clojure which makes so many things so short and conssce, makes a simple "this" into voodoo :P
08:16josteinkmpan: scheme vebratim actually
08:17mpannow you've got me curious
08:17mpanwhat are you doing in scheme?
08:17josteinkread SICP, chapter on constraint-based programming
08:17FoxboronSICP contains Scheme examples
08:17mpanok thanks
08:17mpanI was just wondering specifically which feature of scheme you were using for this
08:18josteinkI was using scheme's ability to reference anything
08:18josteinkeven things which doesnt exist yet, like one-self
08:18mpanwe messed around with the language briefly for school but I didn't go very deeply into it
08:18josteink(define (test x) (define boo '(x boo)) boo)
08:18josteinkis valid scheme code
08:19mpanthat's quite interesting to see that done with arbitrary values
08:19solussdjosteink: how about alambda (from on lisp)? from my repl: https://www.refheap.com/paste/7022
08:21josteinkthanks but no thanks
08:21josteinkI got what I need sorted out
08:21solussdk
09:10gfredericksare there yet good enough CLJS libraries that using jquery is not the best way to get stuff done?
09:11abpgfredericks, I like jayq and mpenet is working on it.
09:11abp$google jayq
09:11lazybot[ibdknox/jayq · GitHub] https://github.com/ibdknox/jayq
09:11mpenetjaq is fine, and you are likely to use jquery plugins anyway, so why not use it.
09:12gfredericksI think I considered that equivalent with jquery; what does it do that isn't a thin jquery wrapper?
09:12mpenetjayq*
09:12mpenetplays well with compilation mostly
09:12mpenetand add some sugar here and there
09:12mpenetbut being thin is kind of the point I think.
09:12abpgfredericks, not much, but it's a neat wrapper and I consider jquerys event-handling stuff quite usable.
09:12gfredericksdoes it include an externs file?
09:13mpenetno but there is a link to externs in the readme
09:13gfredericksah cool; k thanks
09:13mpenetangular is also an option but it all depends on what you need to do really
09:13abpmpenet, do you maintain jayq or are you just filling some gaps for your needs?
09:14mpenetI maintain it. And try to improve it where I can
09:14abpmpenet, cool, glad to hear that. Theres much of Chris work laying around.
09:14mpenetI have been fairly active on it lately, PR are also very welcomed!
09:16gfredericksman I load up the github page and the last commit message makes me think of monads
09:16mpenetabp: I am trying to get chris to create a github org around some of his cljs project, since he doesn't really have the time to work on them cuz of LT
09:16abpmpenet, yes I've seen that. Some of my work on my libraries will probably be around jayq, too. Something I need or feel a lack of a nice api will be pulled instantly when present. :)
09:16mpenetgfredericks: well some of the last commit are inspired by monads :p mostly to make some sugar, you are not really exposed to the dirty bits though, no need to fear!
09:17gfredericksI like monads actually, but they're fun to make fun of
09:17mpenetgfredericks: you might like the latest additions then: see do-> in macros.clj
09:17gfredericksmzero must be monoids though, right?
09:17abpmpenet, and he doesn't even got time to do that? Light Table must really be consuming his time like nothing before. Passion can be really forceful.
09:18mpenetgfredericks: it's not 100% "lawfull", it's stuff inspired from roylang mostly
09:18mpenetabp: he seems to be really busy
09:18gfredericksillegal monad usage?
09:18mpenet abp: and it's understandable imho
09:19gfredericksmpenet: why shouldn't the externs file be packaged with the lib?
09:19abpHm, any thoughts on pulling parts of libraries out of clojures contrib libs? The new ones. Theres something in tools.namespace I would like to get standalone and work further on..
09:19mpenetgfredericks: no type system, some "monads" can be hairy fast
09:19mpenetgfredericks: see the tracingMonad from roy for instance
09:19abpmpenet, sure. Got a good cash-backing for burning his time on his ideas. I need that, too. ;)
09:20mpenetgfredericks: it's called a monad, looks like a monad, but isnt really one
09:20mpenetgfredericks: http://roy.brianmckenna.org/
09:20abpmpenet, looking forward to Typed Clojure on cljs? Eases your monads.
09:20abpProbably..
09:21mpenetabp: seems like an interesting project, yes
09:23mpenetgfredericks: about the externs, jayq can be used with a lot of different jquery versions
09:23mpenetgfredericks: and including all of them with jayq didn't seem to be the right thing to do
09:24mpenetgfredericks: I could be wrong though. Also showing where to get them also helps if you need one for underscore.js backbone.js etc since they are all listed at the url indicated in the readme
09:30gfredericksmpenet: would it be silly for somebody to post jquery jars to clojars?
09:30mpenetI think there is a project that does just that already, with jquery and other libraries
09:31mpenetgfredericks: not sure about externs tho
09:33abpCan I check which wich symbols in a given s-expression will evaluate to something via macros?
09:34gfredericksabp: wat?
09:35abp,(resolve 'foo)
09:35clojurebotnil
09:35abp,(resolve 'map)
09:35clojurebot#'clojure.core/map
09:35abpgfredericks, I think that's the answer
09:35gfredericksah ha
09:37abpgfredericks, finding out which symbols get resolved to vars. I need that to further reduce my graph declarations. Will show you a gist soon if you like to see the mess. ;x
09:38gfredericksokay, so if I call (.method ...) on a jquery object, I am doing it wrong
09:38gfredericksI have used jayq in the past and did not realize that
09:39mpenetgfredericks: http://www.webjars.org/ for the mavenized js stuff
09:39gfredericksmpenet: thanks
09:40gfredericksmpenet: fascinating
09:41gfrederickswoah; I can (:require [jayq.core :as $ :refer [$]]) can't I?
09:41mpenetgfredericks: never used if myself
09:41mpenetgfredericks: I am not sure it's a good idea to miz as and refer
09:41mpenetmiy
09:41mpenetmix
09:41mpenetdamn fingers
09:42gfredericksmpenet: do you know any reason why that would be? or you just haven't tried it?
09:42mpenetgfredericks: you probably want :refer if you are just after $, I almost always use [:as jq]
09:42mpenetgfredericks: never tried it
09:43mpenetgfredericks: but that would mean $/$ to get to jquery.fn.$, feels a bit odd
09:43gfredericksmpenet: I want both :D
09:43gfredericksmpenet: no I expect just $
09:43mpenetgfredericks: oh right
09:43gfredericksI just wrote ($/append ($ "body") ...)
09:43gfrederickswhich I think is slick
09:43mpenetgfredericks: try it, but I'd be surprised if it works
09:44gfredericksI expect this would work in clj-jvm at least
09:44gfredericksI know cljs is a bit rougher in the ns departement
09:44gfrederickswell it compiled
09:44abpgfredericks, you're crazy. :D
09:45gfrederickswell the code didn't run but I think it's cljsbuild being borky
09:47gfredericksconsarnit
09:47gfredericksstill emitting my namespaces in the wrong order
09:48mdeboardI need an "accumulator", a var that is defined globally as nil, but inside a function it is incremented by a value, e.g. https://gist.github.com/4154582 .. I know this is awful so please withhold vomit to the best of your ability.
09:49mdeboardI'm not really clear on how to locally bind accum and increment it as required
09:49gfredericksmdeboard: why do you need it to be a global? why not a local atom at least?
09:49mdeboardgfredericks: I don't need it to be
09:49mdeboardjust a supposition on my part
09:49mdeboardprobably wrong :)
09:50abpmdeboard, then why would you even mutate something?
09:51gfredericksmpenet: it seems to have compiled correctly; still not running how I expect but that's likely a separate issue
09:51mdeboardabp: Because I'm porting a piece of software from C# and I need to duplicate a particular component which does this. I want to get it duplicated for testability, so I can modify it later
09:52gfredericksusing a local would have different behavior for sure, if you're at any point running this function from two different threads
09:52mdeboardThe original C# is iterating through a hex "fingerprint" in an unusual way, and I'm trying to duplicate that exact behavior
09:52abpmdeboard, ok. But you probably want to rewrite it properly from the beginning. You could produce test-cases with the old implementation.
09:53mdeboardgfredericks: The original uses a thread-local, I think the reason I was making it global was because I poorly understood something I read
09:53mdeboardgfredericks: The thing being `(def ^:dynamic...)`
09:57gfredericksmdeboard: yeah I'd do (let [state (atom 0)] ...) at the very least
09:58gfredericksbetter to rework the algorithm to not be stateful
09:59gfredericksjayq.util/clj->js will be in cljs core soon, right?
09:59gfredericksor already is?
10:05mdeboardgfredericks: What's an algorithm? I'm a web developer
10:05abpgfredericks, in master, if I missed no cljs release. mpenet again: https://github.com/clojure/clojurescript/commit/cd66e6b9e63ad5ef1896a9c7a117148beb04301d
10:05gfredericksmdeboard: you're translating C# that can't be _too_ true
10:09gfredericksis cljsbuild emitting stuff out of order a bug in the compiler itself? that was already fixed? so if I just use cljs HEAD then cljsbuild should work correctly?
10:10abpgfredericks, http://dev.clojure.org/jira/browse/CLJS-282
10:11gfredericksabp: so...yes? :)
10:11abpgfredericks, we need master released now! But I think dnolen wants to finish source maps for cljs first, so on release we're all stunned and can't develop anything anymore.
10:11gfredericksah ha; okeedokes
10:11gfredericksthanks
10:14abpgfredericks, that was a joke. But hopefully one that gets true.
10:16mpenetgfredericks: the next release will happen soon I hope, I think we are mostly waiting on source maps support to be complete
10:17abpgfredericks, https://gist.github.com/4142595 exk-calls in exg are my awful unbound symbol search macro.
10:19abpI don't know if I really want to include that. Can make debugging awful.
10:21cemerickmdeboard: that's what the PDF is for ;-)
10:21mdeboardoh yeah, hm
10:21abpmdeboard, or cemerick :x
10:21cemerickeh?
10:22abphe can just look everything up in you!
10:22mdeboarddisturbing
10:22cemerickI've forgotten it all.
10:22abpoh, then don't care. write another clojure book to refresh. :P
10:23cemerickIt's like having to read your own documentation or googling for a topic that brings up your own blog post, but way, way more disturbing.
10:23mdeboardDamn, I don't think I used my o'reilly account to buy the book
10:24mdeboard== no pdf
10:24abpmdeboard, ask them, they can be really gracious. Just for future paper-independence.
10:25mdeboardI may
10:25cemerickmdeboard: IIRC, if you bought just the dead-tree version, you can get the PDF for $5 or something.
10:25abpcemerick, yes, just like when people work on projects or something. External facilities guard all the knowledge.
10:25clojure-newbhey guys, in a compojure app I'm destructuring a path param with [id], how do I get a header 'foo' in the same mechanism without reverting to manipulations of 'request' or is that not possible ?
10:26uvtccemerick: the best is when it takes until you're in the middle of reading it until you realize that you're the one who wrote it. :)
10:28cemerickuvtc: that always makes me feel like an idiot :-P
10:28abpclojure-newb, https://github.com/weavejester/compojure/wiki/Destructuring-Syntax see [x y :as r]
10:29clojure-newbabp: thx, I'll take a look
10:30abpcemerick, do you work with Clojure at your Snowtide? On PDFTextStream? Or is that a business secret? ;)
10:30mdeboardoh my god
10:31cemerickabp: PDFTextStream was largely built ~2003-2005, definitely predating Clojure.
10:31mdeboardI am in PDF hell right now
10:31abpcemerick, ah ok. Didn't know that.
10:31mdeboardI live in PDF hell
10:31cemerickThat said, 99% of the code I've written since summer of 2008 is Clojure.
10:31mdeboardcemerick: How familiar are you with Callas, itext, etc.
10:32cemerickmdeboard: is this a book issue you're struggling with?
10:32mdeboardThe C# code I'm porting right now is all about workig with PDFs
10:32mdeboardyes
10:32mdeboardwe use itext to extract the word/paragraph/line data
10:32cemerickCallas? You mean Calais?
10:32mdeboardSure
10:32cemerickSure, I've tinkered with OpenCalais some.
10:32mdeboardIs it really Calais? LOL. I'm just basing the spelling off of how people pronounce it
10:33abpcemerick, wow. I just get to work with it at work after one and a half year of discussion.. Do you do contracting work or own projects?
10:33mdeboardAnd no, I mean Callas http://www.callassoftware.com/callas/doku.php/en
10:33cemerickmdeboard: FWIW, many, many PDFTextStream customers were prior users of iText and PDFBox. ;-)
10:33mdeboardWe use a wide swath of open-source and proprietary libraries
10:33mdeboardbabilen: indeed
10:34cemerickah, no, I've never used Callas
10:34mdeboardvous avez caillou, calais
10:34mdeboardcemerick: The itext api is ... unusual
10:35cemerickI've never had much contact with preflight, prepress, pdf generation generally
10:35mdeboardcemerick: That's our bread and butter. We're not a content company, but we serve content from textbook publishers, and all they know is PDF.
10:36cemerickabp: I used to do some consulting around PDFTextStream through ~2008, but nothing since then. Mostly been building other (failed, so far) products since then, in addition to open source work, writing, etc.
10:37cemerickmdeboard: Sure. We have a few publishers that use PDFTextStream to improve accessibility in various ways, but I don't know the details of what they've built on top of it.
10:37mdeboardis there some combination of "doseq" and "while" out there
10:37mdeboardcemerick: Interesting, accessibility is our big push right now.
10:38cemerickmdeboard: BTW, confirmed that the PDF of 'Clojure Programming' can be had for $5; just log into your account, add the print version to "your products", and hit the 'upgrade' button.
10:38mdeboardyeah I'll have to do it at home, I assume I need some serial number from my copy of the book
10:39TimMcmdeboard: You could consume from a blocking queue. What exactly do you want?
10:39cemerickmdeboard: shockingly, you don't
10:40mdeboardTimMc: See lines 6-7 and 21
10:40mdeboardhttps://gist.github.com/1e317858ac546d133c03
10:43mpenet,(doseq [i [1 2 3 ] :while (< i 3)] (print i))
10:43TimMcTHat actually doesn't look so bad.
10:43clojurebot12
10:43TimMcI found it fairly readable, although I don't know what the fingerprint stuff is about.
10:43mdeboardTimMc: Me either
10:44TimMc>_>
10:44TimMcWait, nth can be ternary?
10:44TimMc(doc nth)
10:44clojurebot"([coll index] [coll index not-found]); Returns the value at the index. get returns nil if index out of bounds, nth throws an exception unless not-found is supplied. nth also works for strings, Java arrays, regex Matchers and Lists, and, in O(n) time, for sequences."
10:44mdeboardyeah
10:44cemerickmdeboard: oh, it can't be _that_ bad
10:45mdeboardcemerick: We're hiring, come see for yourself!
10:45TimMchaha
10:45cemerickha ha ;-)
10:45mdeboardsee what I did there
10:45TimMcThat's an enticement if I ever heard one.
10:46devnemacs-live overrides C-v and M-v?
10:46devngah
10:46TimMcmdeboard: Oh, I see -- you're porting code.
10:46mdeboardTimMc: Yes
10:46mdeboardfrom the original greek
10:47TimMcFrankly, the lexical shadowing bothers me more than the while/atom.
10:47mdeboardI actually like C# but we don't have any windows devs anymore
10:47mdeboardlexical shadowing?
10:48mdeboardI have no idea what that is
10:49uvtcmdeboard: a local in an inner scope shadowing one in an outer scope?
10:49chronnodevn: yep, it changes some of the default bindings... take a peek into default-bindings.el
10:49TimMc"i" serves double duty in your fn (argument and local), as does "fingerprint" (fn name and local)
10:49devinuswhat other sql modelling libs are there out there other than Korma?
10:50mdeboardTimMc: Oh, right, definitely poor variable naming
10:50nDuffdevinus: SQLAlchemy has its own declarative layer these days
10:50devinusnDuff: oh, i was referring to clojure specific
10:51technomancydevn: wat
10:51chronnodevn: C-w was another surprise for me
10:51devntechnomancy: yeah i couldn't believe it either
10:51devnchronno: yeah, wtf
10:52nDuffOh -- sorry.
10:52devnchronno: yeah, i just went through and fixed those bindings, but man, that's pretty opinionated. Overriding default bindings is a user pack, not the default IMO
10:53TimMcmdeboard: doseq walks i over the indexes of fingerprint, and then the last line walks to that index+1 in fingerprint and pulls out the value. Why not just iterates over the contents of (concat (rest fingerprint) [(last fingerprint)])?
10:53devnsame deal with this rainbow paren stuff and the replacement of fn with ƒ and so on
10:53TimMcdevn: fn-replacement also screws with line length
10:53Mr_Bondƒ is pretty cool
10:53TimMcIt's good only for demos.
10:53chronnodevn: yep, I guess it suits people not used to emacs but for more seasoned users its surprising (and annoying, the first time)
10:53devinusyeah the fn replacement stuff by default made me scratch my head
10:54uvtcdevn: your views on emacs-live intrigue me and I wish to subscribe to your newsletter.
10:55technomancyit also eschews basic packaging hygiene
10:55mdeboardTimMc: Good question. I'm kind of flailing here porting this algorithm over step-for-step, the code's hideous for sure.
10:57TimMcmdeboard: No need to call (seq (hex 12)) -- map will call seq for you/
10:57mdeboardI see
10:58sundbphi - after exiting an emacs session using nrepl I get a lingering jvm process. any tips for how to avoid this?
11:00sundbpseems to spawn 3 subprocesses for the nrepl session, java -client, which spawns java -cp which in the end spawns the actual process doing the work. it's the last process that remain after exiting emacs
11:00ucb:D
11:01abpuse eclipse
11:01mmitchellis it possible to have a dependency, which contains "resources" that you can "merge" into your project's resources directory?
11:01sundbpif there was a nice nrepl and debugger experience i would. using emacs with evil mode, use vim except for clojure work.
11:02sundbpemacs+evil gets things comfy enough that it's comfortable. even got my vi foot pedal hooked up :)
11:02jweisstrying to set up emacs/nrepl/autocomplete - something seems to be showing completions for the nrepl buffer even though auto-complete-mode is not on. i want the popup box for completion, not the separate window. anyone know what is doing that?
11:02Mr_Bondsundbp: we actually have a usb-pedal here :)
11:02abpsundbp, regarding java processes not being killed, I think that's a more fundamental problem than editor choice.
11:02Mr_Bondfor our robotics projects :P
11:03Mr_Bondfound it on dx
11:03sundbpabd: this is oracle downloaded jdk on ubuntu. not the openjdk one.
11:03sundbpMr_Bond: mine is a 3 pedal usb device that was like 25usd or something similar. cheap enough worth the play :)
11:04abpsundbp, jdk version neither, more like clojure tooling ;x
11:04cemerickmmitchell: yes, though there's no packaging standard for such things. I've been packaging resource artifacts under a /_rsrc "package", which the ring-resources handler can be configured to look under.
11:09sundbpabp: yes, my bet is somewhere between emacs, nrepl.el and nrepl lies the answer, someone isn't properly killing their children
11:10mpanI see I picked an awkward time to enter the channel
11:15thorwilhmm. how to handle a dependency like the aloha editor. should i just add the whole thing to my git repo? or maybe just a bash script to fetch it and put it into place?
11:16balinthey,
11:16balintI would like to help out with some "entry-level" clojure OS projects
11:16barfuINFO chouser
11:17balintI say entry-level because I'm not -yet- an expert clojure programmer
11:17balintdo you know any ones that need help?
11:17balintI checked the ones on http://clojurewerkz.org/ but they don't seem to have any open issues
11:19duck1123mmitchel_: You might want to check out webjars.org to see how they use resources directories to package js libs
11:19uvtchi balint . I suppose it depends somewhat on what you're interested in.
11:20balintuvtc: i'm proficient with web-related stuff so noir/ring are good candidates
11:20balintbut they seem to be somewhat abandoned
11:21mdeboardwut
11:21uvtcbalint: I think the author of noir is working full-steam on LightTable at the moment.
11:21mdeboardDidn't raynes take over noir?
11:21mdeboardor am I thinking of korma
11:22balintstorm is another fascinating one but at first glance it's too complex to grok
11:22clgvmdeboard: Raynes did some refactoring and pulled out a lib from noir that contains functions that are useful for non-noir projects as well
11:22clojurebotlibraries is http://clojure.org/libraries
11:22balintuvtc: yes, I believe so, too
11:22technomancycompojure and ring are definitely not abandoned, but they're just small enough that there's not a lot of ongoing feature work on them
11:22uvtcI think Raynes was doing some work on https://github.com/noir-clojure/lib-noir .
11:23balinttechnomancy: ok, got it
11:23uvtcbalint: you might poke arond http://clojure-doc.org/articles/ecosystem/libraries_directory.html for some ideas.
11:28abpI didn't know about:
11:28balintuvtc: great, thank you
11:28abp,(conj {:a 1} {:b 2})
11:28clojurebot{:b 2, :a 1}
11:28reikalus1kkais rlwrap essential for clojure development?
11:29nDuffnot _essential_, no.
11:29nDuffif you're using emacs + nrepl/slime, it's completely unimportant
11:29nDuffbut having some kind of a nice REPL environment is important.
11:30uvtcreikalus1kka: if you're using `lein repl`, I think it comes with everything you need.
11:30reikalus1kkaokay. I'm not completely sure what I need or how I should set up my development environment
11:30uvtcreikalus1kka: http://clojure-doc.org/articles/tutorials/getting_started.html
11:30reikalus1kkaI run the command lein repl and I got the message Using JLine for console I/O; install rlwrap for optimum experience.
11:31nDuffreikalus1kka: ...so, a lot of this depends on what kinds of keybindings/keystrokes you're accustomed to expecting.
11:31nDuffreikalus1kka: if everything you expect works (ctrl+a, ctrl+k, etc etc), then you're good.
11:31nDuffreikalus1kka: ...if you're going to be using something more capable than "lein repl" for most of your experimentation, then you're also good.
11:31reikalus1kkawhat should those keybindings do? xD
11:32reikalus1kkaI plan to use sublime texeditor for writing code.
11:32reikalus1kkatexteditor*
11:32duck1123reikalus1kka: You might want to look into updating your lein version. But having rlwrap doesn't really hurt much and is handy to have around
11:32S11001001reikalus1kka: the readline defaults are based on emacs defaults.
11:32nDuffreikalus1kka: does sublime have any kind of REPL integration or paredit support? I'm not saying not to use it, but you might be missing out on a lot.
11:32S11001001reikalus1kka: never used rlwrap in ~2yrs of professional clojuring, but I used emacs, so...
11:33nDuffreikalus1kka: ...a good LISP-aware editor can do some beautiful things.
11:33S11001001reikalus1kka: anyway, readline is wildly configurable with respect to keybindings.
11:33reikalus1kkaI don't think sublime has it and I didn't know I need to use it. I never used emacs and I feel too dump to use it. and I have no previous experience in any lisp dialect
11:34reikalus1kkaI'll check out readline
11:34uvtcreikalus1kka: "readline" means making your repl keyboard shortcuts act like a regular GNU/Linux bash terminal.
11:34S11001001reikalus1kka: (readline is the library that rlwrap uses)
11:35uvtcreikalus1kka: when just starting out, you can just use a terminal window along with your text editor.
11:35nDuffreikalus1kka: if you _do_ decide to try emacs at some point in the future, look at "Emacs Live" for an out-of-the-box configuration with everything you need to be productive (and videos/presentations showing what it does / how to use it).
11:37abpAny ideas on how to write macros with the semantics of fn? I need to preprocess the arguments to the function, but everything else is just fn.
11:37reikalus1kkaokay. I'll put that behind my ear
11:37reikalus1kkaI will be happy if I can just get started
11:37S11001001abp: expand to fn.
11:37S11001001abp: e.g. (fn [gensyms...] (let [fn-args use-gensyms...] body...))
11:39abpS11001001, sure, but I need to correctly take the arguments fn takes too, access the argument vector and pass it along. I already got a dumnded down version, but there is a meta-map to be supported etc.
11:40S11001001abp: if you want full fn, you need to parse enough of the destructuring language to get what you need without breaking stuff
11:40S11001001essentially that just means knowing what & does
11:40abpS11001001, Destructuring doesn't matter. :)
11:41S11001001well, there's nothing really special about writing fn variants otherwise.
11:41abpS11001001, so not quite all what fn does. Mostly meta/name/rgs, no meta/name/args, no meta/no name/args etc.
11:42S11001001you've got string?, symbol?, vector?, map?
11:45bordatouehello
11:45bordatoueis it possible to create a local binding that maintains state in clojure.
11:48nDuffbordatoue: could you be a little more explicit?
11:49nDuffbordatoue: ...I mean, it's possible to update a thread-local dynamic var, or to modify root bindings, but more background would be helpful to understand the right thing for your use case.
11:49bordatouei would like to have a procedure that returns another procedure modifying the binding of the first procedure
11:52nDuffbordatoue: ...well, you can only modify a thread-local binding that's actually valid while you're being called, so the context in which the the returned function is invoked matters.
11:53nDuffbordatoue: within that caveat, nothing's stopping you.
11:53bordatouenDuff: for example http://hastebin.com/rimigojuke.cs
11:53nDuff...okay, I think I misunderstood your question, then, if that snippet has anything to do with it.
11:54bordatouenDuff: how do i update the value bound in the outer procedure
11:55nDuffbordatoue: ...first, define a dynamic var outside of the outer procedure, bind it _in_ the outer procedure, and alter its binding in the inner procedure.
11:55nDuffthat last piece is done with var-set
11:56bordatouenDuff: http://hastebin.com/cavawaveke.cs
11:56nDuff...
11:56bordatouenDuff: if i define a dynamic var then won't that be accesible to other procedures
11:57nDuffHuh?
11:57jondavidjohnCould I bother any clojure guru's in here to take a look at one of my first clojure attempts, and give it a critique? http://codereview.stackexchange.com/questions/19073/first-go-at-clojure-and-functional-programming-in-general
11:57nDuffbordatoue: That's not true at all. Where do you have that idea from?
11:57duck1123In your mind, whenever you find yourself thinking "I need to update..." replace it with "I need to return a new copy of..."
11:57nDuffbordatoue: ...unless you mean you want it to still be callable after the scope of the outer binding exits; that's true enough.
11:57bordatouenDuff: i am trying to create an object model using procedures
11:58nDuffbordatoue: if that's the case, you might want to bind an atom.
11:58nDuff...actually, don't need a var at all at that point.
11:58nDuff...pass the atom around, and it can be eventually returned.
11:58bordatouenDuff: okay so its an atom ,
12:00bordatouenDuff: i need to read on atom , what does that mean futher decomposition is not allowed
12:00nDuffbordatoue: ...pardon?
12:01bordatouewhy is it called atom if we can mutate it , is it like CAS operation
12:01nDuffbordatoue: yes, individual changes to the atom are serialized and atomic.
12:02seangroveIf in my cljs I require a non-existant namespace, shouldn't it complain at compile time that it can't find it? My test code just happily goes along with it
12:03seangroveThe compiled output from the cljsbuild test that I'm trying to build just has the goog-closure library with the test code appended - none of the required namespaces are included between them
12:04seangroveSo when the test (ns example.hello.test (use [example.hello :only [work-you-bastard!]])), in the output.js it goog.provides("example.hello.test") right after the goog closure code, then goog.requires("example.hello"), which isn't in the output
12:04seangroveI can't figure out what I'm doing incorrectly
12:05duck1123seangrove: what level of compilation are you using? IIRC, it only complains at the higher levels
12:05bordatouenDuff: can you recommend any way i could create a local fn that would maintain local state, i don't want idempotent fn calls
12:05seangrovewhitespace
12:06seangroveFor the :test build, it's supposed to add the source-path of all other builds, so that requires work properly. It works in the cljsbuild advanced project example, but the same process doesn't work on a different project
12:07lucianbordatoue: the simplest way around is to always pass in and return that state
12:07lucianbordatoue: the other might be an atom
12:07nDuffbordatoue: one way to do that is for your function to close over an atom. Really, though, trying to do that is indicative of trying to do things "the wrong way".
12:08bordatouethanks lucian , nDuff .
12:09bordatouenDuff: i can't understand your view on saying "the wrong way", say if you want some local state to be maintained then?
12:09bordatouei am not talking about maintain a global state , just locally to a procedure
12:09nDuffbordatoue: keeping local state inside your functions is considered bad practice here.
12:10bordatouenDuff: is that specific to clojure or functional programming in general
12:10seangrovejondavidjohn: Just syntax-wise, I believe that (map (fn [p] []) (range num_piles)) is equal to (map #{[]} (range num_piles))
12:11nDuffbordatoue: functional programming in general -- one of the Big Ideas is that state should be kept in well-understood places and modified only in well-understood (and observable) ways. Hiding little bits of state all over the place makes reasoning about your logic harder.
12:11lucianbordatoue: if you think about it, state local to a function is exactly the same as an argument
12:11seangrove,(map (fn [p] []) (range 4))
12:11nDuffbordatoue: ...Clojure provides exceptionally good tools for managing state in this way.
12:11clojurebot([] [] [] [])
12:11seangrove,(map #{[]} (range 4))
12:11clojurebot(nil nil nil nil)
12:11seangroveNope, I was wrong, heh
12:11jondavidjohnyeah, I tried that, and it was complaining about wrong number of args
12:11lucianbordatoue: but the argument makes it much clearer about what's going on
12:11jondavidjohnpassing hte p made it work
12:13jondavidjohnfor speed considerations, should I make each "pile" a transient also?
12:13jondavidjohn,(map (fn [p] (transient []) (range 4))
12:13clojurebot#<ExecutionException java.util.concurrent.ExecutionException: java.lang.RuntimeException: EOF while reading>
12:13jondavidjohn,(map (fn [p] (transient []) (range 4)))
12:13clojurebot#<ArityException clojure.lang.ArityException: Wrong number of args (1) passed to: core$map>
12:13jondavidjohn,(map (fn [p] (transient [])) (range 4))
12:13clojurebot(#<TransientVector clojure.lang.PersistentVector$TransientVector@6fc01c8f> #<TransientVector clojure.lang.PersistentVector$TransientVector@2d93299a> #<TransientVector clojure.lang.PersistentVector$TransientVector@189054d6> #<TransientVector clojure.lang.PersistentVector$TransientVector@2bb1ba33>)
12:14jondavidjohnand will (persistent! parent) follow and "persistantize" each element if they are transients also?
12:14Chousukeno
12:15Chousukedon
12:15Chousukedon't optimise too much before you actually have a problem
12:15jondavidjohnright, just trying to get a best practice approach from the word go.
12:15Chousukeif you are making very large vectors, use transients for those.
12:16Chousukeand never let transients escape the function where you use them.
12:16Chousuke(you will know when to break that rule.)
12:16jondavidjohnI'm actually trying to make a comparison to a python c extension I wrote for this same algorithm, speed wise.
12:17seangroveduck1123: I think you're write about advanced mode
12:18jondavidjohnso If I wanted to transient all the "piles" I would maybe do something like (persistent! (map (fn [p] (persistent! p) parent)
12:19Chousukeyou can't do that.
12:19Chousukesince map will not return a transient
12:19Chousukeyou will have to loop explicitly.
12:19Chousukebut I don't think it's worth it.
12:19jondavidjohnso if I map a transient, will it return a persistent list?
12:19Chousukeyou can't use map on transients.
12:19jondavidjohnor you simply can't map a transient
12:19jondavidjohnok
12:20Chousukein general, transients should be a local optimisation
12:20Chousukefirst make your code work without them
12:20Chousukethen, if performance is an issue, add transients.
12:20jondavidjohnright, and it is currently
12:21Chousukehow large are your vectors?
12:21jondavidjohnsince I'm trying to make it compete with my c implementation, every ms counts... I know in the practical world what you're saying makes sense, but as an experiment and learning...
12:21jondavidjohnit's going to be a library, so however large the user wants them to be.
12:22jondavidjohna library of different types humanoid shuffles
12:22Chousukeno, I mean, how large do you expect them to be, relative to each other?
12:22jondavidjohnequal
12:22Chousukewill you have thousands of piles each containing thousands of items? :/
12:22jondavidjohnif that's what the user wants ;)
12:22jondavidjohnbut realistically probably not
12:23Chousukealso, will this vector of piles be constructed all in one go?
12:23Chousuketransients are only useful if that's the case.
12:23jondavidjohntake a look at my full function here... http://codereview.stackexchange.com/q/19073/2776
12:27Chousukejondavidjohn: your problem there is that you're not making the piles themselves persistent. also the concat operation looks suspicious
12:27seangroveIs the author of cljsbuild ever in here?
12:28Chousukejondavidjohn: moving things like (count cards) outside the loop might help a slight bit too, especially if cards is not Counted
12:28jondavidjohnI was under the impression that I'm the parent vector of piles (vectors) a transient, but each individual pile was persistent
12:29Chousukeoh, right, I misread your code
12:29jondavidjohnwould it be better to make each pile a transient and leave the parent as a persistent?
12:30jondavidjohnsince I'm associng on the pile and not the parent
12:30Chousukejondavidjohn: the problem with that is that you still have to update the parent with the new pile when you assoc to the transient
12:30seangroveThis just doesn't seem to be true, locally: "Note that all of the :source-path entries from the :builds are added to the classpath, so the tests can :require ClojureScript namespaces from, e.g., the src-cljs directory"
12:31jondavidjohnok
12:31Chousukejondavidjohn: since assoc on a transient is not guaranteed to return the same object
12:31jondavidjohnso with the count, wrap the loop in a let and assign the card count once there, and use it within the loop?
12:32jondavidjohnand I'm using the concat to push new items on the front of the pile, the opposite of conj
12:32Chousukejondavidjohn: btw you can replace that map thingy with (transient (vec (repeat num_piles [])
12:32jondavidjohnso (concat [(new item)] [pile])
12:32Chousukejondavidjohn: you should use a list instead of a vector for the piles then
12:32jondavidjohncoool, that looks much nicer
12:33Chousuke(vec (concat foo bar)) is terribly slow
12:33jondavidjohnok, are lists of things more common than vectors of things? and will that impact my usage of vectors elsewhere in the code?
12:34Chousukelists and vectors are for different operations
12:34Chousukelists have fast add to the front
12:34Chousukevectors have fast random access and fast add to the tail
12:34jondavidjohnok
12:34jondavidjohncan you cast a vector to a list and vice versa cheaply?
12:34kaoD_list also have fast (rest )
12:35nDuffjondavidjohn: not cheaply, no.
12:35Chousukea vector becomes a list easily
12:35Chousukebut not vice versa
12:35llasramA vector becomes a *seq* easily
12:35kaoD_Chousuke: are you sure about that?
12:35Chousukea seq is essentially a list in this case
12:35mbcevI thought a vector WAS a seq?
12:35Chousukenah
12:35kaoD_I don't think a vector is easily converted to a list
12:35Chousukevectors aren't seqs
12:35jondavidjohnI'd love it if this function could be somewhat collection agnostic
12:35ChousukekaoD_: lists are just non-lazy seqs
12:35nDuffmbcev: vectors are seqable, but that's not the same as being a seq
12:36kaoD_Chousuke: then a vector CANNOT be converted easily into a list
12:36kaoD_right?
12:36clojurebotto be fair I dunno that I've ever had code out right rejected, it just sits in jira or assembla or where ever, or if I ask if there is any interest (before writing any code) I get told to go write alioth benchmarks
12:36Chousukeokay, well, it can be converted easily into a seq
12:36Chousukebut in this case, it doesn't matter if it's a list or a seq
12:36kaoD_yeah, sorry, I came late into the conversation
12:37Chousukeyou still get fast conj to the front.
12:37kaoD_I'm currently reading jondavidjohn's question at CodeReview
12:37kaoD_cola_zero: but not fast rest, right?
12:37kaoD_oops, sorry
12:37kaoD_Chousuke:
12:37ChousukekaoD_: nah, rest is fast too
12:37kaoD_sure? even for not consed seq'ed vectors?
12:38jondavidjohngood grief clojure has such an esoteric lingo it seems, at least for a noob
12:38ChousukeI'm pretty sure iterating a vector is fast
12:38kaoD_but not as fast as iterating over a list
12:38kaoD_(linearly)
12:38Chousukejondavidjohn: seq is the main abstraction in clojure
12:38Chousukejondavidjohn: it's basically a lazy list
12:38mthvedtjohndavidjohn: is speed a goal?
12:38Chousukeor a generator
12:39jondavidjohnSpeed and generality, which are probably competing interests
12:39nDuffjondavidjohn: what are you trying to do in this code?
12:39kaoD_iterating over a vector needs access to its buckets or whatever it's called
12:39kaoD_resting a list is easy, just strip the head
12:39Chousukejondavidjohn: you can make these seqs out of many things, like vectors, maps, sets or lists, and there are many functions which operate on seqs
12:40ChousukekaoD_: the seq implementation of vector has access to everything it needs
12:40kaoD_but it's slower than a list
12:40jondavidjohnso maybe turn whatever collection is passed into a seq. Is it wierd to take in one type and return a different type?
12:40nDuffjondavidjohn: ...the general abstraction is seqs; they just don't promise that many things other than reading will be fast.
12:40Chousukejondavidjohn: no, if it makes sense to return a seq
12:41Chousukejondavidjohn: in fact, if you can return a lazy seq, it's usually considered good to do so
12:41Chousukejondavidjohn: since then your user can just call your function and take for example the first three things
12:41mthvedti wonder if you can split one seq into several lazy seqs
12:41Chousukeand not pay the cost of getting the lest
12:41Chousukerest
12:41mthvedtin the manner of a pile shuffle deal
12:41Chousuke;|
12:41jondavidjohnso if a user passes me a list to shuffle, wouldn't they expect a list back? or is it common to pass back a lazySeq
12:41nDuffjondavidjohn: ...but what's the actual use case here? It's easier to provide good advice when dealing with specifics rather than generalities.
12:42Chousukejondavidjohn: you would return a lazy seq in that case
12:42devn...emacs-live rebinds C-h
12:42devnwtf.
12:42nDuffjondavidjohn: passing back a lazy seq is common -- improves efficiency, if the consumer only needs part of the list.
12:42Chousukejondavidjohn: since lazy seqs are for all purposes indistinguishable from actual lists
12:42kaoD_nDuff: jondavidjohn just wants to shuffle a "pile"
12:42jondavidjohnnDuff: I'm implementing a "pile shuffle"(http://en.wikipedia.org/wiki/Shuffling#Pile_shuffle)
12:42kaoD_he wants to make a library, so he doesn't know if his users want it lazy or not
12:42llasramjondavidjohn: Most sequence functions just return seqs -- that's definitely the common idiom. The user can then turn that into whatever they want
12:43jondavidjohncool
12:43Chousukejondavidjohn: for example, in clojure it's perfectly fine to do the following (map #(Thread/sleep 1000) (range 100000000000))
12:43Chousukeit will take no time providing you actually don't try to get at the latter items
12:44nDuffHmm. A shuffle algorithm isn't necessarily something that _can_ be lazy, then.
12:44Chousukeyou can imagine Thread/sleep being some hideously expensive computation.
12:44ChousukenDuff: I think there is a lazy shuffle algorithm in contrib somewhere
12:45jondavidjohnconverting to and operating on a seq will take some rewriting? or is the api similar to a vector?
12:45nDuffjondavidjohn: vectors implement ISeq, so if you're operating on the vector using seq operations already, there's no difference.
12:45Chousukejondavidjohn: you have most of the operations available to you except random access
12:46kaoD_jondavidjohn: be aware: you cannot random-access a sequence
12:46kaoD_because, well, it's SEQuential
12:46jondavidjohnChousuke: cool, which I'm not using
12:46Chousukevectors implement Seqable, not ISeq
12:46Chousukeyou can call seq on a vector to get a sequence view to it, but it won't be a vector anymore
12:46clojurebotdoseq is like for, but for side effects instead of values
12:46jondavidjohnhow would I return a LazySeq once I'm done building the new seq?
12:47Chousukejondavidjohn: you don't do that
12:47Chousukeif you were done building a seq, it would not be lazy :)
12:47jondavidjohnhah, right, so is this algorithm even lazyable?
12:47jondavidjohnSo in this case I would just return the seq
12:47ChousukeI have no idea, but I suspect it isn't.
12:47nDuffjondavidjohn: I can think of variants of it that could be, though they'd get more expensive towards the end.
12:47kaoD_jondavidjohn: you just deal cards alternatively into "piles", right?
12:47kaoD_and then stack those piles
12:48jondavidjohnright
12:48FrozenlockIs there a way to use maven-plugins with leiningen?
12:48kaoD_it's mathematically solvable?
12:48jondavidjohnin order, there's probably a way to calculate the new order
12:48kaoD_then if you need speed
12:48kaoD_THAT is your solution
12:48kaoD_since vectors do support pretty fast random access
12:49jondavidjohnright
12:49lucianso a user could pass in a vector and receive back a seq
12:49lucianyou could use the vector as a source as much as you want
12:49mthvedtjohndavidjohn: i think this will work: partition by n for n piles, then return n sequences that map get 1..n
12:49technomancyFrozenlock: no. you can emit a pom with a <plugin> section though I think
12:49kaoD_you could even keep the vector interface and make it still vector-like with random access
12:49mthvedtpartition and map are lazy
12:50jondavidjohnthat would be some pretty hard math
12:50kaoD_jondavidjohn: I don't think so
12:50jondavidjohndealing n cards into n piles (sequentially) and rejoining them
12:50Chousukehm
12:50Frozenlocktechnomancy: thanks
12:50kaoD_it seems like easy math to me
12:51mattmossn-th permutation
12:52Chousuke,(apply interleave (partition 3 [1 2 3 4 5 6 7 8 9]))
12:52clojurebot(1 4 7 2 5 ...)
12:52jondavidjohnso 10 cards using 3 piles end up [10 7 4 1 8 5 2 9 6 3]
12:53Chousuke,(iterate (comp apply interleave) (partition 3 [1 2 3 4 5 6 7 8 9])))
12:53clojurebot#<ExecutionException java.util.concurrent.ExecutionException: clojure.lang.ArityException: Wrong number of args (1) passed to: core$interleave>
12:53Chousukehmm
12:53jondavidjohnto illustrate it better [10 7 4 1 - 8 5 2 - 9 6 3]
12:53Chousuke,(take 1 (iterate (comp apply interleave (partial parition 3)) [1 2 3 4 5 6 7 8 9])))
12:53clojurebot#<CompilerException java.lang.RuntimeException: Unable to resolve symbol: parition in this context, compiling:(NO_SOURCE_PATH:0)>
12:53Chousuke,(take 1 (iterate (comp apply interleave (partial partition 3)) [1 2 3 4 5 6 7 8 9])))
12:53clojurebot([1 2 3 4 5 ...])
12:54Chousukehm
12:54kaoD_jondavidjohn: it's something along the lines of (piles, size) -> [(n) -> (+ (* (/ size piles) (mod n piles)) (/ n piles))]
12:54kaoD_right?
12:54clojurebotto be fair I dunno that I've ever had code out right rejected, it just sits in jira or assembla or where ever, or if I ask if there is any interest (before writing any code) I get told to go write alioth benchmarks
12:54kaoD_fuck you clojurebot
12:55jondavidjohnhaha
12:55llasram&(letfn [(pile [n cards] (->> (range n) (map #(take-nth n (drop % cards))) (apply concat)))] (pile 3 (range 10)))
12:55lazybot⇒ (0 3 6 9 1 4 7 2 5 8)
12:55jondavidjohnan answer on codereview suggests this " (->> (range n) (map #(take-nth n-piles (drop % cards))) (apply concat))"
12:55llasramYeah, that was me
12:55llasramIt got noisy here :-)
12:56llasramOh, actually:
12:56jondavidjohnllasram: that works but it's reversed
12:57kaoD_&(/ 3 21)
12:57lazybot⇒ 1/7
12:57llasramOh, easy enough
12:57kaoD_&(div 3 21)
12:57lazybotjava.lang.RuntimeException: Unable to resolve symbol: div in this context
12:57kaoD_what is the integer division operation?
12:57jondavidjohnto illustrate it better [10 7 4 1 - 8 5 2 - 9 6 3]
12:57Chousuke(I think I have an onelinesr for this now
12:57jondavidjohnwould be the result I'm looking for
12:57kaoD_oooh, you want it REVERSED
12:58kaoD_I get it now
12:58jondavidjohnClojure is some serious ninja wizardry...
12:58kaoD_(since you're dealing it backwards)
12:58jondavidjohndealing form the top of the original deck, but the first card dealt to a pile ends up the last card in the pile
12:58Chousuke,(take 1 (iterate (comp (partial apply interleave) (partial partition-all 3)) [1 2 3 4 5 6])
12:58clojurebot#<ExecutionException java.util.concurrent.ExecutionException: java.lang.RuntimeException: EOF while reading>
12:58Chousuke,(take 1 (iterate (comp (partial apply interleave) (partial partition-all 3)) [1 2 3 4 5 6]))
12:58clojurebot([1 2 3 4 5 ...])
12:58kaoD_&(quot 3 21)
12:58lazybot⇒ 0
12:58Chousukehm, still some error there
13:00llasram&(letfn [(pile [n cards] (->> (range n) (mapcat #(take-nth n (drop % cards))) (reduce conj nil)))] (pile 3 (range 10)))
13:00lazybot⇒ (8 5 2 7 4 1 9 6 3 0)
13:00jondavidjohnhaha, almost, can you deal left to right, instead of right to left?
13:00jondavidjohnsince we're joining the piles left to right
13:00jondavidjohn?
13:00mattmoss&(separate (fn [_] (< (rand) 0.5)) (range 10))
13:00lazybotjava.lang.RuntimeException: Unable to resolve symbol: separate in this context
13:01jondavidjohnI'm sorry, but this is freaking ludicris that you can do that on one line...
13:01mattmoss&(filter (fn [_] (< (rand) 0.5)) (range 10))
13:01lazybot⇒ (0 4 7 9)
13:01mattmoss&(filter (fn [_] (< (rand) 0.5)) (range 10))
13:01lazybot⇒ (0 3 4 6 7)
13:01llasram&(letfn [(pile [n cards] (->> (range n) (mapcat #(take-nth n (drop % cards))) reverse))] (pile 3 (range 10)))
13:01lazybot⇒ (8 5 2 7 4 1 9 6 3 0)
13:01Chousuke,(take 5 (iterate (comp (partial apply interleave) (partial partition-all 3)) [1 2 3 4 5 6]))
13:01clojurebot([1 2 3 4 5 ...] (1 4 2 5 3 ...) (1 5 4 3 2 ...) (1 3 5 2 4 ...) (1 2 3 4 5 ...))
13:02kaoD_Chousuke: you can do these tests in private-msgs
13:02kaoD_(I'm doing it there so it doesn't get noisy)
13:02ChousukeI was doing most of the work in tryclojure actually
13:02jondavidjohnor... you know in an actual repl...
13:02llasramHaha
13:02Chousukethat algorithm is probably horrendously slow for larger decks though
13:03jondavidjohnChousuke: yours or llasram's?
13:03Chousukemine
13:03Chousukeit's too lazy
13:04Chousukeso if you have lots of piles and large decks you get loads of thunks
13:04Chousukeand at some point it will blow the stack
13:04llasram&(letfn [(pile [n cards] (let [cards (reverse cards)] (->> (range n) (mapcat #(take-nth n (drop % cards))))))] (pile 3 (range 1 11)))
13:04lazybot⇒ (10 7 4 1 9 6 3 8 5 2)
13:05jondavidjohnllasram: so close [10 7 4 1 8 5 2 9 6 3]
13:06llasramjondavidjohn: Huh. Why?
13:06jondavidjohnthe last two piles are reversed
13:06llasramOh, I see
13:06jondavidjohnBut the problem is this is very cool, but I can't begin to understand what is happening on that line...
13:09llasramOk, reverse the pile selection order, and swap the reversal back to the end:
13:09llasram&(letfn [(pile [n cards] (->> (range (dec n) -1 -1) (mapcat #(take-nth n (drop % cards))) reverse))] (pile 3 (range 1 11)))
13:09lazybot⇒ (10 7 4 1 8 5 2 9 6 3)
13:11jondavidjohnfeels like magic...
13:11llasramjondavidjohn: It mostly just takes getting familiar with the standard library sequence functions. They are insanely powerful, and because they each return something that the others can consume are easily composable
13:12Chousukefunctional programming with lazy sequences often does look like magic but it's just unfamiliarity :P
13:12lucianjondavidjohn: it's useful to take each bit and give it inputs, see what happens
13:12Chousukealso you should understand that these algorithms are not efficient at all. :/
13:12lucianjondavidjohn: it's partly like syntax in most languages
13:13Chousukeand yeah, looking at what happens at each step is often useful
13:13jondavidjohnyeah, going to take me a bit to digest this, but thanks for all the help and info
13:13luciani don't fully understand that expression just by glancing either
13:13llasramChousuke: I'm pretty sure my function is O(n). The constant multiplier is larger an optimally efficient implementation, but I thinkn the allgo is fine
13:13Chousukejondavidjohn: the point about laziness is that you can work with your data as if you always did the entire operation on the data structure
13:14jondavidjohnright, evaluate as needed
13:15Chousukeit also means you can work with infinite data structures
13:15jondavidjohnback to the day job for me (PHP :p), thanks again for everything..
13:17ChousukeAnd even with all this, clojure's flavour of functional programming is significantly less mind-bending than eg. haskell's :P
13:17ChousukeClojure can do everything haskell does, for the most part, but haskell people actually *use* that crazy stuff.
13:17seangroveI'll have to give up on testing cljs code for now, I've been defeated
13:19dnolenthis is a pretty awesome CLJS series of tutorials - including how to contribute back to the compiler! http://github.com/magomimmo/modern-cljs
13:20SegFaultAXIs cljs/lua dead?
13:25dnolenSegFaultAX: raphael amiard is not actively working on it from what I can tell, but it seems like it's in decent spot for someone else to pick it up if so inclined.
13:26kaoD_jondavidjohn: I still think it's mathematically solvable
13:26kaoD_see this
13:26kaoD_&(map #(let [per-pile (quot 9 3)] (+ 1 (* (mod (- per-pile 1 %) per-pile) per-pile) (quot % per-pile))) (range 9))
13:26lazybot⇒ (7 4 1 8 5 2 9 6 3)
13:27kaoD_it utterly fails with (not= (mod elements piles) 0)
13:27kaoD_but hey, it's not bad for starters :P
13:35uvtcI was asking about Clojure + Android on the ML. I wonder, has there been any movement on having Clojurescript transpile Clojure to Java?
13:35mdeboardwut
13:35technomancyyou mean compile?
13:36uvtcEr, right. Compile Clojure ==> Java.
13:37S11001001uvtc: you don't need that; you can convert jvm bytecode to dalvik bytecode. That's what the scala toolchain does.
13:37technomancyuvtc: you can't represent locals-clearing in Java
13:38uvtcS11001001: I should probably ask about these details on clojure-android...
13:38uvtcS11001001: Thanks.
13:39uvtctechnomancy: What is "locals-clearing"?
13:40technomancyuvtc: without locals-clearing (or TCO) you get memory leaks when using lazy seqs since keeping them in a local prevents them from being GC'd
13:41uvtctechnomancy: ok, related to GC. Thank you.
13:41technomancylocals-clearing emits bytecode to avoid references to unused locals once they're not used anymore
13:41technomancybut the bytecode it emits can't be generated from javac
13:41uvtctechnomancy: oh, interesting.
13:42tomojhuh, I thought it was just "var = null"
13:43TimMctechnomancy: Wait, javac doesn't do locals-clearing? o.o
13:43technomancytomoj: yes, but how do you handle it if the last reference is in a call to another method?
13:43technomancytomoj: you have to null it after it's placed on the stack frame for the call
13:44mthvedtTimMc: javac isn't smart enough to figure out if a reference isn't going to be used
13:44TimMcShouldn't it be?
13:45mthvedtthe general case is a tough problem
13:45technomancynot with the granularity needed to deal with laziness
13:46jonasacjust got reply from the modulecounts.com maintainer today, a couple of weeks ago i suggested he added clojars, and he did :)
13:46TimMctechnomancy: Apparently this is how you do it manually in Java: https://github.com/clojure/clojure/blob/master/src/jvm/clojure/lang/Util.java#L146
13:47TimMcAs seen here: https://github.com/clojure/clojure/blob/master/src/jvm/clojure/lang/RT.java#L521
13:47tomojah, I wondered what that was supposed to do
13:47TimMcSomeone in the channel explained it to me a while back. (Possibly technomancy!)
13:47technomancyTimMc: haha; gross
13:47technomancywasn't me =)
13:48technomancyaw man, that indentation... ugh
13:51hcumberdaleHi ;)
13:51TimMcThey do it that way to make you cringe.
13:51hcumberdaleHow to add custom jars to my project?
13:51mthvedti don't understand how that code would work
13:51hcumberdalethey are not in any maven2 repo
13:52S11001001mthvedt: order of arg evaluation is guaranteed in java
13:52uvtctechnomancy: First shalt thou indent the code. Then shalt thou indent 4 spaces --- no more, no less. Four shall be the number thou shalt count, and the number of the counting shall be four. Eight shalt thou not count, neither count thou two, excepting that thou then proceed to four. Five is right out.
13:53technomancyuvtc: haha; nice
13:53S11001001mthvedt: like common lisp, unlike r5rs scheme
13:53technomancyhcumberdale: first step is to get them into a repository
13:53hcumberdaletechnomancy is it not possible to work with an own lib folder
13:54hcumberdalelike having a "lib/own.jar" dependendy in project.clj?
13:54technomancyhcumberdale: there is no good way to do it
13:54technomancythere are some bad ways
13:54hcumberdaleis there any lein2 functionality to add files to the local m2 repo?
13:54mthvedtS11001001: so the point is to pass the ref to o to countfrom while clearing it on the stack?
13:55S11001001mthvedt: it's not a ref, it's whatever o is. Java is a pass-by-value language; it is merely that so many of those values are references.
13:55the-kennyhcumberdale: lein install?
13:56mthvedtS11001001: right, i meant ref in the java sense
13:56hcumberdalethe-kenny lein install third_party_lib.jar ?
13:56S11001001mthvedt: then yes.
13:56S11001001welcome to wonderful world of side-effects and operation ordering
13:56the-kennyOh, a random jar. Don't think so. I use maven for that
13:56technomancyhcumberdale: a better question might be who is asking you to use a jar without putting it in a repository? because they need to get their act together.
13:56technomancythere's a lein-localrepo plugin to do that
13:57technomancybut it's addressing the symptoms, not the actual problem
13:57mthvedtis there a good way to use reify that supports equality among instances of that reified class
13:57hcumberdaletechnomancy it is a licensed third party module
13:57hcumberdalehanded out as .jar
13:57hcumberdaleto use it in java projects within ant files
13:57hcumberdaleor dirty maven hacks
13:58hcumberdaleso I just want to have a third-party-libs folder in my lein2 project
13:58hcumberdaleto move the jar there
13:58technomancyyou can use localrepo for that
13:58technomancybut you should file a bug report too
13:58S11001001hcumberdale: when we dealt with that, we wrote a pom and added it to our maven repo.
13:59hcumberdaletechnomancy a bug report? why?
13:59hcumberdaleS11001001 then you need an own maven repo
13:59technomancybecause distributing a jar by hand is crazy
13:59mthvedtlike if i have (defn myfn [arg] (reify MyClass …)), is there a succinct way to have (= (myfn "foo") (myfn "foo"))
13:59hcumberdaletechnomancy, that's how big companies like HP work ;)
14:00S11001001mthvedt: = falls back on Object.equals when it doesn't know what to do
14:00S11001001mthvedt: this sucks but is better than nothing
14:00technomancyhcumberdale: you mean poorly? =)
14:01hcumberdaletechnomancy they work just like they work. ;)
14:03technomancyit's lay
14:03technomancylazy
14:03abpA few minutes ago I thought Java and it's ecosystem are only acceptable for large companies which can afford that waste of time. ;x
14:03hcumberdaletechnomancy what's a better way for them to do it?
14:03abpBut they waste even more time. :D
14:03mthvedtS11001001: i'm having trouble coming up with a non-hideous implementation of equals that works for this
14:03hcumberdaleHanding it out with a own maven server?
14:03hcumberdale-a +an
14:04technomancyhcumberdale: right
14:04Frozenlocktechnomancy: I'm trying to write a Lein plugin. It need to run after a uberjar. Any suggestion on which function I should hook myself?
14:04technomancyit can just be a pile of static files on disk behind http basic auth
14:04technomancyno excuses
14:04technomancyFrozenlock: if it needs to run after every uberjar then just hook the uberjar task function itself
14:05technomancyotherwise write an alias that composes the two
14:05FrozenlockGreat, thank you very much!
14:05technomancyno problem
14:05xumingmingv,(loop [input "help"]
14:05xumingmingv (println "xxx")
14:05xumingmingv (print "=> ")
14:05xumingmingv (recur (read-line)))
14:05clojurebot#<ExecutionException java.util.concurrent.ExecutionException: java.lang.RuntimeException: EOF while reading>
14:07xumingmingvwhy the result of these lines of code will be "=> xxxx" rather than "xxxx =>"?
14:07devncemerick: you around by any chance?
14:07cemerickdevn: depends :-P
14:08technomancyxumingmingv: need to flush stdout
14:08devnhaha, i think im missing something w/r/t using friend
14:08devnlet me gist something for you to peek at
14:09xumingmingv(loop [input "help"]
14:09xumingmingv (println "xxx")
14:09xumingmingv (flush)
14:10xumingmingv (print "=> ")
14:10xumingmingv (recur (read-line)))
14:10xumingmingvtechnomancy: like this?
14:12technomancyxumingmingv: please don't paste code into the channel
14:12technomancyyou need to flush after print
14:13devncemerick: i gisted it, but i just discovered i'm missing ring.middleware.reload, and that seems like a likely culprit, investigating that avenue first
14:13xumingmingvtechnomancy: ah, thanks!
14:14cemerickdevn: friend definitely doesn't require the reload middleware
14:14cemerickit does require params, keyword-params, and whatever others are mentioned in the readme
14:15hcumberdalecemerick friend is awesome
14:15cemerickThe compojure handlers/api or handlers/site über-middlewares are both well-suited.
14:15cemerickhcumberdale: :-)
14:21hcumberdalelein localrepo does not work
14:22devnring.middleware.reload -- where have you gone?
14:22devnah, ring-devel
14:28mudgeanybody here use seesaw? When I try to compile my code with lein jar, compiling a file hangs
14:30antares_mudge: it means you have a top-level code that blocks (like starts a server of some kind)
14:31mudgeantares_: thanks, but all I put in my code that hangs it is this: (:use seesaw.core)
14:31mudgeantares_: so mabe on startup seesaw is doing something on the network and so hanging
14:31antares_mudge: you can use VisualVM to create a thread dump
14:36mudgeantares_: i don't really want to download and install that software
14:37antares_mudge: why?
14:37antares_mudge: it's one of the most useful tools in the JVM ecosystem
14:38technomancymudge: vaguely recall a bug like that caused by j18n which seesaw pulls in
14:39technomancyyou can get a thread dump without visualvm; I think swank supports it too
14:43mudgeantares_: good to know, I just have enough software to lean how to use at the moment, but I will probably circle around to VisualVM sometime
14:43hcumberdalehow can I (:require a java class?
14:44mudgetechnomancy: thanks
14:44hcumberdale(:require [my.java.class :as abc]) does not work
14:44borkdudewhat's the deal with new similarly looking statically typed imperative languages for the JVM? http://confluence.jetbrains.net/display/Kotlin/Basic+syntax+walk-through
14:44hcumberdale(:import my.java.class) works, but no alias
14:44mdeboardAnyone know the closest Java analog to C#'s MemoryStream class?
14:45p_lmdeboard: SomethingBuffer
14:48borkdudeHas this been mentioned before here? http://www.infoq.com/research/next-jvm-language
14:48FrozenlockI have some difficulties adding a hook to leiningen in a plugin... could someone take a look at this small test and tell me if I have done something horribly wrong? https://www.refheap.com/paste/7033
14:49mdeboardp_l: I see
14:50antares_Monger 1.4 is released: http://blog.clojurewerkz.org/blog/2012/11/27/monger-1-dot-4-0-is-released/
14:51hcumberdaleis it possible to include a java class with alias in clojure?
14:52antares_hcumberdale: no
14:54mudgewell my class is compiling, it just takes about 2 mintues to compile --- which is so long. Without (:use seesaw.core) compilation is fast
14:55kevin5672How do I go about finding the source of a lein error like this: "Error: Could not find or load main class"
14:55seangroveDoes clojurescript not come with a clj->js? I'm almost certain I've gotten errors saying it does
14:58Raynesseangrove: IIRC it will as of the next release.
14:58seangroveAh, ok, that's fine then, just wanted to make sure I wasn't going mad.
15:07lynaghkping: dnolen, hugod: I just finished up some gnarly record-stuff for doing matching with core.logic: https://gist.github.com/4004131#file_rules.clj
15:08lynaghkdnolen, hugod: in case you guys are interested. Basically the problem I needed to solve was to unify against a subset of the keys of records of a certain type. The solution I found was to make a custom record that behaves like a partial-map, but additionally checks the type of the map it is being unified against.
15:09TimMchcumberdale, antares_: Yes, you can alias a class.
15:10TimMchcumberdale: https://github.com/baznex/imports/blob/master/src/org/baznex/imports.clj#L64
15:11dnolenlynaghk: hmm, looks like your just looking for a specific value for a key in the other map?
15:11hugodlynaghk: interesting! I was considering writing something to allow specification of missing keys in sub-maps (which can't be done now if the sub-map doesn't actually exist)
15:12lynaghkdnolen: yes, that and the type of the other map
15:12dnolenlynaghk: by type do you mean record?
15:12dnolentype of the other record?
15:12lynaghkdnolen: yep.
15:13dnolenlynaghk: I guess that hard to express as two more constraints instead of doing it in the unification?
15:14antares_this series of tutorials on ClojureScript is seriously awesome: https://github.com/magomimmo/modern-cljs/tree/master/doc
15:14dnolenantares_: very awesome
15:14lynaghkdnolen: yes, I think it'd be tricky to do with lvars (though I could be wrong)
15:16lynaghkdnolen: in particular because you need an lvar for the whole record (so you can constrain its type) and lvars that unify with certain keys inside of that record.
15:16dnolenlynaghk: yeah, in anycase, very cool that you were able to solve your problem.
15:17lynaghkdnolen: yeah, it's a long time in coming, so I'm jazzed. Once the constraint map stuff lands I'll be set.
15:18mudgeantares_, technomancy: I did a thread dump and I see that my clojure file with (:use seesaw.core) is compiling so slow because the threads are reading files it looks like
15:18dnolenlynaghk: yep, if you can find a second to do the unify bit, I can work on the constraint map stuff next weekend and next week during my travels
15:19lynaghkdnolen: unify bit?
15:19dnolenlynaghk: or I tackle it as well - just allow the multi-arg unify w/ constraint map last.
15:19dnolenunifier I mean of course
15:20lynaghkdnolen: ohhh
15:21lynaghkdnolen: I did that a few days ago. I guess Github didn't tell you about it: https://gist.github.com/4116442
15:21dnolenlynaghk: sweet!
15:21hugoddnolen, lynaghk: I still haven't fully grokked how/where unifier is meant to be used
15:22dnolenhugod: it's just an api so users don't have to dig into run if they don't want to.
15:22hugodah, ok
15:23hcumberdaledo I need with-open when I use with-in-str?
15:24hugoddnolen: am I right in thinking I'll need to do something similar to lynaghk to unify both {:a {:b 1}} and {} with {:a {:c ::not-found}}?
15:24devnor rather, why it doesn't print in the nrepl buffer in emacs
15:27dnolenhugod: not sure if that applies to what lynaghk is doing - you need to express some kind of `or` there. or I could ponder some kind of (optional ...) wrapper which w/ will unify w/ ::not-found
15:28hugoddnolen: ok - I really want to say that the path [:a :b] in the map is not set, rather than matching the structure
15:29hugod[:a :c] that is
15:29dnolenhugod: sounds like something higher level that can be built on what I described, no?
15:31hcumberdalehow can I convert StringReader to InputStream ?
15:32hugoddnolen: I guess so - unifiying with ::not-found works, and a wrapper for that would be nice not to have to rely on ::not-found directly. I'm not sure how to do the 'or' bit yet.
15:33antares_mudge: that's very strange. I don't even thing seesaw is a large library. Please ask on the mailing list?
15:33dnolenhugod: pondering it some more this could be done w/ path-constraint ... something like (not-setc x [:a :c])
15:33dnolenhugod: I'm not going to add that by I'll try to cook up a gist later that shows how this can be done.
15:34mudgeantares_: thanks, I posted on the mailing list a moment ago: https://groups.google.com/forum/?fromgroups=#!topic/seesaw-clj/OoweKH4AiAY
15:34hcumberdale>> (ByteArrayInputStream. (.getBytes s)) is this really the best way to do this?
15:34hugoddnolen: thanks!
15:38jonasendnolen: another useful feature for the unifier would be segments: (unify [1 ??x 5] [1 2 3 4 5]) would succeed and bind ??x to (2 3 4). Have you discussed such a feature at all?
15:41dnolenjonasen: hmm haven't really considered that - it's also not very clear how that should work - has deep repercussions for unification of anything sequential.
15:42dnolenjonasen: or maybe not ... haven't thought about it at all.
15:44jonasendnolen: have you seen http://groups.csail.mit.edu/mac/users/gjs/6.945/psets/ps05/ps.txt
15:44mudgeantares_: my seesaw directory in classes is 8.5M, that seems large to me
15:44jonasendnolen: it's on pattern matching, but unificatition is kind of the same thing. search for `??` for some examples
15:44mudgels
15:44lazybotboot lost+found proc src srv
15:47dnolenjonasen: it's worth investigating - would consider it if someone else worked it out.
15:49jonasendnolen: this old gist of mine (https://gist.github.com/2236019) was an attempt to do something like ??x with core.logic but I didn't get very far
15:50dnolenjonasen: yeah wouldn't want to do that as a goal - to much hassle - you'd want to change unification.
15:51cemerickhcumberdale: yes, though keep an eye on what encoding you're using to get bytes from the string
15:52dnolenjonasen: you want a new kind of logic var - if encountered during unification of sequential type a different path would be taken.
15:52hcumberdalecemerick, it 'should' be UTF-8
15:53cemerickhcumberdale: well, if you don't specify, it'll use your platform default, which almost certainly won't be utf-8 everywhere
15:53hcumberdalebut I get the "Content is not allowd in prolog" when I try to xml.zip it
15:53hcumberdaleseems to be a encoding issue
15:54cemerick"xml.zip it"?
15:54hcumberdale(xml-> (zip-str string) :element text)
15:55cemerickoh, from zip-filter
15:55hcumberdalezip-str from http://nakkaya.com/2009/12/07/zipping-xml-with-clojure/
15:55jamiiWith the latest emacs-live, I get 'Symbol's value as variable is void: feature' on startup
15:55jamiiNot sure how to begin debugging it...
15:58mudgeIs it normal for leiningen to put the class files of a dependancy into target/classes ?
15:58wytukasuaarithcumberdale, you taste like poo.
15:59cemerickhcumberdale: that's pretty old; better to use the newer data.xml and data.zip libraries.
16:01jamiiStarts breaking between release/1.0-BETA-4 and release/1.0-BETA-5
16:07tomojsuppose @x always waits for 1s and then returns 42. so (do @x @x) waits for 2s and returns 42
16:07tomojif x implements IPending, should realized? always return false?
16:08tomojor should x not implement IPending?
16:16antares_tomoj: I'd say it should keep track of whether 1 second passed. Just like core things that can be dereferenced, they cache their results.
16:16tomojwhat you mean is that my x should not implement IDeref?
16:17tomojI don't think I can accept changing x to immediately deref to its result after the first time
16:17tomojbut the result will indeed be cached
16:17tomojyou'll just still get the 1s delay
16:21TimMctomoj: Sounds like a promise.
16:21tomoja clojure.core/promise?
16:21TimMcYes.
16:22tomojno, once a clojure.core/promise is delivered a result, deref'ing will always immediately return that result
16:24TimMcSorry, I mean it sounds like you that's what you *want*.
16:24tomojno, I definitely don't want that
16:24tomojcljque.promises/promise is closer to what I want but still wrong
16:25TimMcOh, right. And not clojure.core/delay?
16:26tomojindeed, again definitely not because that's only synchronous, but also because (delay (Thread/sleep 1000) 42) only sleeps once
16:27TimMcI didn't realize that was desied behavior.
16:27tomojI guess the question is, must (false? (realized? x)) mean "@x has never returned a value for anyone"?
16:29tomojI just want (true? (realized? x)) to mean "if you do @x now, you'll get a value immediately" and (false? (realized? x)) to mean "if you do @x now, you'll have to wait for a value"
16:32tomojhmm, shit
16:40mudgecan a gen-classed .class file use code written in a .clj file? or does code it use also have to be in a .class file?
16:41nDuffmudge: gen-classed methods just call through to clojure.lang.RT
16:41mudgenDuff: what does that mean?
16:41nDuffmudge: so they're completely able to see non-AOT'd code.
16:42mudgenDuff: thanks, good to know.
16:42nDuffmudge: (it also means they're not particularly efficient)
16:43mudgenDuff: you mean the .class files will be more efficent than the .clj?
16:43mudgenDuff: is that what you are saying?
16:43nDuffNo.
16:43nDuffI mean that gen-class just builds wrappers.
16:43nDuff...those wrappers call other code, which will in turn be just as efficient as they would have been were they not called by gen-class
16:44nDuffbut, of course, the wrapper itself is a single function call's worth of overhead
16:45mudgenDuff: okay. But we need gen-class in order to create a .class file that Java can see right? So there's no way around it.
16:45nDuffmudge: well, that depends.
16:47nDuffmudge: ...I mean, if you're writing your own, arbitrary Java code, it can ask the Clojure runtime to give it anything you want, with no wrapper involved. If you're passing a callback to Java code, you can give it something from reify or proxy.
16:47mudgenDuff: I'm building a module for a Java Web Start application that uses Swing, so I'm planning to use seesaw which is a nice library using Swing underneath. However when I aot the code the seesaw library gets much larger,
16:47mudgenDuff: I'm buidling somethign that Java code will call --- and I have no control over the Java code which will use my stuff.
16:48nDuffmudge: it's an available option to only build your gen-class wrappers without AOT'ing everything.
16:48nDuffmudge: Okay -- if the entry point is from Java code you don't control, and there's no alternate calling convention that lets you invoke it without a pre-named class, then it sounds like you do have a use case for gen-class.
16:49mudgenDuff: cool, do you know of any downsides to that? Because seesaw is like 100kb in .clj and like 8mb when I aot it.
16:49nDuffOnly real downside is that startup is slower.
16:49mudgenDuff: downside to making my gen-class file call .clj files instead of .class files
16:49nDuffyup.
16:50mudgenDuff: okay. startup of what?
16:50nDuffthose namespaces need to be compiled from clojure when they're loaded if they aren't compiled ahead of time
16:50nDuffso -- startup of whatever's loading the namespaces. :)
16:50mudgenDuff: i see, thanks
16:52mudgenDuff: is there a way to tell lein not to compile the the namespaces that I require or use?
16:52nDuffI don't remember what there is, but yes.
16:52nDuffs/there/that/
16:52mudgenDuff: okay, tanks
16:52mudgethanks
16:54tomojthere is?!
16:55nDuffmudge: see http://stackoverflow.com/questions/4062643/how-can-i-minimize-the-aot-compilation-in-leiningen-clojure
16:55mudgenDuff: okay
16:55nDuff...hrm; that's more than a little old.
16:56tomojwow, lein by default solves the transitive aot problem now? sweet!
16:57firesofmayHi, is it possible to create a web repl for overtone, where the user can write scripts and on the server side it executes them, transports back the sounds generated via some protocol and the browser plays it on the client side.
16:57tomojoh. https://github.com/technomancy/leiningen/issues/141 :(
16:57firesofmayI don't know if the browser can do that. So I am curious.
16:58tomojfiresofmay: I think that should be possible. but 1) you have to worry about them executing dangerous code and 2) I'm really unsure about this, but I think overtone itself is dangerous, since it calls out to supercollider - so it may be easy for them to crash your jvm
16:59firesofmaytomoj, Ah I see.
17:00technomancytomoj: lein includes a workaround
17:00tomojthe other hard part is streaming overtone's output out, dunno how you'd do that
17:00technomancythere's been an open issue for it since forever =\
17:00firesofmaytomoj, The idea from where I am coming from is, I have seen that there is a lot of barrier in just trying out overtone, I myself had lot of problems getting it running.
17:00tomojtechnomancy: but it still breaks protocols?
17:00firesofmaytomoj, yeah, lets forget the whole crashing part, how can you stream the overtone output? Any ideas?
17:00technomancytomoj: yep; doesn't seem to be a way around that problem
17:00technomancyother than not using protocols
17:00tomoj:)
17:00tomojor fixing CLJ-322
17:01technomancywhich works great for me
17:01technomancyheh; good luck
17:01tomojfiresofmay: hmm
17:02tomojI don't think you can do that inside the jvm
17:02firesofmaytomoj, I see.
17:02tomojagain, not sure. but maybe you can just wire the SC output with jack to something that streams out?
17:02tomojguess I'd ask #supercollider
17:02firesofmaytomoj, I am quite to new this so no idea.
17:02firesofmaytomoj, okay yeah that may be a good idea.
17:06tomojfiresofmay: http://code.google.com/p/darkice/
17:06tomojcould be relevant
17:06tomojI've been thinking about streaming overtone to a browser for a long time, but never considered a web repl. cool idea
17:07firesofmaytomoj, checking.
17:07firesofmaytomoj, yeah. having a web repl would mean anyone can checkout overtone without any barrier of installing.
17:08firesofmaytomoj, interesting project.
17:14mbcevSo I don't have a direct clojure question, but it's semi-related... I know the MVC design pattern was born out of SmallTalk (the poster child for OOP), what about with Functional Programming? Are there similar frameworks slash design patterns slash formalisms that seem to fit Functional Programming particularly? Or is it entirely irrelevant because it depends entirely on how you choose to design your particular system architecture?
17:16TimMcmap/reduce?
17:16jamiitomoj, technomancy: I'd be pretty interested in getting streaming working for https://github.com/jamii/concerto too
17:17jamiiI imagine there would be a lot of overlap with any web-repl project
17:17FrozenlockDoes a uberjar run faster than the equivalent separated jars?
17:18tomojjamii: streaming what?
17:18Frozenlock(Any load time difference, or is it just for convenience?)
17:18p_lI figure there is possible load time difference, but mostly the convenience of not fucking around with the madness that is CLASSPATH
17:19technomancymbcev: middleware is a common "pattern" in Clojure
17:19technomancyFrozenlock: no difference
17:20jamiitomoj: streaming overtone audio
17:21solussdis metadata as a way to mark data as validated by a validator a correct use of metadata? I have some code with validators being called in the view layer and in the model layer. Depending if data is coming from the API or the web portal it may be validated twice. I was considering, as an optimization, marking data as validated and having the validator check for that metadata before performing validation. thoughts?
17:22solussdafter all, it is data about the data. :)
17:22technomancysolussd: sure, except for the fact that it can't be attached to strings or numerics
17:22solussdtechnomancy: it'll always be a record or map
17:24bryanlin clojure, there isn't a way to have a range as a hash key is there?
17:24mbcevtechnomancy: So, with middleware you're referring to Ring, right?
17:25technomancymbcev: ring is probably the first place in Clojure it was introduced, but it's also used in nrepl, clj-http, and Leiningen
17:27mbcevtechnomancy: just found a page painting a better picture of what "middleware" means, thanks. I can see how this idea would be more natural to a LISP, and also just to I/O-esque systems. Thanks! :D
17:27dakronembcev: http://clojure-doc.org/articles/cookbooks/middleware.html
17:28FrozenlockAh excellent! Then my next possibly misguided question: Is there a way to just send every jars into the same folder? Should I just use lein-tar and decompress the result?
17:29devntechnomancy: best way to get access to some project dependency without adding to .lein-classpath or :eval-in-leiningen?
17:29mbcevdakrone: haha, that's I just came up with. That and the wiki for Middleware lol. Thank you!
17:29technomancydevn: what?
17:30devni'd like to require src/foo/core.clj in src/leiningen/blah.clj
17:30Frozenlock(I've made a lein-plugin around Getdown to enable auto-update for applications, but if the different jars could be separated that would be very nice: less download at each version bump)
17:30technomancydevn: eval-in-project is how you do that
17:30devnthanks
17:30technomancysure
17:32TimMctechnomancy: Have you had any thought as to how documentation might be distributed with Clojure projects?
17:33technomancyTimMc: Leiningen symlinks things from doc/ into resources/
17:33technomancyworks pretty well
17:33TimMcOh yeah? Interesting...
17:34TimMcWhat happens on NTFS?
17:34technomancythat's how `lein help readme` works
17:34technomancythe symlinks are only used during development
17:35technomancy`lein uberjar` copies the linked contents into the jar, not the symlinks
17:35TimMcbut a Windows user would not be able to package the jar properly?
17:35technomancyno
17:35TimMcHmm, OK. Not too worried, though.
17:36technomancybin/release is a shell script anyway
17:36TimMcI don't know what that is.
17:36technomancyoh, I mean the script that generates the uberjar
17:36technomancyunfortunately due to bootstrapping it's more complicated than just running `lein uberjar`
17:37TimMcThis is a component that lein uses to build lein, or to build arbitrary projects?
17:37technomancyspecific to lein
17:37technomancyI just mean symlinks aren't the only thing preventing using Windows for releases
17:38TimMcBut bin/release only prevents lein from being released on Windows.
17:45technomancyI think
17:54zackzackzackHow does one go about setting the seed for rand?
17:55ssideristechnomancy: oh, I didn't realize lein uberjar does not run properly on Windows!
17:55ssiderisis that a documented limitation?
17:56technomancyssideris: leiningen can't build its own uberjar with documentation on Windows (without Cygwin)
17:56TimMcOh right, Cygwin.
17:56technomancybuilding a typical project's uberjar will work
17:57ssideristechnomancy: oh ok, thanks, sorry for jumping into the discussion with minimal context :-)
17:59technomancyno worries
18:13solussdare assertions (*assert*) disabled in production mode for ring?
18:14technomancyring has production mode?
18:15bozhidarI guess someone did too much Rails development :-)
18:19solussdthe jetty adapter appears to take a :mode option
18:19solussd:prod or :dev
18:20solussdbroader question then- when is *assert* not true?
18:24brehautsolussd: do you have a link to the code that uses :mode?
18:24brehautsolussd: i cant seem to find it in https://github.com/ring-clojure/ring/blob/master/ring-jetty-adapter/src/ring/adapter/jetty.clj
18:24brehauti suspect im looking in the wrong place
18:26solussdack, sorry, it's not passed to the jetty adapter, it's being used by gen-handler in noir.server (bad code reading)
18:30solussdcould someone help me understand when *assert* isn't true? I'm debating whether or not to use pre/post conditions in some places- I'd prefer not to throw assert errors in production (i'd rather have validators in my model later catch things and generate errors to present to the user)
18:31muhootechnomancy: it'd be neat if readme.md and docs got included in jars
18:31muhooso one could read the docs without having to go find the github page for a lib
18:33technomancymuhoo: you can do that with :filespecs {:type :path :path "README.md"} in project.clj
18:33technomancyI don't know if it should be on by default since not everyone uses markdown
18:35technomancycould search for the first file matching README* but the logic gets a lot more complicated when it's not declarative
18:35technomancy(like you need a separate flag to turn it off)
18:35muhooreadme.md is the default in lein new, tho
18:36technomancyyeah, but markdown is not a very good format
18:36technomancyyou shouldn't have to add stuff to project.clj to prevent jar failures just because you are using a better format
18:37muhoomaybe there will be an eventual rethink of docs then.
18:37muhoobut self-contained docs in a lib package would be nice
18:37technomancymaybe the default could include :filespecs
18:37technomancyI mean the default project.clj
18:38technomancyrather than having it hard-coded in lein itself
18:38muhoomakes sense
18:40muhooi could even see a plugin for lein repl or nrepl to show them
18:40muhoomaybe even some transformation for nrepl.el that turns md into info and puts them in emacs
18:42technomancyheh... that would be cool, but info is completely bonkers-insane
18:42muhoowell that may be unneccessary since markdown-mode works
18:43technomancyit would be nice if there were a pure-elisp HTML renderer
18:43technomancysince you can't rely on w3m being available
18:43technomancybut yeah, markdown is usually pretty palatable on its own
18:44muhoothat's easiest. or there's a markdown-mode func that renders it to htm and shows it in the browser
18:46muhoobut i'd love to have M-x nrepl-doc RET friend RET and see the damn readme.md
18:47muhooas a use case :-)
18:50dnolenhugod: ping
18:55sgarrett|afkWhat's the best way to debug in clojure? Or to get good debugging information?
18:57dnolensgarrett: probably ritz
18:58sgarrettdnolen: will that work well with lein?
19:00muhooas a use case :-)
19:01dnolensgarrett: seeing as there's a lein-ritz plugin I'd imagine so
19:01sgarrettdnolen: Awesome. Thanks!
19:24seangrovelynaghk: What's the state of reflex? Is it suitable for production use still, or has it been deprecated for something newer?
20:21hugoddnolen: ping
20:21dnolenhugod: pong
20:21hugodyou called...
20:21dnolenhugod: http://gist.github.com/4158004
20:22dnolenhugod: getting that to work requires a bit too much knowledge about constraint internals
20:22dnolenhugod: I'm working on a macro that will greatly simplify defining fairly straightforward constriants like that
20:22dnolenhugod: but I'm assuming that's what you wanted in terms of behavior correct?
20:24hugoddnolen: yes, thanks very much - though I would call it not-pathc or something
20:24dnolenhugod: yeah
20:24hugodbut looks fantastic :)
20:25dnolenhugod: gimme a second, cooking up something even cooler
20:25dnolenconstraints are pretty sweet - kinda just starting to realize how cool this stuff is.
20:26hugodthe interaction of functional and logic is mind-bending
20:27hugodI'm just wondering how I could use this as a pure constraint (or whatever it is called; something similar to >fd and <fd)
20:27hugodI think I can just call it
20:28dnolenhugod: what do you mean by similar to >fd <fd?
20:29hugodit's ok - I think I understand. I'm using these constraints bound to logic vars, so have to project them
20:29dnolenhugod: yes I'm fixing that.
20:29dnolenhugod: hold one :)
20:29dnolenyou should never have to projet w/ constraints
20:29dnolenproject
20:32hugodoh, ok - I'm basically doing (run* [q] (fresh [c] (membero c constraints) (project [c] (c))))
20:32hugodoh and unifying q with a pattern, that includes a logic var that is in c too
20:41dnolenit's always fun when you can use a pre-constructred exception for cheap backtracking ...
20:43hugodfunctional!
20:44dnolenerg, I guess nrepl doesn't do sensible macroexpand yet ...
20:45dnolenthis feel like 2009
20:45dnolenfeels
20:45hugodI don't think it is recursive yet
20:45dnolenI'm not even talking about that
20:45dnolenjust pretty printed code w/ namespace clutter
20:45dnolenw/o
20:46dnolenthe only thing that's bitten me is macroexpand and yucky stacktraces
20:46hugodit's moving very quickly
20:47hugodnot having multiple sessions is a bit of a limitation I find
21:04dnolenhugod: look ma, no project! http://gist.github.com/4158004 :)
21:04dnolenhugod: and considerably less code
21:05dnolenhugod: I added defc, which eliminates all the boiler plate
21:05dnolennote ordering doesn't matter, nor how deeply nested the logic vars are in the terms to the constraint
21:06dnolenthe constraint won't run until all arguments are deeply ground.
21:06dnolenI can't imagine this will solve all use cases - but it'll probably handle many of the kinds of simple constraints most people would write.
21:32hugoddnolen: wow!
21:32hugodI'll have to try it to test set membership
21:33dnolenhugod: it's a bit experimental let me know how it works out for you.
21:33dnolenhugod: the fun part is that the body of defc is just regular Clojure code
21:34dnolenhugod: but by testing the arguments to see if the constraint is ready to run - it frees you from considering projection - performance hit of course - but in this case the flexiblity is a big win I think.
21:35hugoddnolen: having to call project isn't too bad, but nicer without it
21:35hugoddnolen: being able to defc constraints simply is big though
21:35dnolenhugo: exactly :)
21:56dnolenhugod: as far as sets it's likely I add explicit support for CLP(Set)
21:57dnolenhugod: kinda like CLP(FD), but without all the complications.
21:58hugoddnolen: you had a comment in the code about unification with sets being a research problem - I take it that set membership is easier
21:58dnolenhugod: so you could do things like (inset x #{:cat :bird :dog})
21:58hugod:) I could use that!
21:58dnolen(unionset x #{:zebra} y)
21:58dnolenhugod: yep, and it's easy to do
21:59hugoddnolen: if I have a pattern for a map, can I associate the whole map with an lvar so I can impose a constraint on it? a la {:as ?f}
21:59dnolenhugod: I'm putting efficient CLP(FD) on the backburner and focusing on stuff that's easy to implement efficiently.
21:59dnolenhugod: in what context?
22:01dnolenhugod: relational programming with sets is hard
22:01dnolenhugod: sets in the context of constraint programming - easy
22:02hugoddnolen: I want to match a map {:some :key} and impose the constraint (not-pathc [:other :key]) on the map
22:02dnolenhonestly I don't see how you can do anything w/ relational programming that doesn't involve lists.
22:02hugodmembero seems to work nicely with maps
22:03dnolenhugod: well, in Clojure sequences work out as well of course
22:03dnolenhugod: is there something you're describing not covered in the gist?
22:06hugoddnolen: I can see how it works in the context of the body of a run, but not when passing the pattern and constraints as logic vars themselves (if that sentenced was parsed)
22:07jcromartiewhy can't I do bitwise operations on BigInteger?
22:07dnolenhugod: oh right, you're passing in constraints bound to logic vars?
22:07hugoddnolen: yes
22:08dnolenhugod: is that the missing bit?
22:08hugod(let [rules (map prep [[{:some :key} {:a 1} [(not-pathc ???? [:other :key])]]])] ...)
22:10hugoddnolen: map destructuring syntax would be nice...
22:10dnolenhugod: yeah I'm not sure how your system works so I can't really say
22:11dnolenhugod: would need to take a closer look at how you're trying to solve things.
22:11hugoddnolen: I'm just trying to associate an lvar with {:some :key} above, so I can put the same lvar in the not-pathc form
22:12dnolenhugod: this is all work you want to do before calling run?
22:14bryanlwhat is -> and ->> called?
22:15hugoddnolen: no - I process the constraints - resolving the constraint function symbol in each constraint form and then creating a function that uses reduce to call each constraint with the susbtitution map. That function then gets bound to a logic var and called inside run (that is all working already).
22:16hugoddnolen: if this is getting too out of scope I'm happy trying things out on my own
22:18dnolenhugod: core.logic constraints or something of your own devising?
22:18hugoddnolen: these are core.logic constraints (it works with <fd and >fd)
22:19dnolenhugod: so why won't it work w/ not-pathc that I gisted?
22:20aperiodicbryanl: the threading macros, thread-first and thread-last (though i've also heard the first one called "the arrow macro")
22:21hugoddnolen: because I don't know how to get prep to bind an lvar to the {:some :key} map (actually it would be (partial-map {:some :key})
22:21bryanlaperiodic: thrush and threading... now it makes sense
22:23dnolenhugod: oh like (unifier ({:foo :bar} :as ?x)) !
22:23hugoddnolen: yes, I think so
22:25hugoddnolen: I can probably work around it for now anyway, but putting the map inside a map
22:25hugodback in 15mins
22:25dnolenhugod: yeah I'll ponder that, probably not that hard to add support for in prep and thus unifier
22:25dnolenhugod: I gotta run myself. will think on it
23:14TimMcbryanl: I like to call them stitching macros.
23:14brehautTimMc: thats a much better than the other common name that people normally use
23:15brehaut(which i wont mention to minimise confusion)