#clojure logs

2015-03-01

01:41Guthurhow do i get a global var that allows me to assign to it, and how do i do the assignment?
01:45TEttingerGuthur, you probably want an atom.
01:45TEttinger,(def mutable (atom 10))
01:45clojurebot#'sandbox/mutable
01:45TEttinger,(reset! mutable 20)
01:45clojurebot20
01:45TEttinger,@mutable
01:45clojurebot20
01:45TEttinger,(swap! mutable inc)
01:45clojurebot21
01:45TEttinger,@mutable
01:45clojurebot21
01:46TEttingerreset! will set the value of the atom without regard to its current value
01:46TEttingerswap! changes it by calling a given fn on the current value
01:47TEttingerget the current value (not within swap!) by calling (deref mutable) or shorthand @mutable
01:47GuthurTEttinger: ah ok, cheers
01:47TEttingerthere are other ones, but I've found I mostly use atoms
01:48TEttingeratoms are certainly the simplest
01:48GuthurI just need the simplest at the moment, this is just to ease testing at the REPL
01:48Guthurah ok, well then all good
01:48Guthurthanks again
01:49TEttingerjava classes are always mutable unless the java that wrote them defined them in some immutable way (like clojure's data structures, which are written in Java behind the scenes), and arrays are always mutable
01:49TEttingerarrays being the harder-to-use, only-one-type, non-resizable cousin of vectors :)
02:44kryftI finally managed to set redirect-on-auth? to false in friend, but now a successful login returns 404 instead of redirecting. The 404 response does include the authentication cookie, so the only problem is the status code itself
02:53justin_smithkryft: what route is it trying to hit?
02:55kryftjustin_smith: I don't know (but apparently it ends up hitting my (route/not-found ..)
02:55kryft)
02:56kryftjustin_smith: I was trying to figure out if its trying to GET some other route by looking at the friend source, but didn't figure it out yet
02:57kryftI don't have :default-landing-uri set at least (and in any case I assumed that was only used when redirect-on-auth? is set to true)
02:58justin_smithkryft: if it isn't redirecting, shouldn't it try to land on the same URI that friend handles, but after the friend middleware?
02:59kryftjustin_smith: You mean that if I'm POSTing to /login, it should try to GET /login and return that?
03:00justin_smithwell, I don't see why it would change the request method
03:00justin_smithit should try to post to /login if you don't redirect it
03:02kryftjustin_smith: Ahhh. Yes, now it works, thanks. :) I falsely assumed that I wasn't supposed to define the /login route and that friend somehow handles that, but of course friend is just middleware that does something special for that route
03:02justin_smithexactly, but if you told friend to redirect, then you would not need to define that route
03:05kryftRight, which is what I did before (because I couldn't manage to set :redirect-on-auth? to false - after a lot of googling I finally figured out that you need to give it to workflows/interactive-form as a parameter)
03:06kryftThat was weird given that all the other parameters (:allow-anon? etc.) can be passed in a map to friend/authenticate
03:24TEttingerWell someone just got interested in clojure after I pasted a gibberish compressed name generator into a channel's eval, started reading Brave Clojure and then he and I went back and forth trying to implement a fibonacci sequence generator (I was trying to remember how to do it cleanly, he was trying to figure out how to do it), and in less than maybe 4 hours since hearing about clojure, he was understanding tons of it.
03:25TEttingerlazy sequences as generators of the next step one step at a time, reduce/reductions (he guessed what reductions did after seeing what reduce does), iterate, destructuring
03:25TEttingerthere are so many cool features that clojure has it's hard to tell where to start, apparently brave clojure hit the main points very well
03:26justin_smithinteresting
03:30TEttinger&(map second (take 10 (iterate (fn [[a b]] [b (+ a b)]) [0 1])))
03:30lazybot⇒ (1 1 2 3 5 8 13 21 34 55)
03:30TEttingerthat's the generator I came up with
03:30TEttingerit demonstrates destructuring and fns as args, lazy seqs with take, etc.
03:57robindunbarrHi all, what is the difference between ratio? and rational?
03:57robindunbarrThey seem to return the same thing.
04:07TEttinger,(ratio? Math/PI)
04:08clojurebotfalse
04:08TEttinger,(rational? Math/PI)
04:08clojurebotfalse
04:08TEttinger(doc rational?)
04:08clojurebot"([n]); Returns true if n is a rational number"
04:08TEttingeroh
04:08TEttinger,(rational? 10)
04:08clojurebottrue
04:08TEttinger,(ratio? 10)
04:08clojurebotfalse
04:09TEttingerratio is true for stuff like 1/2, but false for 2
04:11TEttingerwow... http://www.canonware.com/download/rb/rb_newer/rb.h
04:11GuthurTEttinger, on the learning that's probably why Scheme was used a lot in academia
04:12GuthurLisp is a very neat family of language for learning
04:12TEttingerprobably, I'm surprised people can learn clojure so quickly now, the resources used to be not-great when it was new
04:12Guthurit's less to do with programming a computer and more about computation
04:12TEttingeryup
04:14GuthurI like to think of the fact that John McCarthy was trying to convey and idea with his initial paper rather than create a programming language
04:14Guthurit was just that his students seen that they could actually implement it
04:15devll,bots
04:15clojurebot#<CompilerException java.lang.RuntimeException: Unable to resolve symbol: bots in this context, compiling:(NO_SOURCE_PATH:0:0)>
04:16devll ,bots
04:16clojurebot#<CompilerException java.lang.RuntimeException: Unable to resolve symbol: bots in this context, compiling:(NO_SOURCE_PATH:0:0)>
04:24ehurrellI agree on the computation aspect of it, lisps read quite like mathematical notation, and implementations of machine learning etc are as readable as the maths they are based on. Harks back to Turing talking of a 'computer' and refering to a person who does computation
04:26Guthurit's what i love most about the lisps, if you want to you devise you solution completely in the abstract
04:26Guthurof course one often has to think about the reality of computer system
04:56robindunbarrThanks, TEttinger.
04:56robindunbarrI didn’t know you could run the REPL from irc.
04:56robindunbarr(str “That’s pretty cool.”)
04:56robindunbarr,(str “that’s pretty cool")
04:57clojurebot#<RuntimeException java.lang.RuntimeException: EOF while reading string>
04:58TEttingerheh, smart quotes
05:00robindunbarrGah
05:00robindunbarrLol
05:05robindunbarr(str "Removed the smart quotes, finally.")
05:05robindunbarr,(str "Removed the smart quotes.")
05:05clojurebot"Removed the smart quotes."
05:05robindunbarrHeheh!
09:07crazydiamondHi. Is clojure.contrib alive?
09:09hyPiRionclojure.contrib is long ago
09:11justin_smith~contrib
09:11clojurebotMonolithic clojure.contrib has been split up in favor of smaller, actually-maintained libs. Transition notes here: http://dev.clojure.org/display/community/Where+Did+Clojure.Contrib+Go
09:11crazydiamondand... are transducers already avaliable?
09:17hyPiRionon 1.7.0 alphas, yes
12:57crazydiamondHow to exec file other than core?
12:57crazydiamondcore.clj
12:59justin_smithcrazydiamond: how are you running clojure?
12:59justin_smithwith lein there is a :main option in project.clj
12:59crazydiamondok
12:59justin_smithcrazydiamond: are you using lein run?
13:00crazydiamondno, so...
13:00crazydiamondI have vim with fireplace.vim
13:00crazydiamondlein repl in separate window
13:00justin_smiththat's not executing a file - that's just loading one
13:00justin_smithbut OK
13:00crazydiamondand using :Connect
13:00crazydiamondand :%Eval
13:01justin_smithwhatever your :main ns, lein will make the repl use that as the init-ns (the first ns in the repl) iirc
13:02justin_smithbut no matter which ns you start in, you can require any ns you like (that is accessible to your project) and then switch the repl to that ns
13:03KristienShould I use io! for effectful subroutines? I've never seen it used TBH.
13:03justin_smithKristien: I don't see a reason not to use it
13:03justin_smithbut yeah, most people don't use it
13:04KristienI think it's related to contract programming.
13:04justin_smithif you explicitly want your routine to throw an error where retries may occur, go for it
13:04Kristienwhich people tend not to do even when available :
13:04Kristien:p
13:04justin_smithKristien: kind of - think about what your routine would do in a retry situation, if doing it twice would be really bad, us io!
13:05justin_smithKristien: yeah, I kind of wish contracts were used more
13:10dnolenKristien: io! is really most useful for STM, but the STM isn't used very frequently in Clojure
13:18gfredericks,(def a (atom 0))
13:18clojurebot#'sandbox/a
13:18gfredericks,(swap! a (fn [x] (io! (inc x))))
13:18clojurebot1
13:19gfredericks^ a retry situation
13:20juggernotdnolen: Hi, posted a message on the group RE GSOC expressing interest in clojurescript but it seems it hasn't been moderated as yet.
13:21dnolenjuggernot: did not see it
13:21dnolenjuggernot: I don't modern Clojure much which is where it probably got sent?
13:21dnolens/modern/moderate
13:21juggernotdnolen: yea
13:21Kristiengfredericks: why does it not fail?
13:22KristienDoes io! only throw when there was in fact a retry?
13:22juggernotdnolen: its not so much of an issue
13:22gfredericksKristien: my guess is only the STM pays attention to it
13:22dnolenjuggernot: if you PM me your email I can fix this for you
13:22juggernotdnolen: I just wanted to know what's the difference between the project here: http://dev.clojure.org/display/community/Project+Ideas#ProjectIdeas-ClojureScriptGoogleClosure ...
13:22juggernotdnolen: and the foreign libs support that was added recently
13:24dnolenjuggernot: :foreign-libs doesn't involve CommonJS/AMD/ES6 transformation passes
13:24dnolenjuggernot: doesn't automate or validate externs, etc. etc.
13:25juggernotdnolen: oh i see
13:25dnolenjuggernot: you should be able to post now
13:26dnolenjuggernot: there's tons of stuff Google Closure can do that we don't take advantage of wrt. JavaScript interop
13:26justin_smithgfredericks: yeah, you would have to use (dosync (swap! ...)) if you cared about the protection io! ofers
13:26justin_smith*offers
13:28juggernotdnolen: thanks... and where could i start reading about those features in particular? is reading 'Closure the Definitive Guide' enough?
13:28dnolenjuggernot: I don't think Closure covers the internal APIs much, but I'm not sure I've never read it (probably should)
13:28dnolenjuggernot: working with Closure means reading a lot of Java source
13:28dnolenfortunately it's pretty well written Java source
13:30juggernotok well i have no issue with java. I have significant experience there... i guess i just need to get a bit more familiar with Closure and how ClojureScript is using it
13:32dnolenjuggernot: cljs.closure is more or less the extent of it at the moment
13:33dnolenjuggernot: source mapping, :simple/:advanced optimizations, and Google Closure Modules
13:33dnolenjuggernot: we do rely on the basic abstractions in goog.base (Google Closure Library) everywhere in order to have the same dependency model regardless of browser, iOS, Nashorn, Android etc.
13:34mbachttps://xkcd.com/625/
13:36juggernotdnolen: yea i read up on all that recently
13:36juggernotdnolen: as for the tools.reader project whats the difficulty level for a beginner to intermediate level person?
13:36dnolenjuggernot: in anycase that's a high priority ClojureScript one, would love to see us be able to consume anything JavaScript people might write
13:37dnolenjuggernot: all ClojureScript people need to bring is externs
13:37dnolenjuggernot: tools.reader is a nice to have / lower priority, not hard at all and a big step towards bootstrapping
13:38dnolenjuggernot: but bootstrapping is not nearly as impactful today and won't be even long after it lands
13:38dnolenall the important library stuff, dependency management etc. is all on the JVM
13:39juggernotdnolen: yea I'm guessing majority of the grunt work would be to port the existing macros etc.
13:40dnolenjuggernot: no, there's very little to do w/ regard to porting macros
13:40dnolenCLJS has many of it's own core macros, just need to port over the few things we still piggieback on Clojure for
13:41juggernotdnolen: oh ok
13:42juggernotdnolen: well thanks for clearing things up ill be applying for that interop project
13:42dnolenjuggernot: so of the 3 ClojureScript projects I wrote up - highest priority goes to cljs.core.async & Google Closure enhancements
13:42dnolenjuggernot: cool
13:42juggernotdnolen: are there any open discussions around it i should be aware of?
13:43dnolenjuggernot: around what? interop?
13:43juggernotyea
13:43dnolenjuggernot: ah no not really - largely because for a long time ClojureScript JS interop was very ad-hoc
13:43dnolenjuggernot: now that :foreign-libs is a thing I think people will want more/better suppport
13:44dnolenjuggernot: but also JS community is pushing in weird gross directions
13:44dnolenso we have to follow along
13:45dnolenjuggernot: that is CommonJS/AMD/Node.js style require/ES6 is going to become more and more desirable
13:46dnolenReact-only components have already started going down the require route
13:48juggernotdnolen: ok, so you dont like that approach? i actually thought having require would be nice for modularity...
14:24Manduskj\t\ti
14:27dnolenjuggernot: the problem is it isn't a standard, shipping libraries that need is ugh
14:28dnolenjuggernot: if you want to use it internally OK
14:31dnolenjuggernot: the point of GSoC project to protect CLJS from the vagary of JS fads
14:36juggernotdnolen: ok... thats understandable
15:14nicferrieranyone else use hickory?
16:01whodidthisanyone know how re-frame deals with event dispatching when users needs to event.preventDefault()? x_X
16:02whodidthiswoops wrong channel
16:46nicferrierraaaaaar. frustrated.
16:47nicferrierI've got a zipper that if I call next x times returns the right thing... but in a recursive loop never finds the right thing.
16:47nicferrierclearly broken... I expect it's obvious.
16:47crazydiamondhi nicferrier
16:47crazydiamondcan you share both?
16:48nicferrierI can't. code is locked inside a firewall. Sorry. just venting.
16:49crazydiamondall that stuff is not that obvious. for me - clojure is "programming right away", i.e. when you start you already must think hard
16:50crazydiamondI think that "thinking functionally" is a skill, but we learn on own mistakes
16:50nicferrierI feel like I understand zippers.
16:50crazydiamondbetter there to exercises
16:51crazydiamondbut it's not easy to compose good ones
16:51nicferrierI feel like I think functionally... I do agree with you.... it's not trivial to bend your head round new things.
16:51nicferrierI've just obviously made a mistake in this function. just can't see what it is.
16:51nicferriermy data is quite large. I should probably cut it down.
16:52nicferrierthe trouble is the data is a particular confluence page.
16:52nicferrierhard to cut down.
16:59nicferrierho. the problem seems to be I'm getting hickory and not hiccup.
16:59nicferriernot sure why.
17:05marcos22OXGood day guys, I'm having troubles doing a remote debug with a vertx app...(using lein vertx) I posted in SO here http://stackoverflow.com/questions/28799405/configuring-java-options-for-remote-debug-i-always-get-error-jdwp please if anyone know how fixed I'll appreciate it
17:07justin_smithmarcos22OX: is the error with the vertex server's port, or with the dt_socket?
17:07justin_smithif the problem is actually the latter (which I doubt) you can just not provide a socket arg and it will pick an available one
17:08justin_smithmarcos22OX: tl:dr: don't change the socket arg in your :jvm-opts, change the socket the vertx server is using
17:28marcos22OXhi justin_smith...let me try
17:32nicferriermy understanding of zippers was that zip/next descended along all axes. but I've got a zipper here that is not stepping into a structure with next. it just steps over it.
17:35justin_smith$grim clojure.zip/next
17:35lazybothttp://grimoire.arrdem.com/1.6.0/clojure.zip/next
17:35justin_smithhmm, that grimoir page could use some examples
17:37nicferrierit says depth first. all the examples I've seen are depth first.
17:37justin_smithnicferrier: do you have a minimal example showing the behavior that surprises you?
17:37nicferrierthe node that's coming back looks like [:table {} [:tbody ...]] but it's not finding that.
17:38nicferrierI'm finding the table... but not the tbody.
17:38nicferrierwhen I find the table (zip/next the-table) produces the element _after_ the :table, not from inside.
17:39nicferrierso not really depth first.
17:39nicferrierI suspect I'm doing something wrong because it's late and I'm using a crappy environment.
17:39nicferrierbut it does seem odd.
17:46nicferrieryou're right though. I started to work with a smaller dataset. I'm being dumb.
17:47justin_smithI just suspect some of use here could likely help (maybe even myself, though I am not an expert on clojure.zip), but you'll get more help if you have a small example showing the behavior that confuses you
17:47nicferriersure.
17:48nicferrierfwiw I just cut it down massively and still getting the same behaviour.
17:48nicferriertotally weird.
17:48nicferrieroh wait.
17:48justin_smithI think I got something close to what you are talking about -- https://www.refheap.com/97978
17:48nicferrierif the zipper is made of a sequence but contains vectors... will the zipper not step into them?
17:49justin_smiththat totally depends on how you define your check
17:49justin_smith,(seq? [])
17:49clojurebotfalse
17:49justin_smith,(sequential? [])
17:49clojurebottrue
17:49justin_smith,(coll? [])
17:49clojurebottrue
17:49justin_smithoften coll? is the right general thing to do when walking things
17:49nicferrierwhat check?
17:49justin_smithfirst arg to the function "zipper"
17:50justin_smith(doc clojure.zip/zipper)
17:50clojurebotHuh?
17:50nicferrier:-|
17:50justin_smith:P
17:50justin_smith$grim clojure.zip/zipper
17:50lazybothttp://grimoire.arrdem.com/1.6.0/clojure.zip/zipper
17:50nicferrierI am talking about zip/seq-zip, for example.
17:50justin_smithseq-zip is just a wrapper for zipper
17:51nicferriergotcha. zipper is generic.
17:51justin_smithand seq-zip uses seq?
17:51nicferrierso you can make something that uses seqs or vectors.
17:51nicferrierand that's my problem!
17:51nicferrier:-D
17:51justin_smithsee above, a vector fails the seq? test
17:51justin_smithright
17:51nicferrierawesome. thanks.
17:51justin_smithin my refheap paste above I create a zipper that uses coll? as the test
17:51justin_smithnp
17:57nicferrierthat looks definitely like it... though now I'm touching too many nodes. still I can hack it now. thanks.
18:00justin_smithnp
18:53emaczencan someone point me to a flowchart or reference on clojure variables and which one to use in which case (atoms, agents, ... )
19:00shokyemaczen: donno if it's what you're looking for but it's helped me in the past http://clojure-doc.org/articles/language/concurrency_and_parallelism.html
20:32emaczenshoky: thanks that was exactly what I was looking for
20:33emaczenDo you refer to vars, refs, agents, and atoms as variables?
20:33emaczenWhat is the terminology here?
20:46JJJollyjim_Hi there, I've got a small question, could I have some help?
20:47JJJollyjim_Oh nevermind, found it in the docs! :-)
20:51gfredericksemaczen: those are called "reference types"; there's not really anything in clojure called "variables", but "locals" are close
21:00ennI'm trying to deploy something (just a snapshot, so not worried about signing/promoting at this point) to Clojars for the first time, and I must be missing something. I run lein deploy clojars, enter my username and password, and it says things like "Sending blah.jar (80k) to https://clojars.org/repo/&quot;, and in general acts as though it was successful
21:02emaczenwhat should I do when I don't need any concurrency features?
21:02emaczenjust a plain old def does not seem recommended
21:02ennBut then when I pull up the project it tells me I have a missing pom, missing jar, and a number of missing things in my project.clj (description, etc.) -- even though my project.clj has all of those things defined (and indeed the :description from my project.clj appears at the top of the Clojars page for my project, above the complaint that description is missing)
21:05nuwanda_emaczen: why do you think a plain old def is not recommended?
21:07emaczennuwanda: I need to mutate this variable
21:08TEttinger,(def mutable (atom 0))
21:08clojurebot#'sandbox/mutable
21:08TEttinger,(reset! mutable 11)
21:08clojurebot11
21:08TEttinger,@mutable
21:08clojurebot11
21:08gfredericksemaczen: atoms for that normally, but we try pretty hard to avoid them
21:09TEttingeravoiding mutation in general
21:09TEttingerenn, that sounds odd
21:10TEttingercan you link to the clojars page?
21:10emaczenOk, so I am new to clojure and am struggling a bit with where to start -- here is a good scenario
21:11emaczenSay I am making a card game (I am) what would you do to add and remove cards from a player's hand?
21:11emaczenWhich variable type would you use?
21:11gfrederickshow is the program being driven?
21:11ennTEttinger: https://clojars.org/enaeher/contrail
21:11gfredericksis this a terminal game? some sort of web server?
21:11emaczenI'm interested in both
21:12gfredericksin either case we usually try writing all of the game logic with data and functions, and then having just one top level piece of state to store the whole state of the game
21:12ennTEttinger: http://hastebin.com/eqihapeqas.py is the transcript of my lein deploy clojars session
21:13emaczengfredericks: Can you be precise with what you mean by data?
21:13gfredericksbut that atom or whatever is kept at the top level where you're coordinating interaction with the user, it doesn't usually overlap with the code that has game logkc
21:13gfrederickslogic*
21:13gfredericksemaczen: the immutable data structures, keywords, numbers, etc
21:13gfredericksvalues
21:15gfredericksyou might write a pure function (fn act [game-state action] ... return new game state ...)
21:15gfredericksthat can handle any possible thing that happens in the game, and doesn't need any reference types or mutation
21:15emaczengfredericks: wouldn't that be inefficient?
21:16TEttingerenn, I wonder if you were pushing to releases without it telling you
21:16TEttingerhttps://github.com/ato/clojars-web/wiki/Releases
21:17TEttingeremaczen, for a terminal-based game, printing to the console will be slower than processing the next step
21:17TEttingerfor a web-based game, your network connection is more important
21:18emaczenTEtinger: so in either case I should go with a completely immutable solution?
21:19TEttingerprobably not completely. you can probably do quite well storing anything that needs to change in one central map
21:19TEttingerthat's how play-clj does it
21:20TEttinger,(def central {})
21:20clojurebot#'sandbox/central
21:20TEttinger,(def central (atom {}))
21:20clojurebot#'sandbox/central
21:20emaczendef is a var right?
21:20emaczenOh an atom
21:20TEttingeryeah, which is just a name
21:20gfredericksvars are almost never used for application state
21:21emaczenon #clojure, do people look at paste.lisp.org?
21:22TEttinger,(swap! central update-in [:player1 :hand 0] [:clubs 10])
21:22clojurebot#<IllegalArgumentException java.lang.IllegalArgumentException: Key must be integer>
21:22TEttingergah, how did I do it
21:22gfredericksassoc-in?
21:22TEttingerright
21:22TEttinger,(swap! central assoc-in [:player1 :hand 0] [:clubs 10])
21:22clojurebot{:player1 {:hand {0 [:clubs 10]}}}
21:22gfredericks,(def assoc-in? [x] (= x assoc-in))
21:22clojurebot#<CompilerException java.lang.RuntimeException: Too many arguments to def, compiling:(NO_SOURCE_PATH:0:0)>
21:22gfredericks,(defn assoc-in? [x] (= x assoc-in))
21:22clojurebot#'sandbox/assoc-in?
21:22gfredericks,(assoc-in? assoc-in)
21:22clojurebottrue
21:22gfredericks,(assoc-in? assoc)
21:22clojurebotfalse
21:23TEttingerhaha
21:23gfredericks#protip
21:23gfredericks,(defn assoc-in?? [x] (= x assoc-in?))
21:23clojurebot#'sandbox/assoc-in??
21:23lazybotclojurebot: What are you, crazy? Of course not!
21:23clojurebotPardon?
21:23gfrederickslol
21:24TEttingeremaczen, so ideally you'd make changes immutably whenever possible, passing the whole immutable map storing everything from one fn to the next. (this is a reference, so you aren't copying a big map every time you return it)
21:25emaczenTEttinger: Thanks, this should get me far.
21:25TEttingerplay-clj has an interesting approach that has certain fns return a big list of "entities" and when they do it updates the map of entities internally in an atom that isn't externally visible
21:26gfredericksI bet you could get infix arithmetic in cljs by extending IFn to Number
21:26TEttingerso it has the advantage of your entities being up-to-date whenever you call one of those fns
21:27TEttingergfredericks, see if you can, this could be very good or very bad
21:27gfredericksI can't remember how to use cljs anymore
21:38emaczenTEttinger: To be clear, so far I have defined a central atom which points to a map and so far each entry is a vector -- what do you think? Did I comprehend correctly?
21:41TEttingeremaczen, its organization really depends on your game
21:43emaczenTEttinger: As long as I got the overall theme (an atom containing immutable datastructures) I am happy at the moment
21:44TEttingercool
21:44TEttingerthat's just about it yeah
21:46TEttingerthere's a big advantage if you only have the core data structures like maps, sets, seqs/lists, and vectors -- you can pr-str the whole value of the atom like (pr-str @central) to get a simple, re-readable version of central that you can write to a file and read back
21:46emaczenpr-str? (doc pr-str) isn't too helpful to me either
21:47TEttinger,@central
21:47clojurebot#<CompilerException java.lang.RuntimeException: Unable to resolve symbol: central in this context, compiling:(NO_SOURCE_PATH:0:0)>
21:47TEttinger,(def central (atom {}))
21:47clojurebot#'sandbox/central
21:47TEttinger,(swap! central assoc-in [:player1 :hand 0] [:clubs 10])
21:47clojurebot{:player1 {:hand {0 [:clubs 10]}}}
21:47TEttinger,(pr-str @central)
21:47clojurebot"{:player1 {:hand {0 [:clubs 10]}}}"
21:47TEttingernow here it gets cool
21:48TEttingerthat string could be written to a file like (spit "mysave.sav" (pr-str @central))
21:48TEttinger(doc spit)
21:48clojurebot"([f content & options]); Opposite of slurp. Opens f with writer, writes content, then closes f. Options passed to clojure.java.io/writer."
21:48TEttingerthen read back with (slurp mysave.sav)
21:49emaczenWhat's so cool about that? I'm pretty sure I have done that with python?
21:49fadingemaczen: might want to look at http://www.chris-granger.com/2012/12/11/anatomy-of-a-knockout/ for how he designed game for clojurescript?
21:49TEttinger,(def that-str "{:player1 {:hand {0 [:clubs 10]}}}")
21:49clojurebot#'sandbox/that-str
21:49TEttinger,(eval (read-str that-str))
21:49clojurebot#<CompilerException java.lang.RuntimeException: Unable to resolve symbol: read-str in this context, compiling:(NO_SOURCE_PATH:0:0)>
21:49TEttinger,(eval (read-string that-str))
21:49clojurebot{:player1 {:hand {0 [:clubs 10]}}}
21:50TEttingerand there it is fully loaded with no dependencies on pickling libs or anything
21:50gfredericksno need for eval eh?
21:50TEttingererr
21:50TEttinger,(read-string that-str)
21:50clojurebot{:player1 {:hand {0 [:clubs 10]}}}
21:50TEttingerright
21:50TEttinger(inc gfredericks)
21:50lazybot⇒ 119
21:53gfredericks,(* 7 17)
21:53clojurebot119
21:54TEttingernot prime
21:54gfredericksit's a semiprime I'm gonna use it for crypto
21:54gfredericksmy public key is 119 everybody
21:54TEttingerheh
22:22TimMcThat's crazy enough it just might work.
22:32niac(defn new-image
22:32niac "Creates a new BufferedImage with the specified width and height.
22:32niac Uses BufferedImage/TYPE_INT_ARGB format by default,
22:32niac but also supports BufferedImage/TYPE_INT_RGB when alpha channel is not needed."
22:32niac (^java.awt.image.BufferedImage [width height]
22:32niac (new-image width height true))
22:33niac (^java.awt.image.BufferedImage [width height alpha?]
22:33niac (if alpha?
22:33niac (BufferedImage. (int width) (int height) BufferedImage/TYPE_INT_ARGB)
22:33niac (BufferedImage. (int width) (int height) BufferedImage/TYPE_INT_RGB))))
22:33niacwhat dose ^ for?
22:33justin_smithniac do not do that
22:33justin_smithuse refheap or something
22:33niacsorry
22:33justin_smith^ adds metadata
22:33justin_smithin this case it is a type hint
22:33justin_smithletting the clojure compiler create faster code
22:34niacjustin_smith: type hint. i see
22:35godd2,(defn str_len [^String s] (.length s))
22:35clojurebot#'sandbox/str_len
22:35godd2,(str_len "hello")
22:35clojurebot5
22:36godd2otherwise you'd just do str_len [s] and let clojure divine that you always send s string
22:36godd2a string*
22:36justin_smithgodd2: kind of similar, but in niac's example it is declaring the type returned
22:37justin_smithwhich may even be redundant in that case, since statically you can know every arity returns the result of a call to that constructor
22:37justin_smithbut maybe clojure isn't smart enough to derive such things
22:37gfredericksyeah I doubt it
22:37godd2they might have turned on warn-on-reflection and went around type-hinting until it stopped yelling at them
22:38justin_smithgodd2: in that case you would type hint args, not return values surely?
22:39godd2No clue. I don't have as much nitty-gritty knowledge on the matter