#clojure logs

2014-07-26

00:19razum2umwhy there is a clojure.lang.PersistentList$EmptyList and no clojure.lang.PersistentArrayMap$EmptyMap ?
00:20bbloomrazum2um: both are / would-be implementation details
00:20razum2umwhy do PersistentArrayMap even exist? in source is written that "only appropriate for _very_small_ maps"
00:20bbloom,(class {})
00:20clojurebotclojure.lang.PersistentArrayMap
00:20benedikthttp://lpaste.net/4733493919461933056 # this wont work, but i swear it worked just a few minutes ago
00:20bbloom,(class {:x 1 :y 2 :z 3})
00:20clojurebotclojure.lang.PersistentArrayMap
00:20bbloom,(class {:x 1 :y 2 :z 3 :a 4 :b 5 :c 6 :d 7 :e 8})
00:20clojurebotclojure.lang.PersistentArrayMap
00:21razum2umbbloom: yep, still a small map?
00:21bbloom,(class {:x 1 :y 2 :z 3 :a 4 :b 5 :c 6 :d 7 :e 8 :f 9 :g 10 :h 11 :asdf 123 :xxx 535835})
00:21clojurebotclojure.lang.PersistentHashMap
00:21bbloomrazum2um: it's faster to do a linear scan of a small array than to bother hashing elements
00:21bbloomonce you get past a certain size, that stops being appropriate
00:21razum2umbbloom: I think it's strange to have different (but similar) classes based on size
00:22bbloomrazum2um: it's not strange at all, it's half the reason for interfaces in the first place
00:22bbloom(doc array-map) ; probably a design error that this exists
00:22clojurebot"([] [& keyvals]); Constructs an array-map. If any keys are equal, they are handled as if by repeated uses of assoc."
00:22razum2umbbloom: I see they implement the same
00:22bbloomjust use hash-map
00:22bbloomor the {...} notation
00:23bbloomrazum2um: it's about performance
00:23bbloombut it's an implementation detail
00:24razum2umok, but i think PersistentList$EmptyList is also for that reason, why not similar like PersistentHashMap$ArrayMap
00:24bbloomrazum2um: no, it's an implementation detail
00:24bbloomjust write ()
00:24razum2umbbloom: ok then :S
00:24bbloom,(class ())
00:24clojurebotclojure.lang.PersistentList$EmptyList
00:30razum2umbbloom: btw i see int HASHTABLE_THRESHOLD = 16 in source. it there any explanatin for that choice?
00:30bbloomrazum2um: empirical testing
00:31bbloomclojurescript sets that value lower: 8
00:31blur3dHey guys, I’m trying to update an atom value, but it’s a nested hashmap, with a hashmap key, uses destructuring. It’s not as complex as it sounds, but I am trying to avoid having to use assoc-in and update-id together
00:31bbloomagain, from measuring
00:31blur3dhttp://pastebin.com/V76nE8Nu
00:31blur3dbasically, is there a better way to write (swap! app-state assoc-in [:sensors] (update-in (:sensors @app-state) [{:kind :temperature :label-id 1}] conj [99.9 1]))
00:32bbloomblur3d: so you're right to be worried, but not about the assoc-in/update-in combo... should be worried when you see a @ and a swap! like that together
00:32bbloomthe point of a swap is that it's atomic, so when you read with @ you may get two inconsistent values (in a concurrent situtation)
00:32blur3dhaha, yeah.. that was also concerning
00:33blur3dif I can somehow use :sensors in the update-in destructuring, then it should be ok
00:33bbloomjust use fn
00:34blur3dbut I get an error trying to mix [:sensors {:kind :temperature :label-id 1}]
00:34bbloom(fn [{:keys [sensors]} ....)
00:34bbloom(fn [{:keys [sensors]}] ....) ; imean
00:34bbloomoh, huh? what error are you seeing?
00:35blur3dim not great with destructuring yet, so how would that fit in?
00:35bbloom(swap! app-state update-in [:sensors {:kind :temperature :label-id 1}] conj [99.9 1]))
00:35bbloomthat doesn't work?
00:35blur3dwith something like this (swap! app-state update-in (:sensors @app-state) [:sensors {:kind :temperature :label-id 1}] conj [99.9 1])
00:36blur3dUnsupportedOperationException nth not supported on this type: PersistentHashMap clojure.lang.RT.nthFrom (RT.java:857)
00:36blur3dbut obviosuly still as @ as well
00:36bbloomblur3d: re-read the doc strings for swap! and update-in
00:36bbloomyou're giving it bad arguments
00:36bbloom(doc swap!)
00:36clojurebot"([atom f] [atom f x] [atom f x y] [atom f x y & ...]); Atomically swaps the value of atom to be: (apply f current-value-of-atom args). Note that f may be called multiple times, and thus should be free of side effects. Returns the value that was swapped in."
00:36bbloom(doc update-in)
00:36clojurebot"([m [k & ks] f & args]); 'Updates' a value in a nested associative structure, where ks is a sequence of keys and f is a function that will take the old value and any supplied args and return the new value, and returns a new nested structure. If any levels do not exist, hash-maps will be created."
00:38bbloomswap! and update-in play nice together usually, but two things here 1) when you're learning, get it right without state first, then add state as you need it
00:38bbloomand 2) you generally want to keep your "thinking" and "acting" separate anyway
00:38blur3dreplacing an atom value is fairly obvious, but I get tricked up over the updating part
00:38blur3dok
00:38bbloom(def an-app-state {:sensors ...}) ; no atom
00:38bbloomand try update-in on that
00:39bbloomlet me know when you have that working
00:39blur3dI did play around with it a bit, but the hashmap has changed also
00:39blur3dok
00:47blur3dbbloom: I think I got it all working for the simple case with an atom… thanks for your help
00:47blur3d(def app2 (atom {:sensors {{:kind :temperature :label-id 1} [[21, 0]]}}))
00:47blur3d(swap! app2 update-in [:sensors {:kind :temperature :label-id 1}] conj [1 1])
00:47bbloomblur3d: yup
00:47blur3d:)
00:47bbloomgenerally, it's a very good idea to have very few swap! calls
00:48bbloomor at least if you have a whole bunch of swap! calls, they should use pure functions defined elsewhere
00:48bbloomthis way you can test the pure functions!
00:48blur3dthis is for a clojurescript app, that will be sent data via websockets… so its for the app-state
00:48blur3dok, sounds good
02:39razum2umclojure is cool at metadata, which can be bound to functions too, but is there any way to get function's (anonymous) metadata inside the same function. e.g. own metadata?
02:56Bronsarazum2um: ##(^:foo (fn x [] (meta x)))
02:56lazybot⇒ nil
02:56Bronsawut
02:56Bronsa,(^:foo (fn x [] (meta x)))
02:56clojurebot{:foo true}
02:56Bronsaoh well.
02:58Bronsahiredman: what's with the 10 locals limit for hoisting?
03:04allenj12__hey does anyone here have experience using overtone? is there a recommended editor for it?
03:11alexyakushevallenj12__: I haven't used Overtone, but I suspect https://github.com/overtone/emacs-live is what you are looking for
06:22Ro_I have a general question, do not know where to ask.. How triplets relate to graph?
06:44alexyakushevSo I am trying to AOT-compile Clojure sources using a slim JAR and I get this: https://www.refheap.com/88608
06:46alexyakushevThis happens when the compiler gets to gvec.clj:122, where print-method is defined for ::VecSeq
06:49boxedRo_: triplets? graph?
06:49boxedRo_: you might need to give some more context
08:10Ro_no context ;)
08:11Ro_I was searching for an answer how does triples relate to graph, how can they be converted from one to another
08:12Ro_is it possible to create hypergraph with tripplets
08:16Ro_and etc.
08:44katratxoRo_: e.g. http://www.snee.com/bobdc.blog/2014/01/storing-and-querying-rdf-in-ne.html
09:15formaggiohi 'veryone
09:53john2xquestion about Luminus. what is this `servlet-context` in the generated templates? they seem to be blank when running the dev server. Are these meant for production?
10:12deathknightWhat is a great recent tutorial that builds a web app?
10:16boxed“web app” is a bit vague… the readme on https://github.com/weavejester/compojure does a fairly good job at the basics
10:17xeranashello, Clojure is new thing to me. I trying to find way to redefine static variables for test. But probably fail to understand concept. Here how I tried: https://gist.github.com/xeranas/2bb3fd9b1508448ffd76
10:18Farexeranas, by the time you call B, it has already been evaluated
10:18Faremaybe you want (defn B [] A) instead?
10:24xeranasFare: hmm, defn would do a trick. I probably should stick for defn while still learning
10:26kandinskihi, I'm new to clojure and emacs. I have installed cider following the instructions on braveclojure.org, but when I start the cider repl, I get this message: http://paste.ubuntu.com/7865976/ . Emacs packages do not include cider-nrepl. What am I doing wrong?
10:29ProTipHi guys, I'm wanting to use rickshaw or d3js in a clojurescript project and I'm a bit confused on the current best way of doing this..
10:29ProTipDo I need to generate and externs file?
10:33deathknightwhat is the name of "@" in clojure? having a hard time searching up what that means on google
10:34deathknighti.e. (let [post @upcoming-post-queue] ...)
10:34H4nsdeathknight: deref
10:35deathknightthank you h4ns
10:47itruslovekandinski: add the cider-nrepl plugin to your ~/.lein/profiles.clj - see https://github.com/clojure-emacs/cider-nrepl
10:49kandinskiitruslove, thanks
10:56ProTipIs this the prefered way to create externs? https://gist.github.com/Chouser/5796967/download#
11:07dnolen_ProTip: https://github.com/federico-b/d3-externs
11:08dnolen_ProTip: you can sometimes use the library itself as the externs file, http://swannodette.github.io/2014/03/14/externs-got-you-down/
11:08dnolen_ProTip: if you only use a couple of functions, writing the externs file is pretty simple.
11:09ProTipthx :D
11:09ProTipI've found out too that I can just use the library with the js explicitly loaded in the html page
12:22reducedHey
12:22reducedIs anybody in there
12:28sjoukeIt's been awhile since I've looked at Clojure. IIRC, there was something about clojure which struck a chord with me: "a uniform API for accessing and manipulating data structures"
12:29sjoukeIs this correct, would someone be willing to give me a search term, so I can look further into it?
12:32jeremyheilersjouke: have you read through http://clojure.org/data_structures ?
12:33jeremyheileractually, this one: http://clojure.org/sequences
12:33jeremyheilerthe sequence abstraction is what you're talking about
12:33jeremyheileris what i think*
12:34sjoukejeremyheiler: i haven't, i'll take a look at both :)
12:34sjoukereading the sequence one first of course, thanks jeremyheiler
12:34jeremyheilernp!
12:40deathknighthow can I, in the REPL, (require ') a file called example.clj in ~/proj_dir/test/clj-facebook-graph/example.clj?
12:42noidideathknight, http://grimoire.arrdem.com/1.6.0/clojure.core/load/
12:43noidideathknight, http://grimoire.arrdem.com/1.6.0/clojure.core/load_DASH_file/
12:43deathknightThank you noidi. Why does my computer lock up for about 10 seconds whenever someone mentions my name in the smuxi client?
12:47sjoukehttps://programmers.stackexchange.com/questions/214425/why-does-clojure-neglect-the-uniform-access-principle
12:48sjoukesee last answer
12:48sjoukei'm a young programmer, i've been thinking private methods are security feature for languages
12:49tbaldridgesjouke: security...no. In Java you can access any private field via reflection
12:49sjoukethen what's the point?
12:49tbaldridgesjouke: and if all data is immutable it doesn't matter, no one can change it
12:49tbaldridgethat's just it, Rich is right, uniform access is a un-wanted "feature"
12:49bbloomtbaldridge: in theory you can disallow java code from using reflection w/ the security system, but nobody does really
12:50bbloomtbaldridge: the uniform access principal is about fields/properties/methods, not about private/public
12:54sjoukeit seems private methods are for communicating to programmers using your code which functions they should use and which ones are implementation details
12:54sjoukethat seems logical
12:59devongis it possible to execute common lisp in clojure? I'd like to be able to convert org-mode documents in html for this clojure app I'm writing.
13:00jeremyheilerdevong: i suppose you could shell out
13:01devonghmm, that doesn't really seem like what I'm looking for. I think I'm going to need to just do more googling, this seems like something someone has probably already solved.
13:01jeremyheilerwhat are you asking for than?
13:01jeremyheilerthen*
13:01devongI don't really need to call common lisp, what I really need is to find a clojure library for parsing org-mode documents
13:01devong:)
13:01jeremyheileroh, well, that's different
13:02devongI just found a common lisp library, and thought, maybe there is an interopt somewhere
13:02jeremyheilerany sort of interop would likely just shell out
13:03jeremyheilera quick search turned up this: https://github.com/gmorpheme/organum
13:03devongI think maybe something like this http://nakkaya.com/static.html
13:04devongyour google foo is better than mine
13:04devongthis morning
13:04devongthanks!!
13:04jeremyheilerlol "clojure org mode parser" ;-)
13:04devongIDK man, I had googled that
13:04devongand wasn't coming up with anything
13:04devongsomething must have been just a little different
13:05devonghaha, oh well
13:05jeremyheilerheh. i suppose with google searches aren't consistent
13:05jeremyheileranyway, i hope that works out for you
13:06devongregardless, thanks
13:06jeremyheilernp
13:11sjoukenobody disagreed
13:11sjoukei wasn't expecting that :)
13:12sjouke11:51 < sjouke> it seems private methods are for communicating to programmers using your code which functions they should use and which ones are implementation details
13:12sjouke11:51 < sjouke> that seems logical
13:13jeremyheilersjouke: documentation can also do that
13:14jeremyheilersjouke: sometimes it's not readily apparent which fns are impl details and which aren't
13:14nobodyzzzprivacy is overrated - ask NSA :D
13:18jeremyheilersjouke: specific to clojure, lets say you have a helper function that you want private and need in two namespaces. are you going to copy paste that function in both, combine the namespaces, or make it public in a util namespace?
13:38sjoukejeremyheiler: that makes sense
13:45vdmit11Hi folks. Given an existing object, can I add an implementation of some protocol to this object? I mean, I would like to morph an object, before morphing it doesn't support a certain protocol, after the morphing - it does. Is there some way to do this?
13:46bbloomvdmit11: you want to define a protocol on a particular instance, not on all objects of that type?
13:47vdmit11yes, on a particular instance
13:47bbloomclojurescript has the "specify" macro
13:47bbloombut nothing like that on the jvm
13:48bbloomif you have a small number of protocols to implement, i suggest using reify to create a delegating object
13:48bbloomor, back up a step and explain why you need this. there may be a better solution
13:55vdmit11Well, I'm writing a little music-related program, I need to represent music somehow, so I decided to add a bunch of types like Note, Chord, Phrase, stuff like that, they have some properties in common like pitch or duration and they need to handle them in a different way, so I decided to write a bunch of protocols for such properties. Now, I need to "compose" some music, so I would like to add certain "effects" to those objects, like "vibrato". There must be a
13:58vdmit11Actually these things like Note or Chord are abstract data types, they determined not by the name, but by a set of protocols they satisfy. I use reify to create them and satisfies? to check whether an object can behave like what I want, kinda duck typing. In the code, I can reify what I want from scratch, but in the runtime I would like to create improved version of existing instances, so I have this problem.
14:00vdmit11Now I guess there is no better solution than runtime polymorphism, so I'm going to re-implement this stuff using multimethods and hashmaps.
14:01Jaoodmarco
14:09ambrosebsbbloom: any ideas on how to chaperone a deftype to add contracts to its methods? so far the best idea I have is to use java.lang.instrument to intercept the bytecode before it's defined and add pre/post things to the methods.
14:09bbloomambrosebs: ha! you're getting crazy now :-P
14:10ambrosebsyes this is stupid
14:10bbloomi know nothing about java's instrumentation capabilities
14:10bbloomother than it's pretty good at it, as far as these things go
14:10bbloomit's important for profilers
14:10ambrosebsahk. worth a try :)
14:11bbloomwould be quite a feat if you make it work
14:11bbloomgood luck :-)
14:12ambrosebsthanks!
14:17schmeehow do I combine `with-open` and recursion? just call the function instead of using `recur`?
14:19bbloomschmee: presumably you don't want to open a file on each go of the recursion...
14:20bbloombut in general, if you want to recurse out of a catch or finally block, clojure/jvm can't promise constant stack space, so you need to call the function by name instead of recur, which enforces a tail call
14:21bbloomin your case, you probably just want to put a loop form inside your with-open
14:22schmeeI solved my problem by splitting the function in two, but thanks for the help!
14:22bbloomschmee: yeah, that's essentially what loop would let you do w/o the split
14:22bbloomschmee: http://clojure.org/special_forms#Special Forms--(loop [bindings* ] exprs*)
14:23bbloomambrosebs: what do you need to add to methods for "chaparones" ?
14:23bbloomchaperones, rather
14:23schmeebbloom: I tried using loop at first, that's when I got the error
14:24bbloomschmee: loop *inside* your with-open ?
14:25schmeebbloom: yep
14:25bbloomwould have to see it
14:27ambrosebsbbloom: basically pre/post conditions that blame the correct party, also to add delayed checks to the return value of a method.
14:27schmeebbloom: I probably did something retarded, but either way it works now :)
14:28bbloomambrosebs: i don't know anything about AspectJ, but it might be worth looking at
14:28ambrosebsbbloom: yes, having a glance. Not sure if I can get away with just using ASM, since it's already on my classpath.
14:30bbloomambrosebs: logging is the only example anybody ever uses for aspect oriented programming :-P
14:30ambrosebshehe
14:33vermain context of clojure async, when I do (<!! (timeout 3000)) my repl waits for 3 seconds, but when I do (<!! (go (timeout 3000))), it doesn't, it seems to me that even go runs in a different "thread" the <!! should still block the currrent threadn, it returns a ManyToManyChannel instead
14:33vermas/even go/even if go/
14:33bbloomverma: read the doc string for go
14:34bbloomor maybe (<!! (<!! (go (timeout 3000)))) will be illustrative
14:35vermabbloom, I did read the docs, so go is returning the channel returned by (timeout 3000)
14:35vermaoh
14:36bbloomverma: no
14:36bbloomgo is returning a channel that will receive the timeout channel
14:36bbloomit's a channel of channels
14:36bbloomor a channel of channel. singular, ie a "promise"
14:36vermabbloom, hmmm, thinking ...
14:37vermabbloom, ok makes sense now
14:37vermathanks
14:37verma(inc bbloom)
14:37lazybot⇒ 39
14:40bbloomambrosebs: what if you only chaperone functions?
14:40bbloomambrosebs: that is, do you really need to blame at method boundaries?
14:40bbloomambrosebs: or would it be sufficient to redefine functions?
14:40drguildohow do i debug a nullpointerexception?
14:41drguildoor debug exceptions in general
14:41drguildothe error messages i get aren't very useful
14:41bbloomdrguildo: *e in your repl
14:41bbloomtry (pst) too
14:41bbloomor (clojure.repl/pst)
14:42ambrosebsbbloom: yea I'm asking the same questions. Need to reread some papers.
14:42schmeebbloom: this function keeps recurring even when I type "quit", any idea why?
14:43bbloomambrosebs: but http://www.eclipse.org/aspectj/doc/released/progguide/starting-aspectj.html does seem useful
14:44bbloomschmee: if the function is running, the repl isn't listening... try ctrl-c
14:44drguildobbloom, thanks but that doesn't really give me any more information than i get already. how would i go about tracking down what it is that's being called in the fn to trigger the exception?
14:44bbloomdrguildo: you follow the stack trace... it should have file/line information in it
14:45drguildobbloom, it does but i'm having trouble finding out what it is on that line that's generating the exception. i'm a complete clojure beginner.
14:46bbloomdrguildo: experiment with subexpressions in your repl
14:46drguildoi'm used to liberally peppering my code with print statements to track down bugs :-/
14:46drguildoso i'm quite stumped
14:46bbloomdrguildo: what's stopping you from doing that?
14:47drguildobbloom, ignorance, i guess. i'm new to functional languages.
14:48bbloomdrguildo: clojure is not pure, just use prn
14:48bbloom,(let [x nil y :not-nill] (prn x y) :result)
14:48clojurebotnil :not-nill\n:result
14:48bbloom,(def dbg [x] (prn x) x)
14:48clojurebot#<CompilerException java.lang.RuntimeException: Too many arguments to def, compiling:(NO_SOURCE_PATH:0:0)>
14:48bbloom,(defn dbg [x] (prn x) x)
14:48clojurebot#'sandbox/dbg
14:48bbloom,(inc (dbg 5))
14:48ambrosebsbbloom: it does. do you know if that redefines entire classes or magically just swaps out a method?
14:48clojurebot5\n6
14:49bbloomambrosebs: the wikipedia article lead me to believe that it uses java.lang.instrumentation and does byte code "weaving"
14:49drguildolike i just added a bunch of println to the fn before the line that causes the exception
14:49drguildobut when i execute the problem function in the repl, nothing gets printed
14:49ambrosebsbbloom: ah. niiice
14:50drguildoi just get the exception like before
14:50drguildosame if i use prn
14:50jeremyheilerdrguildo: did you reload the function?
14:51drguildojeremyheiler, i think so. i did ctrl-c ctrl-k and also ctrl-x e
14:52ambrosebsbbloom: one thing that made me sad is that you can't hook into a primitive array get/set
14:52ambrosebsat least, no one has implemented it yet afaik
14:52bbloomambrosebs: hook the aget and aset functions
14:53schmeebbloom: yeah, ctrl-c works, but I still don't understand why typing "quit" doesn't
14:53bbloomschmee: repl == read, eval, print, loop
14:53schmeetyping "quit" in with a print added will print "running? false"! https://gist.github.com/schmee/7128ad47b35576187e86
14:53bbloomit was doing eval/print, it hadn't looped back to read yet
14:54bbloomschmee: oh, i thought you were talking about the repl, not your custom socket thing
14:54drguildohttps://www.refheap.com/88616
14:54drguildowhat am i doing wrong?
14:54ambrosebsbbloom: yea I might consider that. would be nice to actually have a guarantee of some sort, instead of hoping the array doesn't get passed to evil java worlds
14:55ambrosebsI'm erring on the all-or-nothing for now :)
14:55bbloomdrguildo: you might be being bitten by laziness
14:55drguildostory of my life
14:55bbloomheh
14:55drguildohow do i get around it?
14:56bbloomdrguildo: map is lazy, side effects in the transformation function aren't promised to run at any particular time
14:56drguildoi use do or something like that?
14:56bbloomit just means that your function isn't running
14:56bbloom,(first (map println [1 2 3]))
14:56clojurebot1\n2\n3\n
14:56bbloomnotice all three run
14:56bbloombut:
14:56bbloom,(first (map println (range 100)))
14:56clojurebot0\n1\n2\n3\n4\n5\n6\n7\n8\n9\n10\n11\n12\n13\n14\n15\n16\n17\n18\n19\n20\n21\n22\n23\n24\n25\n26\n27\n28\n29\n30\n31\n
14:56bbloomonly 32 run
14:57bbloomthere's no promise of how much of the lazy sequence will be visited
14:57bbloomwhich means your exception is coming from somewhere else
14:57boxedw00t, got clj-time to use my midje-readme plugin
14:58bbloomambrosebs: isn't the entire point of blame to handle flexible boundaries between verification techniques?
14:58drguildobbloom, so how do i find out where?
14:58bbloomdrguildo: heh, more print statements
14:58drguildo:-(
14:59bbloomdrguildo: what's the matter, you said you like print statements?
14:59bbloomyou learned somethign when NOTHING was printed: you learned that your map code isn't being traversed anywhere
14:59bbloomthat means your NPE is happening before the result of map is used
14:59bbloomyou've narrowed the search space
14:59bbloomkeep going :-)
15:02schmeehow is it possible to have (when running (prinln running)) print "false"......
15:05bbloom(prn (class false))
15:05bbloomor rather (prn (class running))
15:05drguildoso why is the exception triggered on that line?
15:05drguildoand doesn't that make clojure really hard to debug?
15:05ambrosebsbbloom: java arrays seem like the bane of my existence for the last few years. I'll have to think about that.
15:06bbloomdrguildo: have you tried printing all the the variables that are inputs to that line?
15:06bbloomambrosebs: why?
15:06drguildobbloom, i'm pretty sure i've tracked down the problem; i'm just asking a question about clojure in general
15:06gfredericks,(def my-false (Boolean. false))
15:06clojurebot#'sandbox/my-false
15:07gfredericks,(when my-false (println my-false))
15:07clojurebotfalse\n
15:07bbloomdrguildo: small, pure functions are much much easier to debug than large stateful rats nests
15:07schmeerunning class java.lang.Boolean <-- good or bad?
15:07gfredericksschmee: running it?
15:07ambrosebsbbloom: array types in core.typed still don't really work
15:08schmeegfredericks: huh?
15:08bbloomschmee: are you using zmq?
15:08gfredericksschmee: ooh sorry I think I misinterpreted
15:08bbloom,(identical? false false)
15:08clojurebottrue
15:08ambrosebsbbloom: I experimented with bivariant arrays and ... still experimenting
15:08bbloom,(identical? false (Boolean. false))
15:08clojurebotfalse
15:08bbloomschmee: maybe the library you're using is giving you a bad boolean ^^
15:09gfredericksschmee: yeah compare it to `false` using `identical?` as bbloom suggested
15:09gfredericks,my-false
15:09clojurebotfalse
15:09gfredericks,(identical? my-false false)
15:09clojurebotfalse
15:09gfredericks,(identical? (Boolean/valueOf my-false) false)
15:09clojurebottrue
15:09bbloomdrguildo: also all your data being printable/readable makes it *very easy* to inspect intermediate results with a pretty printer
15:09gfredericks,(identical? (boolean my-false) false)
15:09clojurebottrue
15:10gfredericksschmee: you can pass a dirty Boolean to the boolean function to get back a good value; not sure how you ended up with such a thing
15:10drguildobbloom, so in general is clojure easier, the same, or more difficult to debug?
15:10drguildolike is it just a case of me getting used to it
15:10bbloomgfredericks: probably from a broken socket library
15:10bbloomdrguildo: i find it dramatically easier to debug, but it requires a very different workflow
15:11bbloomdrguildo: that doesn't mean that things like stepping debuggers are never useful, and there are some cases where tooling in clojure is far from sufficient
15:11schmeeI don't think it's boolean, but something with the recursion in this function isn't right... https://gist.github.com/schmee/7128ad47b35576187e86
15:11drguildobbloom, is there anything i can read that will help or is it just a case of experience?
15:12bbloomdrguildo: mostly experience, but people can give specific hints
15:12bbloomin general, just get used to working in your repl and evaluating forms from your buffer
15:13bbloomyou'll write better code that way too, b/c you'll write & test smaller bits of code at a time
15:13bbloomand if you type test expressions in to your buffers instead of your repl, then you'll have extra test cases lying around to try when something goes wrong
15:14drguildocool. thanks.
15:17onrcould you recommend a concise resource for java standard library?
15:17bbloomconcision isn't really java's thing...
15:21jeremyheileronr, are you looking for the javadocs?
15:23onrjeremyheiler: oh javadocs seems to be what i need
15:23gfredericksschmee: the recursion looks fine; what about the first call to the function?
15:23jeremyheileronr, i usually get to them by searching "java 7 api" and optionally the class i care about
15:24schmeegfredericks: I've added it to the gist: https://gist.github.com/schmee/7128ad47b35576187e86
15:24schmeeI start by typing `join "user"` in the REPL
15:25onrjeregrine: did you read a java for getting started using java std lib?
15:25gfredericksschmee: are you planning on making this more complex? as it stands the `running` arg is a bit redundant isn't it?
15:25jeregrineonr :)
15:25jeremyheileronr, not sure what you mean
15:26onrjeremyheiler i mean :)
15:26onroh, i intended to ask, did you read a java *book* to learn about java standard library
15:27schmeegfredericks: well, in the REPL I can just ctrl-c out, but I need a way to quit if I'm not running it from the REPL
15:27schmeeand I still don't get why it just doesn't work
15:30gfredericksschmee: replace line three with (prn [running (class running) (identical? running false)]) and let us know what it prints
15:30jeremyheileronr, not really.
15:30jeremyheileronr, mostly learned by doing
15:33schmeegfredericks: waaaaaaiiiit a minute... when (msg-loop socket user false) has returned, will the execution resume from that point?
15:33gfredericksschmee: oh whoops. yes it will.
15:34schmeeoh snap
15:34schmeehow do I avoid that?
15:34gfredericks(if (= msg "quit") (do ...) (do ...))
15:38schmeegfredericks: worked perfectly, thanks a ton!
15:50schmeeis it idiomatic in clojure to use `future` instead of spawn a new Thread, even if the function doesn't return a value?
15:50schmee*spawning
15:51weavejesterschmee: I tend to do it - I don’t believe there are many disadvantages to the approach
15:51weavejesterIt uses a thread pool, but not one that can be exhausted
15:52schmeeso (doto (Thread. (client sock true)) (.start))
15:52schmee and (future (client sock true))
15:52schmee are basically interchangable?
15:53weavejesterYessss… They do different things under the hood
15:53weavejesterfuture uses a thread pool, IIRC
15:53erdoshello, i am looking for a way to serialize a long seq, buf pr-str, print-str, print, pprint/pprint all cut my list after 100 elems. any ideas? thank you.
15:53weavejesterBut for most purposes I believe they can be used interchangeably.
15:54schmeeweavejester: great, thanks
15:54weavejestererdos: pr-str does? I know that REPLs can limit the number of elements, but pr-str shouldn’t be affected…
15:54jeremyheilerweavejester, schmee futures use the same threadpool as send-off uses for agents,
15:55weavejesterjeremyheiler: Yeah
15:55jeremyheilerso blocking activity is cool
15:55weavejestererdos: http://clojuredocs.org/clojure_core/clojure.core/*print-length*
15:56jeremyheilerschmee: with futures you get a higher level api from clojure to manage them.
15:56erdosweavejester, thank you. the docs says, "The root binding is nil indicating no limit."
15:56weavejestererdos: Yeah, *print-length* does affect pr-str. Are you seeing “…” at the end of your printed data?
15:57TimMchyPiRion, technomancy: OK, OK, I've picke dup Hyperion from the library. :-P
15:58erdosweavejester: exactly
15:58weavejestererdos: You might want to check the value of *print-length* in your REPL
16:00erdosweavejester: thank you. it was bound to 100.
16:01weavejestererdos: Mystery solved :)
16:21gfredericksis it weird that clojure doesn't have a simple mechanism to start a function after a delay?
16:21gfredericksI assume (future (Thread/sleep ...) ...) is unideal
16:22_clearwaterhi. learning programming. what language/core library will I like if i like the simplicity and light-weightness of javascript, but for the server. i can't wrap my head around async and clojure has simple syntax but too heavy to install
16:22gfredericks_clearwater: clojure is heavy to install?
16:24_clearwateri have no idea how java works. not a CS major, so don't know about threads etc. but would like to.
16:24jeremyheilergfredericks: there is clojure.core/delay
16:24jeremyheilerit doesn't give you a timeout, tho
16:26gfredericksjeremyheiler: that's completely different
16:27gfredericksI'm talking about scheduling
16:27gfredericks_clearwater: okay, well I can't imagine clojure being much more difficult to "install" than anything else. You need to install a JDK and then download the leiningen script.
16:30jeremyheilergfredericks: i didn't mean timeout, sorry. either way, i see what you mean. i suppose something nice coudld be wrapped around java.util.concurrent.ScheduledExecuterService with j.u.c.Delayed
16:31gfrederickswell if you have an executor service you don't really need anything else
16:31gfredericksa scheduled executor service rather
16:31gfredericks,(java.util.concurrent.Executors/newSingleThreadScheduledExecutor)
16:31clojurebot#<DelegatedScheduledExecutorService java.util.concurrent.Executors$DelegatedScheduledExecutorService@99823>
16:32gfredericks,(def my-pool (java.util.concurrent.Executors/newSingleThreadScheduledExecutor))
16:32clojurebot#'sandbox/my-pool
16:32gfredericks,(def my-num (atom 0))
16:32clojurebot#'sandbox/my-num
16:32gfredericks,(.schedule my-pool #(swap! my-num + 42) 2 java.util.concurrent.TimeUnit/SECOND)
16:32clojurebot#<CompilerException java.lang.RuntimeException: Unable to find static field: SECOND in class java.util.concurrent.TimeUnit, compiling:(NO_SOURCE_PATH:0:0)>
16:33gfredericks,(.schedule my-pool #(swap! my-num + 42) 2 java.util.concurrent.TimeUnit/SECONDS)
16:33clojurebot#<SecurityException java.lang.SecurityException: no threads please>
16:33gfredericksclojurebot: sure okay thamks
16:33clojurebotNo entiendo
16:33schmeeif I want to store messages in a chat server, should I use an atom or an agent?
16:34gfredericksschmee: my guess is an atom is fine
16:36jeremyheilergfredericks: i meant that it could be nicely hooked into deref and whatnot
16:36jeremyheileroh, maybe not necessary . i see j.u.c.Future is special cased
16:37gfredericksyep; you gotta be careful with that interface though
16:38gfredericksthe reflector likes to guess wrong between the Runnable/Callable choice
16:39jeremyheilerheh. what happens when it guesses wrong?
16:39gfredericksa future that returns nil
16:43jeremyheilerah, that makes sense.
17:29hyPiRion(inc TimMc)
17:29lazybot⇒ 64
17:48expezhttps://www.refheap.com/88618 when you're interatively building up the result of a macro, is this the way to go?
17:52jeremyheilerexpez: what do you want the macro to do, ultimately?
17:57jeremyheilerexpez: if you want it to return a constant that is the sum of nums, then you're not doing that. but if it's just illustrative for larger problem, then i'm not sure what you're asking.
17:57expezThe actual macro I'm writing is instrumenting some functions, so it takes a seq of fns and then should expand to a bunch of (add-hook #'fn some-hook) along with some other stuff
17:57jeremyheilerah, ok.
17:58expezI was wondering how I would go about building up the list of ((add-hook...) ...) that I would later splice into the macro result
17:58jeremyheileruse for
17:59jeremyheiler,(for [f [inc dec]] `(~f 1))
17:59clojurebot((#<core$inc clojure.core$inc@ffdb99> 1) (#<core$dec clojure.core$dec@3c67e> 1))
17:59jeremyheilerit takes a seq and returns a seq
18:00expezright, that is way more elegant
18:00expezthanks
18:00jeremyheilerit's also lazy, so keep that in mind
18:01expezWon't the compiler realize it for me at macro expansion time?
18:02jeremyheilerwith out trying it out myself, i'm not sure.
18:07timsgIs there a predicate to test whether something’s seq-able?
18:08jeremyheiler,(doc seq?)
18:08clojurebot"([x]); Return true if x implements ISeq"
18:08jeremyheiler,(doc sequence?)
18:08clojurebotNo entiendo
18:08jeremyheiler,(doc sequential?)
18:08clojurebot"([coll]); Returns true if coll implements Sequential"
18:09jeremyheilerhmm
18:10gfrederickstimsg: there's an interface called Seqable but that misses a few special cases
18:10timsg,(clojure.set/intersection (ancestors (type {})) (ancestors (type '())))
18:10clojurebot#<ClassNotFoundException java.lang.ClassNotFoundException: clojure.set>
18:10gfrederickslike nil, strings, arrays
18:10gfredericksprobably something else I'm not thinking of
18:11timsgoops, new to this repl. Is it possible to refer to another namespace?
18:11gfredericks,(def my-list (doto (java.util.LinkedList.) (.add 3) (.add 99)))
18:11clojurebot#'sandbox/my-list
18:11gfredericks,(seq my-list)
18:11clojurebot(3 99)
18:11timsggfredericks, jeremyheiler: clojure.lang.Seqable looks promising
18:12gfredericksI'm checking the java source now for all the exceptions
18:12gfredericksnil, Iterable, Array, CharSequence, and Map
18:12gfrederickstimsg: ^
18:13timsggfredericks: thanks. What’s the ^?
18:15jeremyheilerit's kind of a bummer that there isn't a predicate for this
18:17timsggfredericks: ah, caret as in yes Seqable :-|
18:18gfrederickstimsg: the caret was pointing to the previous thing I had said
18:19hyPiRionTimMc: I can't PM you without being logged in.
18:20timsggfredericks: yup, thanks :)
18:20timsggfredericks, jeremyheiler: here’s an old implementation: http://clojuredocs.org/clojure_contrib/clojure.contrib.core/seqable_q
18:20gfredericks,(defn seqable? [x] (or (nil? x) (.isArray (class x)) (condp instance? x clojure.lang.ASeq clojure.lang.LazySeq clojure.lang.Seqable Iterable CharSequence java.util.Map)))
18:20clojurebot#'sandbox/seqable?
18:21gfredericks,(map seqable? ["okay" () nil 7 :foo])
18:21clojurebot#<IllegalArgumentException java.lang.IllegalArgumentException: No matching clause: 7>
18:22gfredericksthat's definitely not how to use condp
18:23jeremyheilerlol
18:25hyPiRion(some #(instance x %) [...]) instead
18:25hyPiRionalthough I never remember the ordering
18:26jeremyheilerhttp://dev.clojure.org/jira/browse/CLJ-401
18:30TimMchyPiRion: Huh, OK. I thought most people were registered. Let me fix that.
18:31hyPiRionTimMc: Right, I am, just temporarily unable to login for some reason
18:41jeremyheileras did i
18:41jeremyheilerleft a comment... seems like the contrib version differs only slighly than RT.seqFrom
19:26wildnuxhi
19:26wildnuxwhat is the best way to check for root access in linux in clojure
19:48TimMcwildnux: It's not going to be Clojure specific. You'll either use some library or issue shell calls.
19:51TimMc(So broaden your search to Java libraries as well.)
20:01wildnuxTimMc: doing that.. but so far i just found out only either reading current user (which could be change using jvm option) or using shell or process to run "$uid".. but it also does not give me the correct solution.. it does not give effective uid
20:23TimMcWhy do you need it, by the way?
20:28vdmit11Hi folks, is there an idiomatic way for naming "getter" and "setter" methods. For example, I define getter as: (fn [map] (:key map)) and "setter" as: (fn [map val] (assoc coll :key val), how should I name these functions?
20:29jeremyheilervdmit11: why do you want to name them?
20:30jeremyheilerthe bodies are very idiomatic and succinct.
20:30vdmit11because they are abstract method names; and there are several implementations of these methods, some of them do things more complex than get/assoc
20:30jeremyheileroh, sorry. you literally meant methods.
20:31jeremyheilerwhy not just get-foo and set-foo?
20:32jeremyheilerusing "set" is kind of weird for the persistent structures tho
20:33vdmit11yes, also it may confuse you if you reverse the name like foo-get foo-set foo-delete, etc, you may think that the foo-set is a data structure
20:34vdmit11that is why I'm asking
20:34vdmit11perhaps there is a convenient way
20:34vdmit11conventional
20:36TEttingerwell set-foo would just return a new foo
20:36TEttingerit wouldn't change the old one
20:38TimMc"with" is a prefix I've seen used for builder methods in Java
20:40vdmit11all "set" occurrences in the clojure APIs are about side effects or sets (data structures), so I think the "set" will be a bit confusing
20:42whigmaleeriepossible: (defn assoc-key [map value])
20:42vdmit11"with" is usually used by macros, I think it is a bit confusing too
20:42whigmaleeriewhatever key might be
20:43vdmit11I'd like assoc, but doesn't it implies "associate something with something", like I must pass both key and value?
20:44vdmit11function and variable names are always painful for me :)
21:21ProTipI had a hell of a time figuring out that I missed the :require-macros in the om tutorial. All the error's pointed to .js files and nothing seemed to indicate the issue was with the "go" macro not existing...
21:21ProTipAm I doing something wrong?
21:21ProTipIn regards to debugging that is, haha
21:43kristofvdmit11: This is a weird dilemma to have.
21:43kristofvdmit11: What are your data structures, anyway?
21:52gfredericksProTip: what sort of error msg was it?
22:25ruzu(newbie q) if one was to design a pet language for the jvm, is clojure well suited to building the compiler?
22:27TEttingerruzu: strongly typed or dynamic?
22:27TEttingerclojure is good for making clojuresque languages
22:28TEttingerbut the core data structures are a certain way, and you might have to work around them if your language wasn't close to clojure
22:28TEttingerXText looked interesting
22:28TEttinger$google eclipse xtext
22:28lazybot[Xtext - Language Development Made Easy! - Eclipse] http://www.eclipse.org/Xtext/
22:28ruzumm
22:28ruzui was thinking something ml-esque
22:30lpvbdo swap! compare-and-set! and !reset block?
22:31gfredericksyep
22:34ruzuis xtext akin to antlr?
22:36TEttingerruzu, I have looked at it, it makes an IDE plugin for you with syntax hightlighting and autocomplete. you can make your own language in whatever and hook it up to that
22:36TEttingerit also has a basic compiler it generates I think
22:37jeremyheilergfredericks: internally atoms use an AtomicReference. this is inherently non-blocking, no?
22:40gfrederickswat?
22:41gfredericksjeremyheiler: why would AtomicReference be non-blocking?
22:41gfrederickshttp://docs.oracle.com/javase/7/docs/api/java/util/concurrent/atomic/AtomicReference.html#compareAndSet%28V,%20V%29
22:41gfredericks^ says nothing about being non-blocking
22:43nathan7gfredericks: I'm pretty sure that's implemented as a single CAS pointer set in assembly-land.
22:43nathan7gfredericks: If so, no, it wouldn't block.
22:43gfredericksmaybe we're confusing terminology
22:43gfredericksI mean that it does everything it's going to do before it returns
22:43gfredericksand swap! in particular can sit there spinning arbitrarily long
22:43jeremyheilerah, ok, then yes. i meant what nathan7 said. it doesn't use locks
22:44nathan7oh, yeah
22:44gfredericksso I might be using "block" loosely
22:44nathan7swap! is CAS in a loop
22:44gfredericksit's certainly not async like send
22:44gfredericksis really all I meant
22:44nathan7well, send does some kind of atomic queue addition
22:44nathan7the queue addition is blocking
22:44nathan7probably also involving some atomic CAS in a loop
22:45nathan7but the loop doesn't include the supplied fn, no
22:45gfredericksright
22:45gfredericksthe fn gets called on another thread
22:45jeremyheilernathan7: that's for agents, tho
22:45nathan7jeremyheiler: what else does send accept?
22:46nathan7jeremyheiler: because over here, send's first arg is ^clojure.lang.Agent a
22:46jeremyheilerright, the fns in question originally were for atoms. was confused.
22:59rs0what would constitute a purely functional, dynamically typed programming language?
23:00rs0suppose you had a Clojure-like language where referential transparency and the lack of side effects were enforced at runtime. if you attempted to, say, access the disk or generate a random number outside of a function whose name ended in a ! (even transitively), it was a runtime error. would that be a purely functional language?
23:09TEttingerrs0: a truly pure language is one that has no ability to modify the world outside it, not even the console or repl. does that sound useful to you?
23:12benkayis this (https://groups.google.com/forum/#!topic/datomic/UX4kNT0kaqg) still the best way to get empty attrs out of datomic?
23:15FareI see a documentation page for cond-let, but its github file seems to be disappeared.
23:15FareI know it's only a 3-line macro, but is there a standard place it has moved to?
23:15benkayis if-let the new hotness?
23:17Farecond-let chains several if-lets
23:17Farewithout having to nest heavily
23:18Fareotherwise, I suppose some kind of nesting macro could do it. Maybe a <- reply to -> ?
23:23csd_Hello. How do I change the default directory where Lein creates new projects?
23:26Fare(defmacro <- "Nesting macro" ([] nil) ([x] x) ([x & y] `(~@x (<- ~@y)))) ;; like UIOP:NEST in CL
23:31rs0TEttinger: Haskell is generally described as a purely functional language. do you think the term "purely functional" is well defined?
23:32jeremyheilercsd_: "lein help new" shows you how ;-)
23:33rs0TEttinger: (personally, I have the sneaking suspicion that "purely functional" is no more rigorously defined than "object oriented", but I might be wrong)
23:34csd_jeremyheiler: I see that I can set --to-dir when creating a project, but is there any way to put it into a profile so it's automatic?
23:34TEttingerrs0, I think it's generally accepted that true purity is a program that makes your CPU warmer and prints nothing. Haskell lets you break out of purity with monads, and it obviously is a usable language, so I think "purely functional" more refers for the ability to verify whether a function will have side effects
23:34TEttingerlike in C, there's just no way to tell if a program will mutate outside state or not
23:35rs0TEttinger: yes, that's what I'm getting at. I'm starting to think that the use of the IO monad in Haskell is just an elaborate type-oriented scheme for being able to determine whether functions have side effects or violate referential transparency
23:35TEttingerin clojure, it's easier if you stick to pure clojure... but there are still java interop things and even stuff like ##(rand-nth [1 2 3])
23:35lazybot⇒ 2
23:37rs0another idea in Haskell is pervasive non-strict evaluation. it appears to be one of the problems with unsafePerformIO--that, and the fact that the compiler is liable to perform incorrect optimizations when unsafePerformIO is used, and you have to use a bunch of pragmas and the like to try to ensure that your side effects don't get CSE'd out in a way you didn't intend or expect
23:38rs0so in Haskell all these ideas are combined, and I think it's an interesting thought experiment to try to cut Haskell up into pieces and recompose the pieces in different ways, asking, "is this purely functional? how about now?"
23:38TEttingerindeed!
23:39jeremyheilercsd_: hmm, there doesn't appear to be any other way
23:39jeremyheilerthe code just pulls that option from the arglist and that's it
23:40csd_hrm ok
23:42jeremyheilercsd_: the code binds a *dir* var before it applies the template, so you may be able to create a custom template that overrides that behavoir? but that seems like a little much.
23:43csd_just curious, do you choose to let it clutter up your home directory or use the flag each time
23:44jeremyheileri just cd to the dir i want the project to be in.
23:44csd_ok thanks
23:44jeremyheilernp