#clojure logs

2014-12-06

00:00rritochjustin_smith: Thats why I asked you, I know you understand these transducers better than I do but as far as I can tell anything that you would use reductions for would be replaced with a stateful transducer and either (into [] ...) or (sequence ....)
00:02rritochjustin_smith: I've yet to run into any situation where a transducer would be preferable, in this particular case a simple map (or for) will work, but then again I'm not dealing with statistical analaysis or anything else that requires a lot of function composing
00:03rritochjustin_smith: I'm mostly just looking for excuses to try the transducers, even if they're not the ideal solution to the given problem :)
00:04justin_smithrritoch: the main win for transducers is if you are implementing a new "thing" which things like map and filter and reduce would work on, or if your sequence operations are your performance bottleneck
00:04justin_smithie. the way transducers version of map and filter are replacing the map and filter in core.async
00:12rritochI haven't yet had a good excuse to work with core.async yet. I tried to prepare the codebase I work with to use asynchronous processing, but the project manager removed the code. So unless some client demands a high-performance version of the app with more parallelization than I really won't be able to use it for awhile.
00:16rritochAs far as I know there isn't a stable async http client with https support yet either, which is another thing preventing me from trying core.async
00:17justin_smiththat's surprising, because the underlying java libs are https compatible.
00:18justin_smithI just ran (slurp "https://google.com") in my repl and it worked. That's not async of course.
00:20nhanHWhat is the operator "->" called again?
00:21nhanHie how do I google it
00:21justin_smiththread-first
00:21nhanHokay thanks
00:21justin_smithor use symbolhound
00:21justin_smithhttp://symbolhound.com/?q=-%3E+clojure
00:21nhanHoh that's new to me! Thanks!
00:21justin_smithsymbolhound is great for weird language syntax
00:22justin_smithnhanH: also, hopefully you know about clojure.repl/doc, clojure.repl/source and clojure.repl/apropos
00:23nhanHyeah I do, I just don't have access to the repl right now ... just trying to implement "->" in java
00:24justin_smithgood luck figuring out the types for that! I guess you can just say every argument needs to be a list starting with a callable
00:24justin_smithList of Object of course
00:25justin_smithwait, no, because methods work for -> too...
00:42rritochnhanH: I've never tried it, but something like .the following may work. Object MyHyphenGt(Object[] x) { Clojure.var("clojure.core","->").applyTo(PersistentList.create(Arrays.asList(x))); }
00:43rritochAssuming you have a clojure runtime in your java app
00:50rritochHmm, Maybe not. I see that -> is a macro, how do you execute a macro from Java?
01:03rritochHow about Object MyHyphenGt(Object[] x) { Compiler.eval(PersistentList.create(Arrays.asList(x).insert(0, Symbol.create("clojure.core","->")),true); }
01:03rritochShould that work?
01:14rritochThis also brings me to another question, since it seems using eval on a macro would require operating on symbols, is there some way of generating something like gensym's in java to wrap values?
01:17rritochI can think of an ugly hack of possibly creating a temporary namespace, interning all of the values as generated of that namespace, passing the symbols to eval, and then removing the namespace when it's done, but there must be an easier way.
01:22lodinIs there any way to get a list of all loaded java classes?
01:23josiah14which should I choose when it does not matter, mod or rem?
01:24josiah14I know in some languages there is a lot less overhead in one rather than the other
01:45rritochlodin: If you are using leiningen You can add [org.reflections/reflections "0.9.9-RC1"] to your dependencies and use the code (.get (.get (.getStore (org.reflections.Reflections. "" (into-array org.reflections.scanners.Scanner [(new org.reflections.scanners.SubTypesScanner false)]))) org.reflections.scanners.SubTypesScanner) (.getName java.lang.Object))
01:47rritochlodin: This will list any loaded java classes that have been instantiated, technically this code lists classes that have extended java.lang.Object which should be every class that's been used
01:49lodinrritoch: Thanks. I'll try it out.
01:49rritochlodin: It is acting wierd though, it isn't showing clojure classes, like PersistentVector
01:50rritochlodin: I suspect there are classloader issues involved here
01:51lodinrritoch: In the repl it's giving me just an empty vector. Clojure 1.6.0.
01:51andyfrritoch: I haven?t used Clojure from Java at all, but I would guess that either (a) you don?t use macros invoked from Java, or (b) you invoke clojure.core/eval on Clojure expressions containing macro invocations.
01:52rritochlodin: Ok I figured it out, don't pass an empty string, pass nil
01:53lodinrritoch: Now that's a different story! :-)
01:53rritochTry (.get (.get (.getStore (org.reflections.Reflections. nil (into-array org.reflections.scanners.Scanner [(new org.reflections.scanners.SubTypesScanner false)]))) org.reflections.scanners.SubTypesScanner) (.getName java.lang.Object))
01:53rritochThat is returning all classes
01:54rritochAt least I assume it is due to the HUGE amount of spam
01:55rritochUsing nil instead of an empty string I get 4504 classes returned
01:58rritochandyf: Thanks, I think that is the same as the Compiler.eval((PersistentList)... syntax
01:59rritochandyf: Any idea how to produce gensyms? Typically gensyms are used in let forms so I'm guessing I would need to somehow use a Compiler.LetExpr
02:01rritochandyf: I'm probably going to use this exercyse to become familiar enough with the compiler to start implementting namespace isolation.
02:01andyfrritoch: invoke clojure.core/gensym maybe?
02:02lodinrritoch: Maybe I'm missing something things I'm not a Java programmer, but I just took a random class from the java class library "java.awt.AlphaComposite", but I only have four classes that match #"(?i)awt" and that's com.sun.java.accessibility.util.AWTEventMonitor and com.sun.java.accessibility.util.AWTEventMonitor$AWTEventsListener.
02:02lodins/things/since/
02:03rritochandyf: That sounds like a good idea, generate a LetExpr, evoke clojure.core/gensym for each item and then set the macro call as the body
02:03lodinIf i type java.awt.AlphaComposite in the repl it confirms the class exists.
02:05rritochlodin: For reflections to return a specific class that class needs to be used first
02:05lodinMmm-hmm.
02:05rritochlodin: Java classloaders are lazy, they don't load classes until they're requested
02:07rritochlodin: There is really no way to get a list of any possible class that can be loaded by the current classloaders, a few examples of this is that jars (which are zip files) aren't required to include directory entries. You can also have URL's on your classpath, and there's no "standard" for getting a list of files from a web site.
02:09lodinSo when I evaluate "java.awt.AlphaComposite" in the repl, then what happens?
02:10rritochlodin: It will use a classloader to resolve the class. In every current version of clojure it uses Class.forName("java.awt.AlphaComposite") since your using the fully qualified class name
02:11rritochlodin: This behavior is a bit of a bug though and has been patched
02:11lodinHow is it a bug?
02:11rritochlodin: Either way, Class.forName uses the system classloader (the classloader that loaded the class java.lang.Class)
02:12rritochThe system classloader then checks it's cache for the classname, if the class isn't in the cache it searches it's "classpath"
02:12andyfrritoch: Well, a patch has been written. It isn't in Clojure yet.
02:12rritochlodin: It is a bug because nearly everything in clojure uses a "root" classloader
02:13rritochandyf: Yeah, please let me know when/where I can upvote that patch, I really like it :)
02:14andyfThis ticket, I think: http://dev.clojure.org/jira/browse/CLJ-979
02:14rritochlodin: Either way, if your new to java you should really stay away from classloaders
02:14rritochlodin: Classloaders are difficult to deal with even for expert java developers
02:14andyfDo you have an account on JIRA? If you see your name near the upper right, you are logged in. If you see "Log in", you can click on that to create a JIRA account.
02:15rritochandyf: Ok, thanks. I'll create an account
02:16andyfThen go back to the CLJ-979 ticket link after you are logged in, and look for a "Vote" link near upper right part of page.
02:16lodinrritoch: Yeah, I'd rather not. I'm doing some tooling stuff, and this came up.
02:16andyfwell, right hand side of page, not at the top but a little ways down.
02:16rritochlodin: The best way for you to view the situation right now is that if you get a class not found exception than you probably have a missing dependency, in other words your trying to access a class from a library that you don't have loaded.
02:17rritochlodin: If you are using leiningen you can see all loaded libraries using 'lein classpath'
02:18lodinrritoch: Does anyone not use leiningen? :-)
02:18andyfSome people use Maven directly, but not using Leiningen for Clojure is definitely in the minority.
02:20andyfLook for "what tools do you use" near the bottom of the 2014 Clojure survey results if you are curious: https://cognitect.wufoo.com/reports/state-of-clojure-2014-results/
02:21rritochlodin: I've used clojure directly without leiningen, once, for 5 minutes, but I don't think that counts
02:21lodin:-)
02:24rritochAnyhow, I have to get back to work... This chatroom is very destracting, but in the few weeks I've been here I've learned more than I did working solo for months.
02:25lodinrritoch: Thanks for your help.
02:26rritochlodin: I hate to beg for reputation, but think you could (inc rritoch), I'm hovering at a perfect zero so far
02:26lodin(inc rritoch)
02:26lazybot⇒ 1
02:26lodinSure :-)
02:26rritochthanks :)
02:30rritochandyf: I'm on jira now, so how do I upvote the patch which uses baseLoader() ?
02:30andyfyou can vote for tickets. There isn't a way to vote for particular tickets.
02:31andyfvoting for a ticket means you want it to be resolved, not necessarily by a particular patch.
02:31andyfYou can add a comment saying whatever you wish, if you have a reason to prefer a particular patch over another.
02:32andyfSorry, I mean to say "there isn't a way to vote for particular *patches*"
02:33rritochandyf: Thanks, I upvoted the ticket, though I'm strongly for the baseLoader() solution, but I still think it should check for any interned version of the class first
02:34andyfYou can add a comment stating your opinion, and any reasons for it.
02:36rritochandyf: Ok, I'll do that later, first I need to build a remote authentication system, once that's done I'm free to start working on clojure/core issues. I know I'll have time available monday, but I'm hoping to get started before then.
02:37rritochandyf: I really want to get this namespace isolation, I know simply bypassing the problem and allowing namespace conflicts will come back to haunt me if I don't deal with it now.
02:38andyfGood bug hunting
02:53rritochIs there any REPL "terminal"? (A stand alone GUI REPL)
02:54rritochI constantly find myself having to launch a new shell, browse to a random project, and launch lein repl... It would be much easier if I could just add something to my quick-launch bar (microsoft).
02:56andyfIs there an existing Windows terminal that you can configure to start up a command window in the desired project directory?
02:56andyfI'm not familiar with anything you describe, but that doesn't mean it doesn't exist.
02:57rritochandyf: Honestly I'm not sure, I also haven't looked into all of the features of powershell, this may be something I can get powershell to do for me
02:57rritochandyf: I did start a project for testing purposes
03:21TEttingerrritoch: I think you can set up any cmd shortcut to run with a specific command on windows, but you could also just make a .bat file
03:22rritochTEttinger: I think I'm looking for something like https://github.com/alandipert/clj-swingrepl but it doesn't seem to work on my machine, it just hangs.
03:24TEttingerwell the custom cmd application thing that visual studio gives you is just a shortcut with the target: %comspec% /k ""C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\vcvarsall.bat"" amd64
03:24TEttingerthere are others, that one is the x64 tools prompt
03:25TEttinger%comspec% is an env var that leads to the full path to cmd.exe
03:26TEttingersubstitute the vcvarsall.bat for the path to lein.bat and amd64 for repl and you should be set, rritoch
03:26TEttingerthat shortcut can be pinned to the taskbar
03:28rritochTEttinger: Ok thanks. That should work, I'll just need to set a current working directory to a test project
03:28TEttingerthen I would just make a bat file and launch it
03:29rritochTEttinger: I was just hoping there was maybe something like a GUI interface to leiningen, where you can select dependencies, profiles, etc. before launching
03:29TEttingererr, I think shortcuts let you specify where tehy start
03:53wirrrbel"lein repl" takes forever to start, is that due to my underpowered laptop?
03:56rritochwirrrbel: It could be your internet connection, you can try adding :update :always to your project.clj and see if that helps, though if you change your dependencies you may need to run lein deps or lein -U jar
03:56rritochwirrrbel: Err, :update :never
03:58rritochwirrrbel: If you have :aot :all set you may want to comment that out while your developing, otherwise it will try a compile before launching the repl.
03:59wirrrbelhmm, kind of think that overall its my 5-6 year old macbook
03:59wirrrbel:update :never does not speed it up
04:00rritochwirrrbel: Well, for some of my projects my repl takes forever to start so these are the things that I do to speed it up
04:05wirrrbelrritoch: thanks for your help!
04:29sveriHi, how do I convert a clojure data structure (vec / map) to a pretty formatted string?
04:30hellofun`svery clojure.pprint/pprint ?
04:31sverihellofunk: returns a string?
04:31andyfsveri: with-out-str around stuff that prints to *out* will put it in a string instead.
04:31hellofunksveri consider with-out-str
04:32sveriandyf: ah, thats nice, thank you both :-)#
04:32hellofunkah andyf beat me to that one
04:33andyfsveri: The Clojure cheatsheet has some things like this categorized somewhat by function: http://jafingerhut.github.io
04:33andyfCheck out the "IO" section about a page down on the right side.
04:34sveriI see
04:34sverilooks nice :-)
04:37sverihm, could it be that pprint and with-out-str dont workin clojurescript?
04:37andyfpprint doesn't exist there, I think.
04:38sveriok, that explains my problems :D
04:38sverinonetheless, thank you
04:38andyfI'm not sure, someone may have ported the fipp lib to ClojureScript, which also does pretty-printing.
04:38sveri-> goint to #clojurescript
04:39andyfhttps://github.com/jonase/fipp/compare/cljs
04:39andyfSorry, I meant this link: https://github.com/jonase/fipp
04:40sverihm, the PR seems to be merged to 0.4.1-Snapshot, which was never released
04:41sverithis looks good: https://github.com/shaunlebron/cljs-pprint
04:42sverioh, no, I was wrong
04:44sveriHm, reading through all this and cljs jira it seems like there is nothing finished yet
05:31profilHow does a set decide if an item is equal? Is it possible to change that comparison?
05:35whodidthisso i got this macro thingie but im not sure how to get the final result unquoted or something, anyone know if its still possible? https://www.refheap.com/94485
05:39AeroNotixwhodidthis: what is the macro supposed to do?
05:40whodidthiswith that example def depth-1 and depth-2
05:40whodidthisat the moment it just returns the list(?) as seen
05:40AeroNotixjust generate named functions that return integers?
05:40TEttingerseems like you shouldn't be consing a list and should just call do and def, but I am not good with macros
05:41TEttingerhell, you don't even need the do
05:43AeroNotixwhodidthis: I'll write this for you
05:43AeroNotixsec
05:43rritochprofil: if you look at the source code for PersistentHashSet you will see that there is a constructor where you can pass in your own IPersistentMap impl, and it uses the containsKey method from the Associative interface to determine if an item is going to be unique to the list.
05:44rritochprofil: So you should be able to extend an existing map with your own containsKey method to override the default functionality
05:46AeroNotixwhodidthis: https://gist.github.com/AeroNotix/214dd3aef7998c317524
05:46AeroNotixyou should always break macro code out into small portions
05:46AeroNotixnever try to do too much inside a macro's body
05:46AeroNotixbecause it gets confusing very fast
05:47AeroNotixHTH
05:47whodidthisoh, cool
05:48AeroNotixAlso, I guess you were trying to ensure depth was evaluated once or something when you assigned it to the d#?
05:48pyrtsaprofil: Alternatively you could play with (reify Object (equals [a b] ...) (hashCode [a] ...)) to define your own equality semantics for the items you put to the set. But I would recommend using a map data structure instead.
05:48whodidthisi use it with a var
05:48whodidthislike (def-depths depths)
05:48AeroNotixI see
05:48AeroNotixyes
05:49whodidthisi somehow got it to work without the assigning to d# part but then got owned when i put that in
05:50AeroNotixvar expansion is tricky
05:50AeroNotixit's easier to write macros which just work with literals
05:50AeroNotixand probably more easily understood for people using your macros.
05:52whodidthisthey wouldnt use it, i just want a set of depths def'd, kind of like yesql returns the queries as functions
05:52whodidthisyesql code too mysterious for me to understand sadly
05:54AeroNotixAll code is mysterious until you understand it
05:55whodidthisquite, need to put another syntax quote in to expand the var and then code returns a list again
05:58AeroNotixyou need to remember that the code expansion happens when the variables don't have any values
05:58AeroNotixthey're just symbols and s-expressions
05:58AeroNotixSo trying to create the values from a symbol, isn't going to work.
05:59AeroNotixReturning code which expands into a for loop that needs to be eval'd at runtime could work, but requires a runtime call to eval, which is gross.
06:00AeroNotixDo you *need* to def these things as a top-level def?
06:00whodidthisdoes seem to be so :S and theres no eval in clojurescript either
06:01AeroNotixwhodidthis: do you need to have them as a def?
06:01whodidthisill work with your thingie and write the map into the call then! many thanks for explanation
06:01AeroNotixBecause defs are essentially globals.
06:01AeroNotixand those are bad, mmkay
06:02whodidthiswould be nice to call depths/depth-1 and color/lightgrey-1 instead of (get-in color/colors [:lightgrey 1])
06:03whodidthisglobals shouldnt be to bad in their separate namespace i thinks
06:03profilrritoch, pyrtsa: okay, thats sounds a bit hard.. Maybe I'm doing this wrong? I want to have a data structure that consists of coordinates and parent coordinates, and use those in the set, only caring about coordinates and not the parent.
06:04profilrritoch, pyrtsa: I have read about records, maybe I should use that?
06:04AeroNotixwhodidthis: it's up to you, but pervasive use of global defs is a code smell imho. The more you use it, the more you rely on it and the harder your code is to test and reason about.
06:06whodidthisseems to work great for om's DOM functions
06:06AeroNotixWhatever. I'm done here.
06:06whodidthisat least i like it better than sablono, but many thanks again for code and var expansion explanation
06:07AeroNotixnw
06:08AeroNotixwhodidthis: you should read some proper literature on macros
06:08justin_smith$mail wirrrbel there are some tricks to get lein repl to start much faster https://github.com/technomancy/leiningen/wiki/Faster in particular LEIN_FAST_TRAMPOLINE or skipping nrepl and directly running clojure.main instead both shave off a lot of startup time
06:08lazybotMessage saved.
06:21rritochprofil: If you use records you should be able to override the equiv method to control what the record considers as equivalent
06:24rritochprofil: It took me some digging but it appears that the default set uses clojure.lang.Util/equiv to determine if items are equal. Records implement IPersitentCollection so you need to use equiv instead of equals to establish equality within a default set.
06:26profilrritoch: alright, thanks :)
06:53ffwacomis Rich Hickey from the future?
06:54justin_smithnope, he is from the far past
06:54justin_smith$last rhickey
06:54lazybotrhickey last listened to: 100s - Inglish Outro (feat. Ice Cold Perm) [IVRY]
06:54justin_smitherr
06:54justin_smith$seen rhickey
06:54lazybotrhickey was last seen quitting 76 weeks and 4 days ago.
06:54justin_smiththough it's interesting to see what he listens to I guess
07:02justin_smithprofil: you may find this SO answer of mine useful http://stackoverflow.com/questions/26622511/clojure-value-equality-and-sets/26622863#26622863
07:03profiljustin_smith: I realized that I could just use an ordinary map {[x y] [parent-x parent-y]}
07:05justin_smithoh, I thought you wanted a comparison that ignored the parents
07:08profilyeah, and thats what map does?
07:09justin_smithI see, so you would merge things into the map
07:09justin_smithI thought you wanted a set of maps
07:10profiljust like `(conj {[1 1] [0 1], [1 2] [1 3]} {[1 1] [1 0]})`
07:11rritochprofil: I wasn't able to get this done with defrecord as defrecord stopped me from changing the equiv method, but I was able to do it with deftype
07:12justin_smithrritoch: likely the solution you found looks much like my or puredanger's answer in the above SO link
07:13rritochNo mine is much simpler
07:13rritochI just can't paste, it'll take me some time to get this typed out
07:15rritoch,(deftype IgnoreParent [parent y] clojure.lang.IPersistentList (equiv [this o] (and (instance? (class this) o) (= (.y o) (.y this)))))
07:15clojurebotsandbox.IgnoreParent
07:15rritoch,(= (IgnoreParent. 99 1) (IgnoreParent. 99 1))
07:15clojurebottrue
07:15rritoch,(= (IgnoreParent. 99 1) (IgnoreParent. 99 2))
07:15clojurebotfalse
07:15justin_smithrritoch: you can use y in the place of (.y this)
07:18rritochjustin_smith: Do you know why IPersistentList isn't identified? I thought everything in java.lang.* and clojure.lang.* was supposed to be available without a fully qualified name?
07:18justin_smithno
07:19justin_smiththe ns macro makes all of clojure.core's vars available in the ns you create, but clojure.lang is not imported anywhere by default
07:21rritochjustin_smith: Well I've been meaning to ask about that. It is the number one reason for me getting compiler errors since I always assume I can just use clojure.lang.* classes without importing them
07:22rritochAnyhow, I have about an hour to play so I'm finally going to checkout clojure from github so I can start playing with it
07:24rritochI just have to be careful to not use any custom builds in client projects.... That could end badly
07:28justin_smithrritoch: as long as the project.clj explicitly points at your group/artifact, and you make the artifact available, it can at least be tractable
07:29justin_smithnow if you build it and don't change the group and version string, that could be very messy indeed
07:32rritochOk, so if I change the version in pom.xml that won't interfere with pulls?
07:33justin_smithwell, changing group should suffice actually
07:34justin_smithrritoch: btw, your deftype does not suffice for hash equality https://www.refheap.com/94488 - two items with identical fields are not considered identical to hash-maps or hash-sets
07:35justin_smiths/to/by/
07:35rritochjustin_smith: It should, I just dug into the sources of all of that and hash sets use equiv for IPersistentMap's
07:35justin_smithrritoch: no it should not, see the SO above
07:36rritochOnly one way to test
07:36justin_smithhash insertion does not use equiv
07:36justin_smithrritoch: and see my link above for said test
07:37justin_smith(the refheap one that is)
07:39rritochWell, I traced the source code and I see persistentHashSet uses the impl map's containsKey
07:40rritochFrom there I saw it was using a root INode, but obviously I ended up looking at the wrong INode implementation class
07:40justin_smithoh, it works for hash-maps, but not hash-sets
07:40rritochThe one I looked at was checking Util/equiv
07:40justin_smithI guess they hash differently, which is odd
07:41rritoch,(deftype IgnoreParent [parent y] clojure.lang.IPersistentList (equiv [this o] (and (instance? (class this) o) (= (.y o) (.y this)))))
07:41clojurebotsandbox.IgnoreParent
07:41justin_smithrritoch: I don't know if you were trying to make it work with hash-sets, but if you only needed hash-maps, your version does actually work
07:41justin_smithI am surprised that hash-maps and hash-sets hash differently to be honest
07:41rritoch,(set [(IgnoreParent. 2 1) (IgnoreParent. 3 1)])
07:41clojurebot#{#<IgnoreParent sandbox.IgnoreParent@7a80e3> #<IgnoreParent sandbox.IgnoreParent@a3f1cc>}
07:42justin_smith,(into {} [[(IgnoreParent. 1 2) 9] [(IgnoreParent. 1 2) 8]])
07:42clojurebot{#<IgnoreParent sandbox.IgnoreParent@17e2e9> 8}
07:42justin_smithweird!
07:42justin_smithTIL
07:43rritochYeah, that shouldn't be the case, I think hashsets use hashmap as the impl
07:43justin_smithbut clearly they use a different comparison for insertion
07:45rritochHmm, how can I leak the impl?
07:48rritoch,(def a (set [1]))
07:48clojurebot#'sandbox/a
07:50rritoch,(.getDeclaredField (class a) "impl")
07:50clojurebot#<NoSuchFieldException java.lang.NoSuchFieldException: impl>
07:52rritoch,(.getDeclaredFields (class a))
07:52clojurebot#<CompilerException java.lang.RuntimeException: Unable to resolve symbol: a in this context, compiling:(NO_SOURCE_PATH:0:0)>
07:52justin_smith&(require '[clojure.reflect :as reflect])
07:52lazybot⇒ nil
07:52justin_smith&(map :name (:members (reflect/reflect #{})))
07:52lazybot⇒ (withMeta empty asTransient _meta createWithCheck create cons create clojure.lang.PersistentHashSet meta createWithCheck cons EMPTY disjoin create createWithCheck withMeta)
07:54rritochThe hashset extends APersistentSet with a private field impl which I need to make accessible to see it
07:55rritochAnyhow, good cheat-case
07:55rritochI'll just make it public and recompile
07:55justin_smith&(:bases (reflect/reflect #{}))
07:55lazybot⇒ #{clojure.lang.APersistentSet clojure.lang.IObj clojure.lang.IEditableCollection}
07:55justin_smith&(map :name (:members (reflect/reflect clojure.lang.APersistentSet)))
07:55lazybot⇒ (size remove get count setEquals clojure.lang.APersistentSet add equals removeAll clear toArray addAll retainAll invoke toArray iterator _hasheq contains hasheq toString containsAll seq impl _hash hashCode isEmpty equiv)
07:55rritochHmm, you got at the impl
07:57justin_smith&(filter #(= (:name %) 'impl) (:members (reflect/reflect clojure.lang.APersistentSet)))
07:57lazybot⇒ (#clojure.reflect.Field{:name impl, :type clojure.lang.IPersistentMap, :declaring-class clojure.lang.APersistentSet, :flags #{:final}})
07:57justin_smithhas a final flag, but no private flag?
07:59justin_smithaha, I get it, there is no :private flag, but it lacks the :public flag
08:01rritochYeah, and my test environment is screwed up
08:01rritochI checked out from windows so I have windows newlines, but I can only compile from linux
08:02rritochNormally I don't have a problem, but the build script won't run
08:02justin_smith&(into [] (.getDeclaredFields clojure.lang.APersistentSet))
08:02lazybot⇒ [#<Field int clojure.lang.APersistentSet._hash> #<Field int clojure.lang.APersistentSet._hasheq> #<Field final clojure.lang.IPersistentMap clojure.lang.APersistentSet.impl>]
08:02justin_smithso there's the field for you
08:03rritochHmm
08:03justin_smithI guess you would want to .setAccessible or something on it
08:03rritoch,(.getDeclaredField clojure.lang.IPersistentMap "impl")
08:03clojurebot#<NoSuchFieldException java.lang.NoSuchFieldException: impl>
08:04rritoch,(.getDeclaredField clojure.lang.IPersistentSet "impl")
08:04clojurebot#<NoSuchFieldException java.lang.NoSuchFieldException: impl>
08:04justin_smith&(.setAccessible (last (.getDeclaredFields clojure.lang.APersistentSet)))
08:04lazybotjava.lang.SecurityException: You tripped the alarm! clojail.testers.ClojailWrapper@78f78a33 is bad!
08:04justin_smithhahaa
08:04justin_smith,(.setAccessible (last (.getDeclaredFields clojure.lang.APersistentSet)))
08:04clojurebot#<IllegalArgumentException java.lang.IllegalArgumentException: No matching field found: setAccessible for class java.lang.reflect.Field>
08:04justin_smithhrmph
08:04rritoch,(.getDeclaredField clojure.lang.APersistentSet "impl")
08:04clojurebot#<Field final clojure.lang.IPersistentMap clojure.lang.APersistentSet.impl>
08:05rritoch,(. setAccessible (.getDeclaredField clojure.lang.APersistentSet "impl"))
08:05clojurebot#<CompilerException java.lang.RuntimeException: Unable to resolve symbol: setAccessible in this context, compiling:(NO_SOURCE_PATH:0:0)>
08:05rritoch,(. setAccessible (.getDeclaredField clojure.lang.APersistentSet "impl") true)
08:05clojurebot#<CompilerException java.lang.RuntimeException: Unable to resolve symbol: setAccessible in this context, compiling:(NO_SOURCE_PATH:0:0)>
08:05rritoch,(.setAccessible (.getDeclaredField clojure.lang.APersistentSet "impl") true)
08:05clojurebotnil
08:05rritoch:)
08:06rritoch,(def a (set [1]))
08:06clojurebot#'sandbox/a
08:06justin_smithahh, I forgot the arg
08:07rritoch,(.get (.getDeclaredField clojure.lang.IPersistentMap "impl") a)
08:07clojurebot#<NoSuchFieldException java.lang.NoSuchFieldException: impl>
08:07rritoch,(.get (.getDeclaredField clojure.lang.APersistentSet "impl") a)
08:07clojurebot#<IllegalAccessException java.lang.IllegalAccessException: Class sandbox$eval237 can not access a member of class clojure.lang.APersistentSet with modifiers "final">
08:07rritoch:(
08:07rritochSo close
08:09rritochThough clojurebot should really be blocking that setAccessible
08:10rritochAnyhow, I think this is finally going to compile, but that may take awhile since this is my first attempt... I'm better off just testing outside of sandbox.
08:12rritochHmm
08:12rritochThat error isn't from the bot, I get the same error about accessing finals from repl
08:13rritochlooks like I'll need to strip off the final and make it public
08:13justin_smith&(.setFinal (last (.getDeclaredFields clojure.lang.APersistentSet)) false)
08:13lazybotjava.lang.SecurityException: You tripped the alarm! clojail.testers.ClojailWrapper@6faf8224 is bad!
08:13justin_smith,(.setFinal (last (.getDeclaredFields clojure.lang.APersistentSet)) false)
08:13clojurebot#<IllegalArgumentException java.lang.IllegalArgumentException: No matching method found: setFinal for class java.lang.reflect.Field>
08:13rritochHmm
08:13justin_smithblergh (works in my repl)
08:14rritochDoesn't work in mine
08:14justin_smithoh wait, never mind
08:14rritochWhere you able to see what is in the impl by default?
08:14justin_smithI missed the error with the reflection warning in my repl
08:17rritochWell, build time was 4 minutes 55 seconds, I just need to rebuild, install, and restart my repl and I should be able to see what is in the impl
08:18rritochOnce we have that it should be easy to figure out why set's are acting differently thanmaps
08:19justin_smithrritoch: I expect you will find the keys are the hashes, created via .hashCode
08:20rritochjustin_smith: Probably, but I really thought impl would be a PersistentMap
08:21justin_smithright
08:21rritochEither way, there should be consistency between hashes and maps so we probably just found a bug
08:21justin_smitha map, with hash codes as keys, and maybe vectors as the vals?
08:21justin_smithnot so sure of that
08:24rritochI just hope hicky doesn't mind that I'm jailbreaking my clojure runtime, lol
08:25rritochWhere is clojure's licence?
08:25rritochI really should have read that first
08:25Bronsait's the EPL, you can do whatever you want with your runtime
08:25rritochOk, good :)
08:28MorgawrI have a very long string I need to wrap around multiple lines (for a lib I'm making) and I want to split it every X characters and turn it in a list of strings (or vec or whatever)
08:28Morgawrhow can I do that?
08:31rritoch,(partition 2 "ABCDEF")
08:31clojurebot((\A \B) (\C \D) (\E \F))
08:31rritoch,(map str (partition 2 "ABCDEF"))
08:31clojurebot("clojure.lang.LazySeq@be2" "clojure.lang.LazySeq@c22" "clojure.lang.LazySeq@c62")
08:31rritochhmm
08:31Morgawrrritoch: need apply str, but yeah thanks :)
08:31rritoch,(map pr-str (partition 2 "ABCDEF"))
08:31clojurebot("(\\A \\B)" "(\\C \\D)" "(\\E \\F)")
08:32Morgawr(map (partial apply str) (partition 2 "ABCDEF"))
08:32Morgawr,(map (partial apply str) (partition 2 "ABCDEF"))
08:32clojurebot("AB" "CD" "EF")
08:32rritochyep :)
08:33rritoch,(map (comp apply str) (partition 2 "ABCDEF"))
08:33clojurebot#<ArityException clojure.lang.ArityException: Wrong number of args (1) passed to: core/apply>
08:33rritoch,(map (comp str apply) (partition 2 "ABCDEF"))
08:33clojurebot#<ArityException clojure.lang.ArityException: Wrong number of args (1) passed to: core/apply>
08:34rritochHmmm, guess not
08:36rritochAnyhow, I have this jailbroken, so let's see
08:37rritochBack to the source code
08:38rritochimpl is a PersistentHashMap
08:38rritochSo sets and maps should behave the same, but they aren't
08:40rritoch,(deftype IgnoreParent [parent y] clojure.lang.IPersistentList (equiv [this o] (and (instance? (class this) o) (= (.y o) (.y this)))))
08:40clojurebotsandbox.IgnoreParent
08:41rritoch,(def a (IgnoreParent. 2 1))
08:41clojurebot#<CompilerException java.lang.IllegalArgumentException: Unable to resolve classname: IgnoreParent, compiling:(NO_SOURCE_PATH:0:0)>
08:41rritoch,(deftype IgnoreParent [parent y] clojure.lang.IPersistentList (equiv [this o] (and (instance? (class this) o) (= (.y o) (.y this)))))
08:41clojurebotsandbox.IgnoreParent
08:41rritoch,(def a (IgnoreParent. 2 1))
08:41clojurebot#'sandbox/a
08:42rritoch,(def b {a "1"})
08:42clojurebot#'sandbox/b
08:42rritoch,(.containsKey b (IgnoreParent. 3 1))
08:42clojurebotfalse
08:43profilis it possible to break free from the surrounding list in this example https://clojuredocs.org/clojure.core/hash-map#example_542692cfc026201cdc326e23 ? I want to return a map directly
08:43Bronsarritoch: plase don't abuse clojurebot. you can query it to get a repl
08:45rritochBronsa: This isn't meant to be abusive, the issue is why does this deftype behave differently within sets than it does within maps
08:45Bronsarritoch: I meant it as "don't spam #clojure with your repl experiments"
08:48rritochOk, I'll just use pastebin
08:59rritochjustin_smith: I'm exposing PersistentMap/root now in my latest build to see why this is happening. I'm starting to think the first soluion of making a custom map type by overriding containsKey would be an easier route for this issue.
09:02rritochIs there any way to more quickly compile clojure than by just running ant? Each rebuild takes 5 minutes
09:13Bronsarritoch: I use mvn -Dmaven.test.skip=true install
09:15Bronsarritoch: s/install/package/ if you don't want to install the snapshot jar in your local maven cache
09:16rritochBronsa: Ok, I haven't actually tried to just use mvn install after my changes, I've been compiling first with ant
09:17rritochBah!
09:17rritochI figured out the issue, I'm again mistaking persistenthashmap with persistentmap
09:18rritochWhen using {} it isn't a persistenthashmap, which is why maps behave differently than sets when dealing with a typedef that has equiv method overridden
09:20rritochEither way, the root of a persistenthashmap is the $BitmapIndexedNode so the rest should be easy to figure out
09:25rritochjustin_smith: You were right, PersistentArrayMaps use Util.equiv for comparison, and sets are using the hash from Util.hasheq
09:25rritochIsn't that a bug though, shouldn't all of clojure use the same method to determine equivalence?
09:25rritochUnless explicity overridden?
09:26Bronsarritoch: can you summarize the issue for me?
09:27rritochprofil: Posted the problem of creating objects that within a set would be considered equivalent even if they have different parents
09:27rritocherr, Bronsa:
09:28rritochanyhow... I thought it could be done by creating an IPersistentMap deftype with a custom equiv
09:29rritochBut while they pass equivalency tests in clojure, they're not considered the same within sets, justin_smith thought it was because of the hashes, but to verify it I exposed a few final vars in clojure so I could verify
09:29rritochSo now the problem is if there's a way to get the hashes to also match
09:30rritochSo they'll behave correctly within sets
09:34rritochAs far as I can tell now, the only way to do it is to provide a custom impl to the set (or just pass a PersistentArrayMap to the set as the impl).
09:34rritochSince I don't think overriding "hashCode" is a good idea, even if it is possible.
09:35rritochI never tried.
09:38rritochLooking at this code it would be possible to implement IHashEq, not an easy task without knowledge of cryptography, and generate hashes that only use the child data.
09:40rritochBut either way, shouldn't sets be using PersistentArrayMaps instead of PersistentHashMaps by default to provide consistency across clojure in evaluating equivalency?
09:47rritochprofil: Here is the a final solution that works ,(deftype IgnoreParent [parent y] clojure.lang.IPersistentList (equiv [this o] (and (instance? (class this) o) (= (.y o) (.y this)))))
09:48rritochprofil: By implementing equiv and hasheq you get equivalence and the same hashes so they should work the way you need them to.
10:31timvisher-xubuntmacros are written in jvm clojure land for clojurescript, right? so shouldn't i just be able to (require '[clojure.tools.trace :refer-macros [trace]]) in a clojurescript file?
10:33dnolen_timvisher-xubunt: won't work if tools.trace includes runtime defs
10:36timvisher-xubuntdnolen_: also doesn't work if trace isn't a macro :)
10:37dnolen_timvisher-xubunt: in general very few macros tend to work that don't have explicit ClojureScript support in mind
10:37timvisher-xubuntoof. it does use clojure.pprint though, and that sadly still has not been ported. :(
10:37dnolen_timvisher-xubunt: yep there's been a ticket for that for a very long time - still no takers
10:37timvisher-xubuntturns out trace is a pretty simple function. for some reason i thought it was a macro
12:03mattreplif one had a large-ish csv file (1.3gb size, 2m lines), how would one read that file into a nested vector, where the outer vector contained an element for each record from the csv, and the inner vectors contain an element for each field. The fields are stored as strings.
12:05mattrepltrying the obvious: (vec (data.csv/read-csv rdr)), which results in huge memory usage
12:06jeremyheilermattrepl: that's a lot of data, so yeah, it'll be huge in memory
12:06mattreplthinking it was something about the implemetnation of LazySeq and Cons cells which I don’t understand, I also tried using doseq over the read-csv result and conj!’ing into a transient vector. that also blows up memory
12:06gfredericksmattrepl: yeah memory should be about the same either way
12:07mattreplbut you’d think 8gb (max heap size) would be sufficient?
12:07gfredericksmattrepl: does the jvm crash?
12:07gfredericksnot sure what "blows up memory" means
12:07gfredericksI agree it sounds like it should fit
12:07mattreplno crashing, I mean it reaches the maximum size and chugs along, but garbage collection is constantly occurring
12:57justin_smith$mail rritoch I think it is likely about that java truism that you need to override hashCode if you override =. The way in that StackOverflow answer is actaully the simple way to do it. http://stackoverflow.com/questions/26622511/clojure-value-equality-and-sets/26622863#26622863
12:57lazybotMessage saved.
13:17Guest89063I read an article about clojure web programming the other day
13:18Guest89063I had an example with HTML marked up as a big nested clojure map
13:18Guest89063It looked horrific
13:19Guest89063Are there any options for clojure templating that allow for embedding into HTML? a la integrated ruby or php?
13:27justin_smithI don't have messages for nick changes turned on, but if Guest89063 is still around, yes, there are a number of options for html templating with Clojure
13:29seangroveJesus christ though, 230 lines
13:29seangroveFor the initial commit
13:29seangroveThe node world is causing me sadness
13:35gfredericks~Guest89063 was a fleeting visitor who quickly disappeared into the night
13:35clojurebotGabh mo leithscéal?
13:35gfredericks~Guest89063 |was| a fleeting visitor who quickly disappeared into the night
13:35clojurebotIk begrijp
13:35gfredericksare those the same language?
13:36justin_smithwelsh and dutch I think
13:37justin_smithirish and dutch?
13:43superbobI need a bugfix in master of freact. How do I pull unreleased libs into my projects?
13:44justin_smithsuperbob: react, the javascript lib?
13:45superbobjustin_smith: Sorry, I meant "freactive": http://documentup.com/aaronc/freactive
13:45justin_smiththat's much easier
13:45justin_smithdownload, fix, change the group (or at least the version string) and run lein install
13:46justin_smithafter that you can use the newer version by asking for that group / version
13:46justin_smithyou can put it on clojars with "lein deploy clojars"
13:46justin_smithbut usually lein install is enough
13:46superbobExcellent, thanks.
13:47superbobnpm has 'npm link', which is super handy.
13:47superbobFor this sort of thing.
13:49justin_smithsuperbob: that's almost identical to lein checkout deps
13:49justin_smithbut I actually like lein install better, it's simpler imho
13:49justin_smithsuperbob: here's how to do that with lein https://github.com/technomancy/leiningen/blob/master/doc/TUTORIAL.md#checkout-dependencies
13:50superbobCool. Cheers.
13:50justin_smithit doesn't mention how to make the links though, but that's not super hard "ln -s /full/path/to/target place"
14:12dnolen_ClojureScript now has vars - the static parts that make sense anyway
14:13dnolen_ns-interns & doc work on master - also working on a largely compatible rewrite of clojure.test w/ an eye towards alternate tests reports and core.async support
14:13dnolen_which means testing support will be built in - :none will work
14:14gfrederickswoah vars
14:15seangroveAh, damn. If I update my version of clojurescript and get a NPE with cljsbuild, what am I missing? This happens frequently enough that I recognize it, but I don't remember the cause
14:15dnolen_seangrove: wrong version of Clojure usually
14:16seangroveThat makes sense
14:16gfredericksdnolen_: is there a writeup somewhere on the design so I don't have to resist peppering you with questions?
14:17dnolen_gfredericks: it's pretty simple there are still no first class namespaces and there vars are not first class, you can only do static things (i.e. no resolve)
14:17Bronsadnolen_: I'm a bit worried about the evaluation semantics of metadata on the def symbol
14:18Bronsadnolen_: in clojure that metadata is always evaluated, in cljs it looks like only :test meta will be evaluated now ?
14:18gfredericksdnolen_: any of the indirection that clj-jvm has on var usage?
14:18dnolen_Bronsa: for now, not really interested in supporting the general case at the moment
14:19dnolen_Bronsa: I just want to fix testing once and for all and provide the infrastructure so that people can build things properly i.e. not like clojurescript.test :)
14:21Bronsadnolen_: gotcha, it's just causing me a bit of pain for t.a.js but I can deal with it
14:21Bronsadnolen_: btw https://github.com/clojure/clojurescript/commit/54b75eca6fdb6a5959253a9b2addbcf3119567a7#commitcomment-8863289
14:21dnolen_Bronsa: yeah definitely has to be done in a semi-hacky way but this is pretty big portability win IMO.
14:23dnolen_Bronsa: I don't really understand the problem with that
14:23Bronsa,`(defmacro var [])
14:23clojurebot(clojure.core/defmacro var [])
14:23Bronsa,`(var 1)
14:23clojurebot(var 1)
14:24Bronsa,*ns*
14:24clojurebot#<Namespace sandbox>
14:24Bronsathat's not going to return '(sandbox/var 1)
14:25Bronsadnolen_: meaning that if a user namespace shadows cljs.core/var, ns-interns will pick that rather than cljs.core/var
14:28seangroveI don't suppose there's much cljs could do to throw a more useful stack trace here, is there? http://dl.dropbox.com/u/412963/Screenshots/k6.png
14:30dnolen_seangrove: core.async could maybe do something - not specifically a cljs thing
14:30dnolen_gfredericks: what do you mean "indirection"?
14:31seangrovednolen_: Ah, yes, that's what I meant, sorry. I wonder if there's a way to be devtools-friendly with this stuff
14:31dnolen_seangrove: probably, I suspect someone with some time on their hands could do something nice instrumenting for core.async under Chrome DevTools
14:32dnolen_Bronsa: hrm that's actually not enough, #'foo is a reader thing
14:34gfredericksdnolen_: I mean that it's logically an extra hop; so e.g., the behavior of (def x 42) (defn get-x [] x) (alter-var-root #'x inc)
14:34gfredericksperhaps ^ that sort of thing doesn't apply somehow?
14:34dnolen_gfredericks: vars aren't actually a fully reified thing this what I saying about "static" earlier.
14:34gfredericksso I'm curious what doc does
14:34dnolen_gfredericks: the vars in ClojureScript are just user space hooks into the information in the analyzer
14:35gfredericksoh interesting
14:35Bronsadnolen_: ah damn. so it's either making var a special form in cljs too or tweaking tools.reader
14:35dnolen_Bronsa: actually you have to change the reader, special form isn't enough
14:36dnolen_#'foo -> (var foo) via the reader
14:36Bronsadnolen_: right, but if var is a special form there's no chance of shadowing it via macros.
14:37dnolen_Bronsa: ah hmm
14:37Bronsathat's why it works in clj
14:37Bronsadnolen_: you chose what you prefer, I have no issues about opening the dispatch table in t.reader
14:38dnolen_Bronsa: ah right, I think special form is better in this case.
14:38Bronsaok
14:44dnolen_Bronsa: ah ok, I had forgetten that var could not be shadowed in Clojure (I know you were saying this but wasn't sinking in)
14:47superbobClojurescript question; when I eval (.replace "12121212" "2" "z") in the browser, I get "1z121212"
14:48superbobAll instances of 2 should become z, according to the docs.
14:48superbobAm I doing something daft?
14:49justin_smithsuperbob: is there .replaceAll like there is in java?
14:49superbobThere's not.
14:50justin_smithwhat about "2/g" instead of "2"
14:50justin_smithor more likely it would be "/2/g"
14:50Bronsasuperbob: have you tried using clojure.string/replace?
14:51superbobBronsa: Doh, thanks.
14:51superbobBronsa: I'd just assumed that's what I was using.
14:51Bronsanp
14:52Bronsa.replace is interop
15:45dnolen_Bronsa: thanks for the sanity check, var is now a special https://github.com/clojure/clojurescript/commit/91153fa7d26f55cc466ac1d24184ba78bac7cf72
15:48bbloomdnolen_: static var support!!
15:48bbloommmmm #' yum
15:49dnolen_bbloom: yep :)
15:53bbloomdnolen_: https://github.com/brandonbloom/clojurescript/compare/var-form~3...var-form?expand=1 <- old but familiar :-)
15:55dnolen_bbloom: heh for sure, definitely never completely thought it was a bad idea, the renewed interest driven by wanting to get clojure.test properly ported
16:19CaptainLexI'm getting this error
16:19CaptainLex"Java.lang.ClassCastException: null"
16:20CaptainLexno other trace
16:20CaptainLexor line number
16:20CaptainLexIs there some category of problems that can cause this kind of nonsense?
16:22gfredericksCaptainLex: doesn't sound familiar; where are you seeing that? at the repl?
16:22CaptainLexgfredericks: I'm seeing it in LightTable. I tried to reproduce it in the repl but I don't have a main so I don't think lein jacked in
16:23CaptainLex(I also asked in the LT room, but that place is a ghost town)
16:24andyfTwo possibilities I can think of (but I don?t use LightTable): There is an option when you start a JVM that disables some optimizations that can cause stack traces to be eliminated.
16:25andyf(2) LightTable is postprocessing some or all stack traces to try to clean them up, and is too aggressive in this case.
16:26andyfFor the first possibility, see: http://stackoverflow.com/questions/4659151/recurring-exception-without-a-stack-trace-how-to-reset
16:26amalloyandyf: my money is on (1)
16:26andyfLooks like the JVM option that should prevent the optimization in question is -XX:-OmitStackTraceInFastThrow
16:26andyfI don't know if there is an easy way to make LightTable use that when it starts a JVM.
16:28andyfHere is a project.clj file that has that command line option enabled by default, which it appears someone uses with LightTable, but will work for anything that uses Leininge: https://github.com/stoyle/clojure-workshop/blob/master/project.clj
16:30andyfamalloy's money is good enough for me :-) (insert nice thing to amalloy here that lets me stay on for another 24 hours)
16:39CaptainLexThanks guys! Unfortunately a preponderance of issues and time constraints have pushed me to switching this particular project to JavaScript
16:39CaptainLexSo this'll just be one for the ages
16:40gfredericksha
16:41gfredericks~java.lang.ClassCastException is time to rewrite in JavaScript
16:41clojurebotAlles klar
16:42amalloyuncaught type error: undefined is not a function? or however that message goes
16:43andyf"uncaught type error: you are probably using the wrong programming language"
16:44andyf"NPE: Have you considered a career in cosmetic engineering?"
16:46CaptainLexHaha I don't prefer JavaScript either, but it's a language I know and it has the algorithm I need to do this paper for school
16:46CaptainLexI was adapating one in Clojure that was written for a different use case
16:47CaptainLexThe one I found in JS was written for the same one
16:48andyf"WeirdExceptionYouveNeverHeardOfException: You are a fluke of the universe. Give up." (hat tip to National Lampoon's Deteriorata)
16:48CaptainLexHahaha
16:53andyfhmmm. Easter-egg option for creative Eastwood lint warning messages.
16:57mattrepl1.3gb csv file, 2.6m lines, 70 columns. how much heap space would you estimate is used for a nested vector of column values, i.e.: (def data (vec (csv-read rdr)))?
17:01mattreplbetween representation of strings and overhead for persistent vectors, i’d guess ~3gb
17:02mattreplthe actual is ~t0gb
17:03mattreplerr, ~10gb
17:07danneuin my web apps, i've always signed my cookies by default. and i use a signed cookie of {:session-id <UUIDv4>} for authentication. but my friend says it's silly to sign a UUIDv4 since it's already cryptographically secure.
17:08danneubut someone just pointed out to me that RFC 4122 says that UUIDs should not be relied on for security capabilities. - https://groups.google.com/d/msg/datomic/Jo0KJp9JfLA/MwGxH5b_sD4J
17:08danneuis my friend wrong?
17:09danneuor is the RFC just talking about UUIDs in general and not v4 in particular?
17:10andyfmattrepl: How many column values per line on average?
17:10andyf2x is pretty much automatic for ASCII strings read into Java UTF-16 strings.
17:10mattrepleach line has the same, it’s about ~70, many are empty strings
17:11mattreplright, so that’s ~2.6gb, let’s even be generous and round up to 3gb. then 7gb for persistent vectors? something seems wrong…
17:12andyf70 fields per line?
17:12mattreplyes
17:12andyfEach one will be its own Java object with 16 bytes of overhead on a 64-bit JVM (iirc)
17:13andyfif put into a Clojure vector, unless it is one of the primitive vector types, which should use less, I think.
17:14mattreplso we have 2.6m PersistentVectors of 70 String objs each
17:16andyf2.7gigabytes, you mean?
17:17kenrestivoany idea the status of this? http://dev.clojure.org/display/design/%27Lean%27+Runtime i recall that at cljwest, rich endorsed either this or a similar project. did anything ever happen with it?
17:17andyfYeah, it all adds up. I don't have a good guess for how to estimate the other 5 gigabytes you are seeing, but if you are keeping the original line strings around, plus extracted ones, those are copies of each other with Java 7 and later.
17:17mattrepli was counting the number of vectors. but yes, 2.7gb ofor references
17:19mattreploriginal shouldn’t be kept, csv-read returns a LazySeq of PersistentVectors and we consume it (without holding onto head) to create the PersistentVector of PersistentVectors
17:19andyfAre all fields values that are the same type of Java primitive, e.g. long or double? Or is it a mix?
17:20profilWhen checking a value, is there a better way than doing `(cond (= item "something") .. (= item "something2") .. ..)`?
17:21andyfprofil: case is useful if all comparison values are compile-time constants.
17:21mattreplall field vals are strings. no type conversion done by data.csv/csv-read
17:22profilandyf: yeah "something" and "something2" is constant strings
17:22mattreplit looks like references are 8 bytes for 64-bit jvm (which is what i’d expect)
17:22gfredericksdoes anybody know if ThreadLocal is a common jvm technique to reduce allocations of create-and-discard resources?
17:23andyfmattrepl: Yes, for each of your fields in a vector, there is not only the 16 bytes of overhead per String object, put another 8-byte reference in the vector to point to it.
17:23gfredericksand/or if there's any reason it would be inappropriate for that use
17:26mattreplandyf: ok, so that’s 4gb already and that’s not including actual string data. or the references to the nested vectors
17:26andyfmattrepl: If there were a convenient string type in Java that represented strings in memory as UTF-8, it would save significant memory for processing ASCII files.
17:27andyfbut yeah, it wouldn't save all of the pointers or object overheads in this case.
17:28andyfIs it convenient in this application to do the field-splitting on an as-needed basis?
17:28mattreplwas thinking about that, trade time for space savings
17:30mattreplyeah, it’d be fine to do, just makes data.csv less useful. could process a line at a time, but some csv files (not this one though) have multi-line field values
17:31andyfPerl can be nice for some text-file hacking :)
17:31andyfBut having a common language for many tasks is good
17:32andyfgfredericks: How could ThreadLocal's help reduce allocations?
17:34mattreplhah, yes. just crazy that there’s an order of magnitude increase in space for this. having some sort of on-the-fly vector may be useful. in this case just filtering out fields not used for processing will be fine.
17:34amalloyprofil: and if they're not constants, (condp = item ...) expands to your cond
17:34gfredericksandyf: e.g., if you need a byte array for a temporary thing, the ThreadLocal lets you have one per thread, so you don't need to make new ones
17:36andyfmattrepl: It can be surprising until you do the math on what the implementation does. A UTF-8 in-memory string plus value types in a future JVM, taken advantage of by Clojure's vectors, could reduce a lot of this, but those are all just pre-slideware right now
17:37andyfgfredericks: where each thread is mutating its local object over time?
17:37gfredericksandyf: right, presumably resetting it & mashing it for a short time
17:37andyfoh, maybe you mean that rather than repeatedly temporarily allocating and deallocating such an object, the thread just 'caches' the previously-allocated one and uses it again later?
17:38gfredericksbased on the docs ThreadLocal seems like the obvious tool but I haven't really heard of anybody using it
17:38gfredericksandyf: right -- and using ThreadLocal instead of just a single global object makes it threadsafe
17:38gfredericksbut otherwise the single global object accomplishes the same thing
17:39andyfThat sounds similar to lots of C libraries that do their own internal memory mgmt, using malloc only for large chunks, because they believe they can do it better (and maybe they can).
17:39gfredericksright; it's manual mem mgmt for sure
17:40@amalloyhm. that is not working
17:41andyf--- amalloy tweaks settings on the iron fist ---
17:42andyfsorry, still amused by the "rule with an iron fist" comment you made.
17:42@amalloyandyf: feel free. i enjoy being amusing
17:44amalloy$mail technomancy so someone sent me a spam PM and i tried to ban them but i don't think it worked. i tried setting +b on all of '(*!~juuo@213.143.61.98, *!juuo@213.143.61.98, *!~juuo@*) but this juuo person is still in the channel. what am i missing?
17:44lazybotMessage saved.
17:46Bronsaamalloy: you need to kick him
17:46amalloyoh, really?
17:46amalloyBronsa: just issue a +k as well? which of those three forms do i want to use?
17:47Bronsaamalloy: banning will just prevent them from writing/joining but will not kick them
17:47Bronsaamalloy: no just /kick juuo
17:47amalloyk
17:47mattrepland /kickban juuo would do both
17:48Bronsamattrepl: depending on the IRC client /kickban might not be available
17:48mattreplBronsa: true
17:50Bronsaamalloy: you messed something up with the ban
17:50@amalloyBronsa: okay? how to fix? also /kick doesn't seem to be doing anything
17:51Bronsaamalloy: you're kicking him but he's auto-joining back because the ban isn't working
17:51@amalloyoh. i have join/part hidden :P
17:52Bronsaamalloy: just try /mode #metamorphism +b juuo and then /kick juuo
17:52AimHereamalloy, perhaps you need to change the 'juuo' in your banstrings to 'juio'
17:52Bronsaerr amalloy #clojure
17:53@amalloyAimHere: oh, you're right. i read the username wrong
17:53@amalloysuccess!
17:53Bronsayup that worked
17:53@amalloy$unmail technomancy
17:53lazybotDeleted unread messages from amalloy to technomancy
17:53Bronsaamalloy: you're using erc right?
17:54@amalloyBronsa: no
17:54AimHereNow you've got to clear those spare ban entries before the *real* juuo shows up!
17:54@amalloyindeed, AimHere
17:54@amalloyevery few months we have a get-together where everyone teases me for using pidgin
17:54Bronsaheh
17:56amalloythanks for the help, guys
17:56Bronsaamalloy: look at the bright side, now you can kickban those who laugh at you
17:57amalloyBronsa: i've got my eye on andyf
17:59andyfThe eye ... the eye .... can't hide
18:13bitcrusheranyone using cursive?
18:13bitcrusherderping on parens and brackets, it won't let me enter them
18:22justin_smithbitcrusher: do you have structural editing turned on?
18:23bitcrusherprobably on, its on by default
18:23bitcrusherthat might be the problem
18:23bitcrushergonna change that now, see if it fixes the problem, its annoy :/
18:24cflemingbitcrusher: You can turn it off in the status bar at the bottom of the window
18:25bitcrushercfleming: thx
18:26bitcrusherso much better, almost threw my keyboard across the room
18:30cflemingbitcrusher: I'd recommend trying to get used to it, though.
18:31cflemingbitcrusher: It's like touch typing - once you're used to it, you'll wonder how you ever lived without it.
18:32cflemingbitcrusher: It's a pain to learn though.
18:42profilis it possible to use destructuring in a loop? like `(loop [[x y & xs]] ... )`?
18:43Bronsa,(loop [[a] [1]] a)
18:43clojurebot1
18:45profilBronsa: ah, so I want `(loop [[x y & xs] THEVECTOR] ... )`?
18:46Bronsawell if thevector is your init value
18:46Bronsa,(loop [[x] [3]] (if (zero? x) x (recur [(dec x)]))
18:46clojurebot#<RuntimeException java.lang.RuntimeException: EOF while reading>
18:46Bronsa,(loop [[x] [3]] (if (zero? x) x (recur [(dec x)])))
18:46clojurebot0
18:50profilBronsa: great, thanks!
18:50gfredericks,(loop [x 42] (if (zero? x) :heyhey (recur ((rand-nth [inc dec]) x))))
18:50clojurebot:heyhey
18:51justin_smith gfredericks: we should make that into a drunken-walk macro
18:52justin_smithwell, it could probably just be a function actually
18:54justin_smith(defn drunk [test init ops] (if (test init) init (recur ((rand-nth ops) init) ops)))
18:54gfredericksforgot a recur arg
18:54justin_smithoh yeah, test should be in there too, of course
18:55rritochWhat is the best/easiest way to get a list of all required (direct and indirect) of the current namespace?
18:55gfredericks,(defn drunk [test init ops] (if (test init) init (recur test ((rand-nth ops) init) ops)))
18:55clojurebot#'sandbox/drunk
18:56gfredericks,(drunk (fn [[x y]] (< 10000 (+ (* x x) (* y y)))) [0 0] (for [i [0 1] f [inc dec]] #(update % i f)))
18:56clojurebot[-100 1]
18:56rritochI was ableto create namespace isolation using ThreadLocal memory, but for stability I want to copy all dependencies of the current namespace, and the current namespace, into the newly created "isolated" environments
18:56gfredericks,(drunk (fn [[x y]] (< 10000 (+ (* x x) (* y y)))) [0 0] (for [i [0 1] f [inc dec]] #(update % i f)))
18:56clojurebot[100 7]
18:57rritochI'm also considering adding in an assertion to ensure you can't enter a previously created namespacecontainer unless the current namespace already exists in the container.
19:05rritochThis is what I have so far, and in Namespaces.jar the value of the namespaces static final property gets replaced with an instance of this NamespaceContainer
19:06rritochhttp://pastebin.com/vZaAMS53
19:15ortunaWhat is the best way to get run time stack errors on a 'lein ring server' session?
19:15kenrestivoi wrote a library for that, but you could simply write a ring wrapper and log it
19:16kenrestivohttp://github.com/kenrestivo/firealarm (should scrap it and write something around timbre instead, which didn't exist at the time)
19:23amalloybest way to get stack errors? (#(% %) #(% %))
19:26ortuna:D
19:26ortuna@kenrestivo thanks, I'm checking out the wrapper now
19:29kenrestivoamalloy: is that a clojure forkbomb?
19:29amalloykenrestivo: well, it doesn't fork
19:29kenrestivoit looks like two drunk guys staring at me
19:29justin_smithstackbomb
19:30kenrestivo~stackbomb is a great punk rock band name
19:30clojurebotA nod, you know, is as good as a wink to a blind horse.
19:31justin_smithkenrestivo: indeed. Four data structures and a message(queue).
19:36kenrestivo~stackbomb is a good punk rock band name, or (#(% %) #(% %))
19:36clojurebotA nod, you know, is as good as a wink to a blind horse.
19:36rritochI'm just awestruck by the spam ##(into #{} (map (comp type second) (.getMappings *ns*)))
19:36lazybotjava.lang.SecurityException: You tripped the alarm! class clojure.lang.Namespace is bad!
19:38rritochIs it even possible to get a list of dependent namespaces? I expected to see some namespaces in the mappings?
19:38justin_smiththat's not how namespaces work
19:38justin_smitheach var will have a namespace though
19:39justin_smithand you could collect them that way
19:40rritochjustin_smith: Thanks, I can do that, and walk those namespaces to get the list
19:44justin_smith(into #{} (map (comp :ns meta second) (.getMappings *ns*)))
19:45justin_smithhmm ##(into #{} (map (comp :ns meta second) (.getMappings *ns*)))
19:45lazybotjava.lang.SecurityException: You tripped the alarm! class clojure.lang.Namespace is bad!
19:45justin_smithtoo bad
19:48rritochWell I just learned my lesson about using in-ns
19:48justin_smithanother good one ##(.getAliases *ns*)
19:48lazybotjava.lang.SecurityException: You tripped the alarm! class clojure.lang.Namespace is bad!
19:48justin_smith:P
19:48rritochCompilerException java.lang.RuntimeException: Unable to resolve symbol: into
19:48justin_smith(refer 'clojure.core)
19:48justin_smiththat fixes it
19:49justin_smithwell, (clojure.core/refer 'clojure.core) is more like what you need
19:49justin_smithand of course you can just use ns
19:49justin_smithwhich does that for you
19:49rritochjustin_smith: Well I just did an in-ns back to user and that recovered my repl
19:50justin_smiththere is nothing to "recover" though. It's just a namespace without the default mappings, but you can still use clojure.core/* explicitly
19:51rritochWell, I have the first part of this puzzle solved (into #{} (map #(.ns %) (filter var? (map second (.getMappings *ns*)))))
19:52rritochjustin_smith: I'm just not sure how to best do a recursion, typically in this case I'd check if anything new was added to the list since the last sweep, but I've never needed something like that in clojure.
19:54justin_smithyou could use set/difference to get anything in the new set that was not in the previous
19:54justin_smithif you have both handy
19:55justin_smith##(clojure.set/difference #{1 2 3} #{1 2 3 4})
19:55lazybot⇒ #{}
19:55justin_smith##(clojure.set/difference #{1 2 3 4} #{1 2 3})
19:55lazybot⇒ #{4}
19:55justin_smithBronsa: it would be awesome if you did!
19:56Bronsajustin_smith: well CLJ-979 CLJ-1457 CLJ-1544 and CLJ-130 now all have patches. now I just need to convince puredanger to include them for 1.7
19:56justin_smiththat's awesome
19:56rritochThat would require two sets, and possibly doing a double sweep
19:57justin_smithrritoch: how does one find a difference without having the previous result handy?
19:57justin_smithyou need the old result no matter what
19:58rritochI should be able to do loop [m #{} c (count m)] ... (recur (...) (count m)
19:58rritochjustin_smith: I don't need the difference really, I just need to know if anything new's been added since the last loop, I really don't care what was added in each iteration
19:58justin_smithwait, what are you even trying to do?
19:58justin_smithOK, right, and in order to know if anything has changed, you need the previous result
19:58justin_smithand a new one
19:59rritochTrying to get all deep namespace dependencies of the current namespace
19:59rritochFrom clojure first, then xlate it to java
20:00rritochjustin_smith: I'm using a set though, since I'll only be adding to the set a count of the number of items in the set is sufficient to determine if anythings been added
20:00justin_smithOK, you still need to generate the set twice, and set/difference provides more information than count does
20:00justin_smithbut whatever works
20:02rritochjustin_smith: This is actually a fairly common type of recursion, I'm surprised there's no utility that simplifies the process
20:03rritochThis is probably a good case for a transducer though
20:04rritochMy usual pattern for this case is to use (flatten (map ....)) when the function can produce a list that needs to be added
20:05rritochjustin_smith: And I need that entire function repeated until it doesn't produce anything new
20:06andyfrritoch: This is what is used in the tools.namespace lib: https://github.com/clojure/tools.namespace/blob/master/src/main/clojure/clojure/tools/namespace/dependency.clj#L52-L63
20:06rritochActually, that isn't going to work. I can only check each namespace once, otherwise a race condition could turn this into an infinite loop
20:06rritochandyf: Checking that now ...
20:11rritochandyf: Yeah, that's good. I didn't think of mapcat
20:13profilHow would I go about sorting a vector with maps by the length of one of the values? "[{:key '(1 2 3 4)} {:key '(1 2 3)}]"
20:15andyfprofil: something like (sort-by (fn [x] (count (:key x))) my-vec)
20:15justin_smith&(sort-by (comp count :key) [{:key '(1 2 3 4)} {:key '(1 2 3)}])
20:15lazybot⇒ ({:key (1 2 3)} {:key (1 2 3 4)})
20:16profilI dont understand the comp function, is it like haskell's (.)?
20:17justin_smithas opposed to ##(sort-by :key [{:key '(1 2 3 4)} {:key '(1 2 3)}])
20:17lazybotjava.lang.ClassCastException: clojure.lang.PersistentList cannot be cast to java.lang.Comparable
20:17justin_smithprofil: that sounds right. It is classical function composition like from math class.
20:18profiljustin_smith: so your example is a function like "(count (:key X))" where X is the input?
20:18justin_smithright
20:19profiljustin_smith: and if I wanted to sort by another value also, would this be correct "(sort-by (juxt (comp count :key) :otherkey) vector)"?
20:20andyfyep
20:20profil&(sort-by (juxt (comp count :key) :otherkey) [{:key '(1 2 3 4) :otherkey 10} {:key '(1 2 3) :otherkey 12}])
20:20lazybot⇒ ({:key (1 2 3), :otherkey 12} {:key (1 2 3 4), :otherkey 10})
20:20profilalright, thanks guys
20:21rritochandyf: It is really too bad that transitive function is private, this function would be good for clojure.core
20:22andyfYou can use it even though it is private, e.g. (#'name.space/private-fn-name args)
20:23andyfor if your project has a compatible license, just copy the source code into it.
20:24rritochWell, right now I'm just in repl so I'm just going to copy the source :)
20:29rritochI'm not sure how to test if it's working, but I think this worked
20:30rritoch(defn direct-deps [ns] (into #{} (map #(.ns %) (filter var? (map second (.getMappings *ns*))))))
20:30rritoch(transitive direct-deps (conj #{} *ns*))
20:31rritochAs far as I can tell I think that gave me all of the dependencies (deeply)
20:31justin_smith,(= (conj #{} *ns*) #{*ns*})
20:31clojurebottrue
20:32gfredericksback to fun with regexes
20:32ortunadoes clojure do cache/tail call optim. when calling a function in a look multiple times?
20:32ortunaloop*
20:32justin_smithortuna: well, recur is always a tail call
20:32gfredericksortuna: probably not, but I can't tell what you mean so you might want to give an example
20:32justin_smithbut it doesn't cache
20:32rritochgfredericks: That is the first time I've heard anyone use the word fun and regex in the same sentance.
20:33gfredericksrritoch: I think I just learned that \Q...\E inside [...] is a NOOP
20:33justin_smithortuna: you may want to memoize your function
20:36ortunajustin_smith: yes, was wondering if I need to do that. I have a function call to foo within a doseq. foo also calls a (.getWidth bufferedimage). Since bufferedimage is not different between each iteration will this be optimized? I know the proper thing to do is memoize it which I will do, but it made me wonder because the executing is very fast(not expected after ~ 130,000 calls).
20:37justin_smithortuna: I would be surprised if .getWidth was doing any calculation at all
20:37justin_smithimage formats hold their width as a static bit of data
20:37justin_smithit should be a simple lookup
20:38justin_smiththere is an open source jdk (or you could just profile it) if you want to double check that though
20:39ortunajustin_smith: I'll take a look, still new to clojure so figuring the Clojure/Java world out :D
20:40justin_smithcriterium is great for microbenchmarks like "how long does it take to run .getWidth on a BufferedImage"
20:40justin_smith$google clojure criterium
20:40lazybot[hugoduncan/criterium · GitHub] https://github.com/hugoduncan/criterium
20:40ortunaoo thanks
20:40justin_smithI suggest having it as a dep in ~/.lein/profiles.clj so it's always available during dev
20:40TEttingergfredericks: were you the one who asked about \pC in regexes?
20:44gfredericksTEttinger: yeah
20:45TEttingerit's a weird one huh. did you get my reply?
20:45gfredericksyep
20:45gfredericksI probably inc'd you too
20:45TEttingerhaha thanks
20:46gfredericks(inc TEttinger) ;; for good measure
20:46lazybot⇒ 32
20:46TEttingerthose categories are mostly useful, but \pC matching \n but not \space is weird
20:46TEttingerdanke
20:47gfredericksTEttinger: I'm trying to parse regexes and it's the hairiest thing ever
20:47TEttingeroh man
20:47TEttingerhave you read the unicode standard yet?
20:48TEttingerit's only what, 2500 pages...
20:48gfredericksI'm about to try to figure out by exhaustive experimentation what '&' means inside [...]
20:48TEttingernvm 1472 pages
20:49TEttingerit doesn't mean literal ampersand?
20:50TEttingeroh geez gfredericks http://www.regular-expressions.info/charclassintersect.html
20:52gfredericksTEttinger: exactly
20:52gfredericksoh crap I forgot to parse negation
20:52TEttinger&(re-seq #"[a-z&&[^aeiuo]]" "The quick brown fox")
20:52lazybot⇒ ("h" "q" "c" "k" "b" "r" "w" "n" "f" "x")
20:53gfredericksnegation makes intersection more interesting
20:53TEttinger&(re-seq #"[[^kq]&&[a-z]&&[^aeiuo]]" "The quick brown fox")
20:53lazybot⇒ ("h" "c" "b" "r" "w" "n" "f" "x")
20:53devngfredericks: did you know that in 1567 the man people claimed to have the longest beard in the world died by tripping over his own beard while running away from a fire?
20:54gfredericksdevn: no
20:55TEttingerdevn, glad my beard is trimmed then
20:55devngfredericks: the hello world program you wrote earlier on twitter was really impressive
20:56justin_smiththe rate of death by tripping and falling over things is my favorite counter-argument to over concern about things that are scary but statistically irrellevant
20:56gfredericksjustin_smith: what is that rate?
20:57justin_smithhttp://www.cdc.gov/nchs/fastats/accidental-injury.htm
20:57andyfgfredericks: Aren't there existing libs that parse regexes you might use/
20:57andyfuse?
20:57clojurebotOnly use :use with :only.
20:57devngfredericks: also, you forgot thong.
20:57andyfSeems like a lot of work to get all the cases right.
20:58devngfredericks: wait, that's unvoiced.
20:58profiljustin_smith: how do I say that I want to sort largest first in my last example?
20:58gfredericksandyf: this is difficult to google for because of all the people trying parse random things with regexes
20:59gfredericksanother day, another person in #clojure telling me I forgot thong.
20:59profil&(sort-by (juxt :otherkey (comp count :key)) [{:key '(1 2 3 4) :otherkey 10} {:key '(1 2 3) :otherkey 12}])
20:59lazybot⇒ ({:key (1 2 3 4), :otherkey 10} {:key (1 2 3), :otherkey 12})
20:59justin_smithprofil: sort-by takes an extra comparitor function
20:59justin_smith(doc sort-by)
20:59clojurebot"([keyfn coll] [keyfn comp coll]); Returns a sorted sequence of the items in coll, where the sort order is determined by comparing (keyfn item). If no comparator is supplied, uses compare. comparator must implement java.util.Comparator. If coll is a Java array, it will be modified. To avoid this, sort a copy of the array."
20:59profil&(sort-by (juxt :otherkey (comp count :key)) > [{:key '(1 2 3 4) :otherkey 10} {:key '(1 2 3) :otherkey 12}])
20:59lazybotjava.lang.ClassCastException: clojure.lang.PersistentVector cannot be cast to java.lang.Number
20:59devngfredericks: im serious though, i was thoroughly impressed by your hello world implementation. "hi everyone" is one of the shortest I've seen in the wild.
21:00profiljustin_smith: as you see I cant use '>'
21:00justin_smithprofil: > is not a comparitor
21:00andyfhttp://weitz.de/cl-ppcre/
21:00andyfCommon Lisp, but maybe useful.
21:01justin_smith&(sort-by (juxt :otherkey (comp count :key)) (comp - compare) [{:key '(1 2 3 4) :otherkey 10} {:key '(1 2 3) :otherkey 12}])
21:01lazybot⇒ ({:key (1 2 3), :otherkey 12} {:key (1 2 3 4), :otherkey 10})
21:02justin_smith(comp - compare) reverses the default comparator
21:02gfredericks devn: it's the same length as "hello world"
21:02profiljustin_smith: oh, thats handy
21:03devngfredericks: yes, but "hi everyone" handles the printing too
21:03gfredericksandyf: and it would have to be a lib aimed at parsing JVM regexes in particular
21:04justin_smithprofil: the trick there being compare always returns a number indicating which input was larger ##(compare [0 1 2] [1 2 3])
21:04lazybot⇒ -1
21:04justin_smith&((comp - compare) [0 1 2] [1 2 3])
21:04lazybot⇒ 1
21:05justin_smith(flip compare) would be good for that too, if we had flip in clojure.core
21:07ShoopI need some help implementing four-letter word ladders (http://en.wikipedia.org/wiki/Word_ladder) in clojure. I created a hashmap of dictionary words to appropriate peers that are also dictionary words. However, I'm having trouble figuring out how to implement depth-first search to find the shortest "ladder" between 2 four-letter words. Can anyone give me a hand?
21:13gfredericksShoop: you want undirected graph algorithms
21:14justin_smithyeah, there is probably something in the gremlin lib that would just spit out the answer
21:14gfredericksprobably breadth-first makes more sense
21:14justin_smithyeah, especially given the guaratneed ubiquity of cycles
21:19gfredericks,#"[&&&a]"
21:19clojurebot#<NoClassDefFoundError java.lang.NoClassDefFoundError: Could not initialize class java.util.regex.PatternSyntaxException>
21:19gfredericks,#"[a&&&]"
21:19devnis there a lib with A* in it already?
21:19clojurebot#"[a&&&]"
21:23profiljustin_smith: that comparator will affect both sorts, I want to sort the shortest list but the highest number, how do I achive that?
21:29devnah, i should have guessed! http://clj-me.cgrand.net/2010/09/04/a-in-clojure/
21:29devnand another from aria over at prismatic: https://github.com/aria42/mochi/blob/master/src/mochi/search.clj
21:30devnlast one I promise: http://nakkaya.com/2011/10/10/cheaplist-in-clojure/
21:31devnspeaking of nakkaya, has that guy ever been to the conj or euroclojure or something? he's had an excellent blog with lots of clojure in it since 2009.
21:33justin_smithprofil: in that case, I would use sort, and pass a comparator function that does the right thing to each arg
21:34profiljustin_smith: I solved it by doing (comp - :otherkey)
21:34justin_smithahh, since it's a number that works for that special case
21:40TEttingerdevn, a friend helped me implement a sorta dijkstra-A* hybrid that operates on a plain array http://ideone.com/GsHXtz
21:40andyfgfredericks: devn: What is this hello world / hi everyone you speak of?
21:42david6789hello, I'm sorry the useless shill but I'm testing erc so Hello world!
21:42TEttingerhey david6789
21:42TEttingerit works
21:43CaptainLexWhat when did we start talking about A*
21:43justin_smithandyf: https://twitter.com/gfredericks_/status/541252661526659074
21:43CaptainLexthat's the algorithm that was giving me trouble earlier!!
21:43justin_smithCaptainLex: Shoop wanted something that is solved with A*
21:44justin_smithbut hey, it's a graph algorithm, they are everywhere when you know how to look
21:44Shoop:d
21:44Shoop:d
21:44Shoop:D
21:44Shoopcapitalization is hard when caps lock is on
21:44CaptainLexHaha
22:01gfredericks&#"x??"
22:01lazybot⇒ #"x??"
22:01gfredericks&#"x???"
22:01lazybotjava.util.regex.PatternSyntaxException: Dangling meta character '?' near index 3
22:01gfredericksI love these
22:15amalloygfredericks: these what?
22:22gfredericksamalloy: weird characteristics of jvm regexes
22:26amalloygfredericks: that's a totally normal behavior any regex would have, though?
22:26amalloynot a jvm quirk at all
22:30gfredericksamalloy: I sure don't understand why; what's okay about two question marks but not okay about three?
22:31amalloya ? character after a quantifier (ie, *+?{...}) makes it lazy instead of greedy
22:32justin_smithso ?? means 0 or one, lazy
22:32justin_smith?
22:32amalloy&(for [re [#"bare?" #"bare??"], s ["bar" "bare"]] (re-find re s))
22:32lazybot⇒ ("bar" "bare" "bar" "bar")
22:33gfredericksamalloy: okay, you win this round, but I've got more up my sleeve
22:33amalloyso they're both *willing* to match bar or bare, but with the second ? bar is preferred, whereas without it bare is preferred
22:33gfredericks&#"x*+"
22:33lazybot⇒ #"x*+"
22:33gfredericks&#"x+*"
22:33lazybotjava.util.regex.PatternSyntaxException: Dangling meta character '*' near index 2
22:33amalloygfredericks: + makes quantifiers possessive
22:33gfredericksCRAP
22:33gfrederickswhat does that mean
22:34amalloyit's harder to think of an example for that one :P
22:35amalloy&(for [re [#"x?xy" #"x?+xy"], s ["xxy" "xy"]] (re-find re s))
22:35lazybot⇒ ("xxy" "xy" "xxy" nil)
22:35amalloythe optional+possessive ? in the second regex refuses to backtrack after consuming the first x
22:36gfredericksthis is going to be exciting
22:37amalloygfredericks: the only jvm regex quirk i can remember is #"[][]"
22:38gfrederickslooks like a parse error?
22:38gfredericks&#"[][]"
22:38lazybotjava.util.regex.PatternSyntaxException: Unclosed character class near index 3
22:38amalloywhich is a perfectly valid character class matching any left or right square brakcet, but the jvm refuses it
22:38gfredericksamalloy: do other languages accept that?
22:38amalloyof course. perl does, any other pcre engine does
22:39gfredericksruby doesn't
22:39gfredericksamalloy: the jvm is probably detecting a nested character class
22:39amalloyif you want to include a ] in a character class, the only way is to put it first
22:39amalloythere's no such thing as a nested character class
22:40amalloyoh
22:40amalloy?
22:40gfredericksyou can nest them and intersect them too
22:40gfredericks&(re-matches #"[a[b]c]" "]")
22:40lazybot⇒ nil
22:40gfredericks&(re-matches #"[a[b]c]" "b")
22:40lazybot⇒ "b"
22:41gfredericks&(re-matches #"[a-z&&[^aeiou]]" "b")
22:41gfredericks,(re-matches #"[a-z&&[^aeiou]]" "b")
22:41lazybot⇒ "b"
22:41clojurebot"b"
22:41zarkonehello all! i want to use REPL with ring/compojure applications.. How should I connect?
22:41zarkone
22:42amalloygfredericks: i've never seen that in any regex flavor. is that a jvm thing, or what?
22:42gfredericksamalloy: regular-expressions.info claims that intersection is a java/ruby thing; I think that implies nesting too, cuz I'm not sure why else nesting is useful
22:44amalloyhuh
22:44gfredericksI didn't know this two weeks ago either
22:44amalloyokay, i didn't know about this feature, but i don't see how it impacts the parsing of [][]
22:44gfredericksbecause the second [ starts a new class
22:44amalloyoh, because the open-bracket confuses it
22:45gfredericksinterestingly ruby gives a different error
22:45gfredericksSyntaxError: (irb):3: empty char-class: /[][]/
22:45amalloygfredericks: does it say the same for []]?
22:45gfredericksit also says: warning: character class has ']' without escape: /[][]/
22:45gfredericks/[]]/ just gives the warning
22:46gfredericks/[]/ also gives the empty char class error
22:47amalloysure, [] is illegal
22:47amalloyi can't remember what the "fix" is to get java to treat something like [][], except for the obvious one of throwing in some backslashes
22:47amalloybut i'm pretty sure there is some mess of just square brackets that it understands
22:49amalloygfredericks: i think that weird java/ruby character-class intersection feature is the first thing i've learned about regular expressions in about eight years
22:51gfredericksamalloy: I wonder how many times somebody has abandoned their plans to use a regex after discovering that their language doesn't have character class intersections
22:53andyfRegexes are cool, until you get to the dark corners. I tend to avoid them.
22:53andyfI mean: I tend to avoid the dark corners of regexes. The bright spots I love.
22:54TEttingeramalloy, lucky you, I probably learned about regexes 8 years ago
22:54andyfBut I don't want to implement them over again.
22:55amalloyandyf: most under-appreciated bright spot: /x flag
22:58rritochandyf: For this namespace isolation code I'm making, what is the best way of getting it to be reviewed. Should I make a fork on github?
23:00rritochandyf: It is almost functional. I created a namespace, returned to the user namespace, and entered into an isolation successfully. The namespace I created was no longer there, but everything else was still functional
23:00rritochandyf: THings broke down when I tried to leave the isolated namespace, but I'm repairing that bug now
23:01gfredericks&#"*"
23:01lazybotjava.util.regex.PatternSyntaxException: Dangling meta character '*' near index 0
23:01gfredericks&#"{0}"
23:01lazybot⇒ #"{0}"
23:02gfredericks^ matches the empty string
23:05gfredericksthose curly-bracket quantifiers can handle pretty much any digit string it looks like
23:05gfredericksI'm impressed
23:06TEttinger&(re-seq #"{3}" "")
23:06lazybot⇒ ("")
23:06rritochOk, I have namespace isolation fully functional
23:06TEttingernice rritoch
23:07rritochThis is the code http://pastebin.com/Lg59dMyN
23:07fendgitCould someone please help me by explaining the idiomatic way that I could assoc a new k/v into each 'people' object in this map? http://pastebin.com/VJ1QjHtc
23:07fendgitWhat's throwing me off is that the people array is a few levels deep
23:07rritochIt only requires on change to the existing code, which is documented at the top of the code
23:08fendgitI'm not quite sure how to create an updated copy of the entire map
23:08gfredericksfendgit: look at assoc-in and update-in
23:08justin_smithfendgit: for one thing, that layout of the data structure is not idiomatic for clojure at all
23:08justin_smithbut yeah, assoc-in is exactly what you want
23:09fendgitgfredericks: thanks, will check that out
23:09fendgitjustin_smith: what's wrong with the layout of it? I'm definitely open to suggestions :)
23:10rritoch(clojure.lang.NamespaceContainer/enter) enters and (clojure.lang.NamespaceContainer/exit) leaves. The enter returns a pointer which can be used to return to the namespace in the future after you exit, assuming you can find a way to get data between the isolated areas. Since this is new I'm not exactly sure how that would be accomplished, but probably requires enter/exit/stash/re-enter
23:12justin_smith&(update-in [{:data {:people [{:id 1, :projects [{:id 1, :hours 20}]}]}, :end_date "2014-12-14T05:00:00Z", :start_date "2014-12-01T05:00:00Z"}] [0 :data :people] conj {:id 2, :projects []}) ; fendgit
23:12lazybot⇒ [{:end_date "2014-12-14T05:00:00Z", :start_date "2014-12-01T05:00:00Z", :data {:people [{:projects [{:id 1, :hours 20}], :id 1} {:id 2, :projects []}]}}]
23:13TEttingerfendgit, the main thing is it really doesn't look like clojure with a lone bracket on a new line. also, you can use #inst literals
23:13justin_smithfendgit: I realize now it's json, I had mistaken it for edn at first
23:13fendgitsorry guys, I should've mentioned that at first
23:13fendgit(that it's being output as JSON)
23:13TEttingeroh ok
23:13fendgitI'm grabbing that from a Postgres JSON field
23:13justin_smithfendgit: yeah, I figured that out when I put together my example above
23:14fendgitand so I've got the person ID, but I need to insert the person's name in there as well
23:14justin_smithso yeah, your first step would be to use cheshire to turn it into clojure data
23:14justin_smithfendgit: I am sure you can extrapolate from what I pasted above (the update-in)
23:15fendgitjustin_smith: thanks!
23:15andyfrritoch: If you want to get it reviewed, you can publish it and put a link and description on the Clojure Google group, for example. Unless it implements some feature that someone dearly wants, you may or may not get any response.
23:16rritochandyf: By publish do you mean fork on github?
23:17andyfThat is a pretty easy way to publish it, yes, but any method will do.
23:17rritochandyf: Ok, I'll try that
23:17andyfIf you want something considered for inclusion in Clojure itself, then you really need significant interest by many people, or at least a few in the Clojure core team would have to really want it.
23:18gfredericksoh man parsing octal digits is tricksy
23:18rritochandyf: I know a lot of people have had issues creating isolation in clojure, typically they do it with classloaders/OSGi, but require a seperate runtime even for the same version. This makes it possible to create isolated environments in a single runtime so you only need one runtume per clojure version.
23:19andyfMany, many proposals for chages to Clojure have been made, as you might guess, but the majority are not of interest to the Clojure development team, for a variety of reasons.
23:19rritochandyf: Exactly why I didn't want to waste my time writing this code in the first place
23:20rritochandyf: But that is also why I seperated it from clojure as much as possible, so I can carry it to any future version of clojure
23:20andyfA waste of time is in the eye of the beholder. Did you implement something that you will use yourself? Did you learn something you find valuable? Neither is a waste of time, I think.
23:21andyfIf your only purpose in writing modifications of Clojure is to get them in the standard distribution, then checking whether they are of interest first is important.
23:21rritochandyf: I implemented something that I'd like to use, but I have no interest in maintaining a fork of clojure. I'm developing an web application that uses OSGi and really needs this feature for stability though, so it is a catch-22.
23:23andyfThere are people that use patched versions of Clojure, with particular modifications that they value highly, in multiple development teams. I think those tend to be fairly small modifications.
23:24andyfIf you don't need/want the latest release of Clojure, then there is no need to port the modifications to every new Clojure version that is released.
23:25andyfgfredericks: Are you implementing a parser for Java regexes, or you also want to implement a regex matcher, too?
23:27rritochandyf: Well, in my experience projects like this go like Minix, the features are extremly powerful and never made it back into the linux core
23:28justin_smithMinix was not a linux offshoot though.
23:28pllxrritoch: what was Minix
23:28gfredericksandyf: a generator actually; so the opposite
23:28justin_smithpllx: an academic project, and very loosely the basis for linux
23:28andyfa test.check generator?
23:29gfredericksandyf: but it might be hard to implement a generator without implementing a matcher at the same time :P
23:29gfredericksyes
23:29rritochI am probably have the wrong name, but there is an alternative kernel other than linux that provides built-in clustering
23:29pllxjustin_smith: linux precursor
23:29justin_smithhurd?
23:29justin_smithright
23:29rritochNot only did it fork from linux, I think it eventually forked from itself
23:29andyfgfredericks: Perhaps you could implement something that doesn't know about *every* corner case, and filtered them through the Java regex parser to eliminate bad ones?
23:29justin_smithhurd isn't a linux fork, it's an alternate kernel with a completely different architecture
23:30andyfJust brainstorming there. Might not be useful.
23:31rritochErr: sorry, wrong name, its MOSIX http://fixunix.com/minix/523588-turn-minix-distributed-operative-system.html
23:31gfredericksandyf: yeah I've thought of a few different punting tactics; I'm still having fun though so haven't resorted to those yet
23:31andyfYou want to use test.check to look for bugs in ... what?
23:31rritocherr wrong link
23:31rritochhttp://en.wikipedia.org/wiki/MOSIX
23:32gfredericksandyf: nothing in particular, it's just possible it'll be useful and a heck of a lot of fun to do
23:32justin_smithrritoch: mosix is a distributed system you can make out of multiple linux boxes. It's cool, but it's not a linux alternative, it's a way to coordinate multiple linux machines.
23:32andyfgfredericks: Reason enough.
23:32rritochjustin_smith: It is a linux alternative, the kernel is a fork of linux
23:33rritochjustin_smith: This has been around a long time, every so often they have merged in new linux kernels, but for the most part it's incompatible with linux
23:33gfredericksandyf: wouldn't be surprised if steve miner would use it in herbert in place of re-rand
23:35andyfgfredericks: I can't recall why right now, but I was delving into some of the details of the Unicode regex details a year or two ago, probably because I was learning about Unicode for the first time, and it is staggering to me the effort that Tom Christianson put into Perl regex implementation and testing.
23:36rritochjustin_smith: Either way, since this never merged back with linux the hardware compatiblity is garbage, and because linus didnt merge this code in, linux still to this day doesn't have decent clustering.
23:37rritochI suppose it doesn't matter to the people who can just buy dedicated hardware, but to those scrapping together a cluster it's a problem.
23:37justin_smithrritoch: back when mosix was open source, I used a distro that shipped with the mosix stuff, I did not realize it was more than a driver module
23:37gfredericksandyf: being able to use test.check to compare with the existing jvm impl is pretty easy and powerful
23:37rritochAnyhow, sorry for going so off topic
23:37justin_smithin terms of the kernel modifications that is
23:39andyfYou have probably seen this: http://en.wikipedia.org/wiki/Comparison_of_regular_expression_engines
23:40rritochEither way, I'll go the fork route and see how that goes, but this namespace isolation is extremly useful for modularizing clojure applications to ensure there aren't namespace conflicts.
23:40andyfHoly crud. Some regex engines implement a feature called there "recursion". Scary.
23:42gfredericksthat was a new feature in some ruby version wasn't it?
23:43andyfI like my regexes the way God and Kleene intended them: recognizable by a finite state machine.
23:43tbaldrid_.NET had a feature like that too
23:44gfredericksandyf: I think there are milder features than recursion that make them non-regular
23:44gfredericksbackreferences I think
23:44andyf(Disclaimer: andyf is not a recognized spokesman for either God or Kleene, and hasn't discussed the matter with either of them)
23:44andyfdefinitely, and I don't think I've ever used those features, either :)
23:44gfredericks~andyf is not a recognized spokesman for either God or Kleene, and hasn't discussed the matter with either of them
23:44clojurebotIn Ordnung
23:45gfredericksyeah I think #"(a*)b*\1" is non-regular
23:46andyfI'm imagining some grumpy old man shooing kids off his lawn while yelling at them to use context-free grammars for such things.
23:47justin_smithSpock saying "this grammar is highly non-regular, captain"
23:48gfrederickshelp I'm about to try to figure out what #"\11" means
23:49andyfgfredericks: Back away from the ledge!
23:49gfredericksyep; it's context sensitive
23:50gfredericksthis is so impossible to do with instaparse
23:50andyfoh, you meant you wanted help understanding how it was interepreted by the regex engine. I misunderstood.
23:50rritochandyf: I built the fork, any idea how to switch the remote to the fork so I can commit and upload?
23:50rritochandyf: I tried git remote set-url but its not working
23:51rritochandyf: Ok got it... It was git remote set-url origin ...
23:51gfredericksandyf: oh no you had the right kind of help
23:52andyfGitHub tends to have nice Google-searchable documentation for many such things. I do it rarely enough that I tend to assume it is only possible if you fork first, clone the fork, commit, and then push. At least, I know that will work.
23:53gfredericksman that really is hard to do without state in your parser
23:53justin_smithwhen I decide one of my git repos is ready for github, I create the github repo, then "git remote add origin <git uri>"
23:53gfredericksI think #"\7" matches nothing
23:54justin_smithso what exactly does #"\1" match?
23:55gfredericksthe same I assume
23:55gfredericksI just like 7 better