#clojure logs

2012-06-18

01:16michaelr525good morning
01:16michaelr525!
01:28tomojis there a good way to write new macros with recur semantics?
01:28tomoje.g. imagine loop didn't exist, could you cleanly write it as a macro the way it works with recur?
01:30tomojI suppose if you could, loop* wouldn't exist..
01:39amalloytomoj: sure. you can macroexpand to ((fn [] ... (recur)))
01:40amalloybut you're stuck with recur
01:42amalloyyou might find https://github.com/flatland/useful/blob/develop/src/useful/seq.clj#L108 relevant
01:42amalloyit's a loop-like construct that lets you use either a regular recur, or a lazy-recur, which goes through lazy-seq
01:43tomojhmm
01:44tomojI was thinking it would be harder to use an alternate name
01:44amalloy(sample usage at https://gist.github.com/776f35f77c198cf98bff)
01:44tomojthe lack of hygiene seems weird
01:45tomojbut that's better than whatever I was imagining with "recur", and no less hygienic..
01:46amalloywell, loop/recur aren't hygenic either, really. recur is a symbol implicitly captured by loop
01:46tomojyeah
02:07tomojit seems like in clojurescript if you (println 1 1), it prints "11\n", but (println 1 2) prints "1 2\n" O_o
02:12bbloomtomoj: ?
02:12bbloomtomoj: whoa. lol
02:12bbloomwtf?
02:13tomojhttps://gist.github.com/2225f2e6152d9a052cb1
02:14tomojahh
02:14bbloomtomoj: yeah, i was just looking at that… i'm not sure what it's trying to do
02:14tomojat first I was like, why the heck did they write lines 7-8, now I get it
02:15tomojit's just a buggy version of interpose
02:15bbloomtomoj: yeah. do you want to make a patch?
02:15tomojI will, but is there a CA I have to mail off :/
02:15bbloomcan you open a ticket & i'll make a patch? :-)
02:16tomojgreat
02:17amalloywow, that's a pretty remarkable implementation of println
02:17bbloomamalloy: what's the "remark" you'd make about it? :-)
02:19amalloyi abstain
02:19bbloomamalloy: heh, i'm actual curious. what do you think is wrong with it?
02:21tomojbbloom: http://dev.clojure.org/jira/browse/CLJS-319
02:21amalloywell, the obvious error, right? i think it's probably there's some more-general bug this is a special case of, something like "don't look at the values of your sequence if you're not supposed to care what they are"
02:22bbloomamalloy: oh. i thought you were referring to the more general pr-seq approach
02:22bbloomtomoj: thanks, testing a patch now
02:22amalloyi don't know enough about cljs's internals to comment on that
02:23amalloyi can't really tell what pr-seq does, even
02:24bbloomamalloy: in short, it's an optimization for building big strings out of many small parts. instead of stitching strings and re-stitching strings, you just always stitch them into a single buffer by walking over a sequence
02:25bbloomtomoj: there is also the same bug in pr-with-opts
02:26tomojthat's where I saw the bug, is it copied somewhere else?
02:26bbloomtomoj: oh, sorry, yeah, the other one is pr-sb
02:26tomojah
02:26bbloomtomoj: two versions of the same thing. one writes to "*out*" so to speak, and the other to a string buffer
02:27bbloomtry println-str
02:27bbloomprobably could be made higher order :-P
02:28bbloomactually, probably not w/ the string buffer and all… *shrug* i'll just make the fix twice :-)
02:29tomojhttps://gist.github.com/e3c23b2ba35439c604c0
02:29tomojnot sure how I feel about this
02:29bbloomI'm fixing it :-)
02:30bbloomwhat's that after-loop stuff?
02:30bbloomasync?
02:30tomoj(I mean about my macro, not the print bug)
02:30tomojit's pretty much a port of rx's recursive relative-time scheduling
02:30bbloomah neat
05:51Kototamawhat's the problem with maven today? first I got a problem downloading data.json and now that: http://paste2.org/p/2055280
05:55Kototamaoh yeah 503 error http://repo1.maven.org/maven2/org/clojure/java.jdbc/0.1.2/java.jdbc-0.1.2.jar
07:18cshellcemerick: Why does the friend authenticate method need to be called for each URI? Couldn't we tie it specifically to the login url? It seems like the authenticate method could execute for a particular URI, update the session, and then not need to be called again - am i missing something?
07:23cemerickcshell: the authenticate middleware is what turns unauthorized accesses into redirects to your login uri. If you don't need that, then you could probably get by with applying it only to your login route.
07:24cemerickThat might be a hint that authenticate should be split up into two separate bits of middleware. Something to think about, anyway.
07:25cshellcemerick: Okay, cool - I was looking at the OpenId workflow and it checks specifically that the uri is the login uri else it returns null
07:25cshellsorry, nil :)
07:26cshellI modeled my gitkit workflow off of that and only execute if we're on the callback uri - the one that comes back to us from the OpenId provider (so halfway through the existing openid workflow)
07:30Chiron_Hi, any performance penalties associated with multimethods?
07:31ro_stslower'n protocols :-)
07:32Chiron_in my case, check for a parameter and save to a different column family in cassandra depending on event type. I only have 6 cases
07:32Chiron_could be done with cond but multimethod provides a higher view (and some sexiness)
07:33ro_stcoding for performance usually moves one away from coding for .. sexiness
07:34ohpauleezChiron_: If you know you'll only have those six, and there's no possibility the domain will ever grow, you should use cond
07:34ohpauleezOptionally, use core.match, which will get compiled as cond
07:35Chiron_multimethods shouldn't be touched for a small number of cases?
07:35ohpauleezIf the domain will grow, of the function used to classify them could change with business logic, use multimethods
07:36ohpauleezChiron_: Multimethods are useful when you need open-ended dispatch on a variable number of things, and you know those things will change in the future (or you want to open the system to new things further down the road)
07:37ohpauleez* dispatch on more than just type
07:37ohpauleezIf you're dispatching on type, just use a protocol
07:38Chiron_how much it is hard to learn and use core.match?
07:39Chiron_i know nothing about it
07:39si14ohpauleez: why did you split your framework to separate packets?
07:39si14btw, looks awesome
07:39si14*repos
07:39ohpauleezsi14: There will be a "master" package/repo/clojars release
07:40ohpauleezthe split is to allow people to use it ala carte if they're building up their own stuff
07:40ohpauleezFor example, someone could build something and want to stand on top of just my pub sub stuff
07:40ohpauleezthanks! that's good to hear!
07:41si14ohpauleez: Google Closure will eliminate all dead code, doesn't it?
07:41Chiron_ohpauleez: what is your framework? :)
07:41ohpauleezsi14: Yes, it totally will. But, I've had enough requests to split it up, so I did.
07:42ro_stwhich framework is this?
07:42ohpauleezNot ready for the public yet, but Shoreleave: https://github.com/shoreleave
07:42ohpauleezI'll be debuting it on Wednesday at the NYC Clojure meetup
07:43ro_stwicked!
07:43Chiron_a new web framework?
07:43ohpauleezIt's a group of CLJS utilities
07:43Chiron_clojure on the server and the client?
07:43ro_stohpauleez: i have a 'traditional' gclosure app which i'm aching to cljs-ify.
07:44ohpauleeznot so much a framework, but what I had to build to start building serious CLJS apps
07:44ohpauleezro_st: Shoreleave should help. It extends a lot of protocols to gClosure stuff
07:44ohpauleezChiron_: yep!
07:45ohpauleezIt allows you to expose server-side namespaces as namespaced client-side calls
07:45ohpauleez(and has security, like CSRF protection) built in
07:45ohpauleezand a bunch of other stuff haha
07:45Chiron_cool! how it differes from ClojureScript One ?
07:46ohpauleezCS:One is similar, but is more a collection of functions grouped into a base application that you can use as a starting block
07:46ohpauleezShoreleave is a set of functions and services you use to build whatever you want
07:47si14I'm wondering if anyone actually made CS:One into useful app
07:47Chiron_"It allows you to expose server-side namespaces as namespaced client-side calls" something like DWR strategy?
07:48ohpauleezThere's no starting block. You can use Shoreleave's pub sub system to declaratively bind your app together, the remotes package to call your server and third-party servers (like a SOLR server somewhere), there are embedded web workers, and a lot of browser functionality extended to CLJS facilities/protocols
07:48ro_stohpauleez: a word of advice / a huge request: working sample code that exercises the stuff in the libraries, please!
07:48ohpauleezro_st: On it's way, I have two apps: One that uses SOLR and JSONP. And the TODO app
07:49ro_stas a clojure newb, i have difficulty grokking clj libraries unless they map to stuff i'm used to
07:49ohpauleezagain, this stuff isn't ready, I've been hesitant to talk about it (which is why it's not in Clojars yet)
07:49ohpauleezbut it should all be there by Wednesday
07:49ro_sti would love it if someone (cough @ cshell) could share their friend implementations, for example
07:50ohpauleezro_st: Also have a look at the Marginalia docs for each module. They're just in first drafts, but hopefully that'll help too
07:50ro_stit'd be awesome if friend had some samples
07:50ohpauleezro_st: I toyed with the idea of a Shoreleave/Friend demo
07:50ohpauleezso maybe I'll see if I can make that happen
07:50ro_stcool, i will do ohpauleez. i'm still thoroughly in backend-land for a while, so i'll probably only get to shoreleave in a couple weeks
07:51ohpauleez(Client-side auth comes up often enough)
07:51ohpauleezcool
07:51ro_stvery grateful that you're sharing with us, though. i love the idea of using clojure end to end
07:51ro_sti just found out travis-ci supports selenium testing!
07:52cemerickohpauleez: What is Shoreleave?
07:52ro_stcemerick: https://github.com/shoreleave/shoreleave-core
07:52ohpauleezcemerick: CLJS bliss haha
07:52ohpauleezA collection of utilities for CLJS apps: to build end-to-end CLJS apps
07:53ro_stjust reading the marg docs. looks great
07:54ohpauleezcemerick: a pub sub system that supports functions, atoms, local storage, and embedded web workers as topics. Embedded web workers. Exposing server-side namespaces as client-side namespace'd calls, wrapped browser functionality
07:54ohpauleezro_st: Awesome!
07:55ohpauleezcemerick: CSRF-protection, and XSS escaping where needed
07:57cemerickhah, didn't realize that there's a cljs enlive impl
07:57ohpauleezIt's pretty solid. It has DOM listeners, and DOM "Actions"
07:57ohpauleezso coupled with my pubsub, I can declaratively bind my entire application
07:58ro_stthat is hot
07:58ro_stcan't wait to see that in action
07:58ro_stso -ing tired of writing gclosure events
07:58ro_stfeel like i have to sing 99 bottles of beer on the wall every time i want something to happen!
07:59ohpauleezAgreed!
08:02ro_stwhat is your approach to state in cljs, ohpauleez?
08:02ro_stas a newb, i'm not sure if stuff like MVC still applies in client side clojurescript
08:03ro_sti guess your todo example app will answer that :)
08:03piranharo_st: heh, I have same problem (coming to mvc, wondering what to do with state)
08:03piranhastarted with reading https://github.com/lynaghk/c2-demos/blob/master/todoMVC/src/cljs/imtodo/core.cljs
08:03piranha*coming from mvc
08:04piranhabackbone.js, etc
08:05ro_stright now i have a context obj which gets passed injection style to all the key manager classes, and each manager has its own internal state. managers all listen to each other and event out when they need to share state changes or when views need to update
08:06ro_steasily 50% of my code is all the hopscotchery of state declaration and setting state (and testing same)
08:07ro_stthe state machine stuff in cljs one looked a bit alien to me, to begin with. seemed like a helluva lot to go through to move back and forth between the two simple views that its sample has
08:07piranhayeah... I'm jumping between different approaches, still can't decide how should it be done :(
08:08ro_stcemerick: -grin-
08:08piranhatried to get simple event system + state, which fires those events
08:08piranhabut it was a bit creepy to me, so I scraped it...
08:09ro_stthis is why ohpauleez's declarative bindings sounds great. in adobe flex, we had the same thing. views were templates + bindings, and simple event handlers to deal with user interactions -> model changes
08:09piranhait would be interesting to see some at least moderately sized application
08:09ro_styes. agreed
08:09piranhahm, declarative bindings?
08:09piranhayes, in backbone we have the same: models, and views, which render templates and handle user input and model changes
08:10ro_styes. <Label text="{ thing.name }" />. change thing or thing's name, and Label's text is replaced
08:10piranhayep
08:11ro_stthey did decl bindings with a compilation step. that'd be compiled down to as3 with enough event boilerplate for a small country
08:12ro_stwas nice to use, but performance is horrible.
08:12piranha:-)
08:12piranhaso, are his declarative bindings available somewhere? :-))
08:13ro_stas he said: cljs-enlive and shoreleave-pubsub
08:13ro_sthe's doing a release of shoreleave on wednesday. i'd hold out until then :-)
08:13piranha:-)
08:14piranhahey, here is quite a bit of good stuff on shoreleave github org
08:14piranhaI guess I can stop using most of google closure
08:14piranhasounds great ;D
08:17piranhaah, it still uses goog.* behind the scenes
08:17ro_stit will do. cljs uses goog
08:17ro_styou want to use goog. you just don't want to have to write that code yourself, like i am currently :-(
08:17ohpauleezpiranha: Yeah, it just wraps most of the nonsense up
08:18ro_stthousands of dev hours in that library, lots of battle testing across more browsers than we could ever hope to virtualise ourselves
08:18ohpauleezro_st: I manage state in the DOM and local storage. Only one of my apps uses an atom to hold "join-data" for state
08:18piranhaohpauleez: yeah, the thing is that I've used Jsonp from goog yesterday and resulting (compiled with :advanced) file became 10k bigger...
08:18ro_stso anything that isn't present in the view (ie, on display) is in local storage?
08:19ohpauleezro_st: More often than not
08:19ohpauleezMy layout looks like this:
08:19piranhaohpauleez: hm, what's wrong with atoms?
08:20ohpauleezmain.cljs -> hook up history, wire up the bindings, set up brepl, attach listeners. listeners.cljs -> all the listeners I need. render.cljs -> All the DOM actions I need and the template functions
08:21ohpauleezthen a file per major action of service
08:21ro_stthat sounds awesome. can't wait to see a working project.
08:21ohpauleezlike search.cljs if I'm working with SOLR. mail.cljs for all my remote calls for emailing
08:21ohpauleezpiranha: Nothing, I just don't have a use for them
08:21piranhaok :)
08:23ohpauleezpiranha: I still use atoms, but more often than not. The data tucked in the DOM and pushed into localStorage is enough
08:23ohpauleezbut more often than not, **
08:24piranhayeah, I see, it's just that I'm used to backbone's approach of storing everything in your objects and syncing to DOM/localStorage/server when I need/want this
08:24piranhaand atoms sound like a perfect replacement for this :)
08:24ro_sti've been doing the MVC thing: user action event triggers a command class (so i can track usage and do undo/redo). command affects model. model changes event out, causing listening views to re-render their DOMs
08:25piranhayep, and atoms with add-watch sound like good plan there to me...
08:25ohpauleezro_st: I think there is a different paradigm that CLJS opens up in the client. I'm not sure MVC is the best approach. Most of my apps operate on streams of data/actions. They're shaped a lot like how I write backend systems for Clojure. Declarative/reactive bindings seem the best fit here.
08:25piranhahm
08:26piranhaI'd like to see working code if that would be possible, honestly, I really need shift in my head it seems :)
08:26ohpauleezWhen I need to store data across multiple interactions, I use an atom. When I want to save off parts of results or large data sets, I use localStorage. I save small nuggets of view-specific data with the history via HTML5 history API
08:27ro_stinteresting
08:27ohpauleezThere is still very much a separation between data, view, control/binding - but it doesn't force you to solve all problems with the same devices (something I think Backbone suffers from)
08:28ro_stmy app is document based. start it up, choose a library of content to work from, create your own document, save/export. so i definitely need the M in MVC here
08:28ohpauleezregardless of the best approach, using CLJS has been a blast and extremely productive
08:29ro_stthe library of content can be an atom (because you can switch libraries) and any amount of fns to retrieve data (it's quite structured). the user's doc can also be an atom, and internally it'll have all the required state… undo/redo, user-added data, etc
08:29ohpauleezro_st: Yeah, you need to manage incremental changes. This is the type of app most people are coming up against
08:29ro_styes
08:29piranhaargh, I have to run. ohpauleez: if you'll do some write up or open source release, it would be awesome to see them :)
08:30ro_sttwo atoms, because i want to be able to easily serialise and deserialise the workspace atom from localstorage or the server
08:31ro_stanother big use of state in client-side js is for performance: reducing repeated lookups by caching local references
08:32ro_sti wonder how well the gclosure compiler is able to optimise for this from cljs's generated js
08:32ro_st(if at all)
08:33ohpauleezro_st: So one thing I'm not sure about is the need to go atom->ls or ls->atom
08:33ohpauleezI extended protocols to ls, so you can use it in sane way. Which is why I haven't made use of atoms (I just bang on localstorage)
08:34ohpauleezI'm not sure this is a good practice, but it saves me one layer of control logic
08:34ro_stfor example, i want users to be able to resume (on mobile). so save-button serialises the workspace into LS. reloading the browser page fetches your latest save and re-hydrates the view
08:36ohpauleezRight. But I'm just not sure the advantage of using an atom to store off partial data (say, all the things related to user) over having a :user entry in ls
08:37ro_stagain, performance. localstorage stores strings
08:37ro_stnot objects
08:37ohpauleezand using (assoc! ls :user {}) => (reset! user-atom {})
08:37ohpauleezbut we have the reader
08:37ohpauleezso now it stores everything
08:37ro_sti thought you can't eval clj browser-side?
08:37ohpauleezyou can read it, you can't veal it
08:37ohpauleezeval*
08:38ro_stso you can get back maps, vecs, sets and lists of primitives, but not of fns that you can then execute?
08:38ro_stinteresting
08:38ohpauleezexactly
08:39ohpauleezand I wrapped all that up
08:39ohpauleezworks in cookies too
08:39ohpauleezand in history states
08:39ro_stvery compelling
08:39ro_stdefinitely going to have to play with it
08:39ro_stjust need to figure out a way to not have to sleep anymore
08:39ohpauleezhaha
08:40ro_stwhat's the cljs testing story like?
08:40ro_stmidje et al?
08:41ohpauleezro_st: That story is largely absent, but there people are working on it
08:42ohpauleezAt tutorspree, we have cucumber+selenium anyway, and that continues to work for us
08:42ro_stok cool. right now i use jasmine bdd specs (written in coffeescript)
08:42ohpauleezjasmine is awesome too
08:42ro_stand i run them on my CI via a 3-liner cuke
08:43ro_stexcellent. exciting
08:46ro_sttrying to use a non-Emacs editor after using Emacs for a couple weeks is infuriating
08:52TimMcC-s C-s C-s dammit why can't I search?
08:53ro_stC-M-space to select a form. C-a and C-e for start/end line (amazing how quickly those stick!) C-c C-c C-d for docs
08:54ro_sti can already see a javascript-mode emacs setup on the horizon
09:01vijaykiranro_st: I think you mean js2-mode :)
09:01ro_styes, thank you!
09:02ro_sti can use paredit with that, right?
09:02foxdonutro_st: I feel the same way about vim
09:02foxdonutemacs has too many keystrokes to get things done
09:03vijaykiranro_st: didn't try it but yes, you can
09:03ro_sti can do silly stuff like store some clojure source in a database, and pull it out and eval it and execute it, assuming a standard interface for calling into the code, right?
09:04vijaykiranro_st: yes, check eval
09:04vijaykiran,(doc eval)
09:05vijaykiranyou probable need to load the text first, since eval operates on datastrcture
09:05ro_stok so to use eval i'd first have to (read ) it first
09:05ro_st-first
09:05ro_stoh i see (load)
09:05ro_stperfect
09:07ro_stis there a variant that'll load, run some code in a closure, and then unload it all again once the closure completes? kinda like with file io
09:07ro_stlike with-open
09:07vijaykiranhttp://clojuredocs.org/clojure_core/clojure.core/read
09:08vijaykiranexample looks like what you want
09:09ro_stthat looks great. so in my case, i'd (read r) and then add (func-from-that-file args-it-expects) and it'd return its results all the way up and toss all the transitory stuff
09:10TimMcI hope you have a good reason for using eval...
09:10TimMcor are you just playing around?
09:11ro_stuse case is that items in our library have quiz elements and each quiz is different. i'd like to put a small clojure fn in each library item that calcs the associated quiz's results, so that when that quiz is submitted, server reaches in, finds the result-calc, calcs it, and stores the result
09:11ro_stwithout having to hard-code each quiz into the main server codebase
09:12vijaykiranro_st: probably a dumb question - but is there a way you can just save the "rules" of calculating the quiz results instead of storing implementation ?
09:13vijaykiranmay be you can avoid read/eval
09:14ro_sti should probably look into doing that
09:14foxdonutStoring code in the database is a Bad Idea.
09:14foxdonutro_st: as I crawl on the ground, bloody and half-dead, I whisper, "don't do it!"
09:14ro_stin this case, it's more storing a formula that is expressed as evaluatable code
09:15vijaykiranwell, this can be a valid usecase for that - considering it as "rule" for the rule engine
09:15ro_stotherwise i have to concoct a rules language and a parser
09:15vijaykiran:)
09:15TimMcro_st: How complex a formula might you have?
09:16ro_stit's really ridiculously simple. ensure i have 40 answers. check each one against the quiz for = or not=. sum up the hits. return a percentage
09:16ro_stsome quizes need two distinct percentages, each using some subset of the answers. some quizes allow multiple correct answers. some require all the correct answers to be present
09:17foxdonutro_st: you could perhaps store the name of the function and just have a name->fn map in code?
09:17foxdonutthen, no eval
09:17ro_stie, super easy to express in JS (current impl) or clojure. but a P.I.T.A to create a language and parser for
09:17ro_sti could do that, but that puts concrete impls back into my main codebase, which is precisely what i'm trying to avoid
09:18ro_stdown the road i want to use this same clojure code (as cljs) to present results clientside, and then have the server re-run the server-side copy to validate
09:18ro_sti could clojail it? wouldn't that prevent the disadvantages somewhat?
09:19TimMcro_st: No, it's your own data, so clojail isn't indicated.
09:20TimMcro_st: No parser is needed, just read in some data structures and process them.
09:22TimMcYou can read in something like {:main {:qCount 40, :answers {0 1, 1 1, 2 3, 3 0...}}, :alt {...}} where :main is the main score, :alt is some other one...
09:22TimMcqCount isn't needed either, for that matter, just count the answers map.
09:22TimMcro_st: Scoring code isn't programmatically modifiable in the general case, but data structures are.
09:22ro_stqcount is to validate that the client sent enough answers. otherwise i could answer one correctly and send it and get 100%
09:23ro_stok. i'll have a go at this approach
09:23TimMc"just count the answers map" <-- as in, the expected answers
09:23ro_stoh, right :) duh
09:23TimMc:-)
09:23ro_stthanks guys. eval avoided.
09:24TimMc\o/
09:24ro_sti promise not to store code in the database, foxdonut, even at Web Scale
09:24TimMchaha
09:25ro_stoh, he left
09:26ohpauleezdustingetz: it's nice to see you in here as a regular
10:05alexyakushevHello, could anyone please tell how can I provide some arguments to AOT-compilation process so the code being compiled would be aware of them?
10:06alexyakushevIn other words, I have two types of AOT-compilation: "debug" and "release", and I want the macroexpansion to depend on whether is used
10:07ifesdjeenalexyakushev: can't you use leningen2 profiles for that?
10:07ifesdjeenlike --with-profile debug etc
10:07TimMcalexyakushev: Perhaps some environment variables?
10:08alexyakushevTimMc: I thought about it, but where can I set them? Before calling to clojure.core/compile?
10:09alexyakushevTimMc: I mean, via System.setProperty() ?
10:09ro_stalexyakushev: you can prepend calls to lein wth env vars
10:09ro_stDEBUG=true lein2 compile
10:09TimMcFOO_MODE=release lein uberjar
10:10TimMcand then use System/getenv
10:11alexyakushevro_st, TimMc: Thanks, that's an option, but I already use "DEBUG=true" calls to act like I'm running the Leiningen itself in the debug mode, not the application I'm compiling
10:11TimMcDo the env vars get through to your macro code?
10:14alexyakushevTimMc: I've just tried to do "FOO=true lein compile" and it didn't end up in (System/getProperties)
10:15alexyakushevOr it should be inside the System/getenv ?
10:16TimMcgetenv
10:16alexyakushevYes, it works with System/getenv, but I'm still rather control it from inside
10:17alexyakushevPerhaps, System/setProperty will be OK if I pickup a property that does not mingle with anything else
10:18ro_stjust use a unique name
10:18alexyakushevOK, thanks for your help!
10:18ro_stthanks for teaching me how to do this in future :-)
10:19gfredericksam I crazy, or is there no simple way in minikanren to reverse a list faster than O(n^2)?
10:26ro_stlooks like you're crazy :-)
10:49wjlroeIs there any ring middleware (or something like that) for recompiling my clojure code for every request (in development, while running with slime/swank) ? I tried writing my own but it didn't work
10:50wjlroeThe reason being, if I change a template file, enlive doesn't serve up the new one until the deftemplate is recompiled
10:50vijaykiranI think ring has wrap-reload
10:51vijaykiranbut it doesn't monitor html files - enlive has few forks that do it for you
10:51wjlroeoh ok, interesting
10:53dnolengfredericks: you should look at Prolog solutions to this, nrev
10:54dnolengfredericks: I believe most Prolog implementations may cheat with nrev - it is handled specially.
10:55dnolengfredericks: similarly, I see no problems with just calling Clojure reverse from within your core.logic program.
11:03gfredericksdnolen: surely reverse wouldn't handle a logic variable
11:14lypanovis this a new thing?
11:14lypanovmaven failing on release day?
11:17lypanovanyone know what i can replace repo1.maven.org with?
11:21lypanov:(
11:21lypanovfirst two releases on clojure and both failing. this is really not looking good to the rest of the team.
11:21vijaykiranhttp://uk.maven.org/maven2
11:22vijaykiranlypanov: ^
11:22lypanovvijaykiran: ah so repo1 is the central but is mirrored everywhere else.
11:22lypanovwhere can i place that in order to have lein ignore central?
11:22lypanovcurrently central is 503ing on everything after multiple minutes.
11:22lypanovhas been doing since this morning.
11:23lypanovdo i just add an extra repo line to project.clj?
11:23lypanovor should i edit my maven config itself somehow?
11:24vijaykirantry - http://maven.apache.org/guides/mini/guide-mirror-settings.html
11:25lypanov"For example, the ID of the main Maven Central US repository included by default is central"
11:25lypanovmissed it first time i read that page. thx for linking again!
11:25lypanovso i'm guessing the repo line in lein can also just take that
11:25lypanovand it'll override… trying.
11:27lypanovException in thread "main" java.lang.IllegalArgumentException: Duplicate key: central (NO_SOURCE_FILE:0)
11:27lypanovmeh
11:28lypanovthe exact block of code from the page in a new settings.xml (didn't have one) is doing the same.
11:29lypanovdoes anyone know how to make leiningen not check maven but instead just use my lib/ dir?
11:29lypanovas if release wasn't stressful enough.
11:29lypanovwill be ripping out maven asap. just as bad as its always been.
11:30vijaykiranlypanov: set :offline? to true
11:30vijaykiranlypanov: to make leiningen not check maven
11:31vijaykiranlypanov: https://github.com/technomancy/leiningen/blob/master/sample.project.clj#L164
11:32lypanovthank you.
11:32lypanovowe you a few pints if we ever meet.
11:35Wild_Cathrmm. Clojure uses not= instead of !=. Surprising.
11:35uvtcI'd wondered about that myself.
11:38Wild_Catit's weird how functional languages all use a weird operator construct for that.
11:38uvtcOh well though, 6 of one, half-dozen of the other.
11:39Wild_Catyeah, its not that much of a problem. Plus, at least, not= looks more explicit and obvious than /= or <>
11:39mhansonhelp
11:39mhansonHm.
11:40lucianhaskell is pretty insane about its function names
11:40lucian<*, *>, <*>, ==<, ...
11:40lucianand don't forget $
11:41RickInGA>>=
11:41lypanovvijaykiran: lein run just ignores it.
11:41lypanovwhat is the way that most people are doing this?
11:41lypanovas in, what am i doing wrong?
11:41pepijndevosHow does detect-silence work in Overtone?
11:42pepijndevosI want to detect-noise and then run a synth
11:42lypanovor is it really just me for which two production runs in a row have involved maven failures?
11:42Wild_Catlucian: yeah, Haskell is crazy about 4-non-alphanumeric-character operators :p
11:42lypanovdoes http://repo1.maven.org/maven2/noir-cljs-lypanov/noir-cljs-lypanov/0.3.5/noir-cljs-lypanov-0.3.5.pom fail to respond for anyone else?
11:43zachtlypanov 404
11:43vijaykiranlypanov: try adding offline in settings.xml
11:43lucianWild_Cat: yeah, you'd think naming things hadn't occured to them
11:43lypanovzacht: wtf?
11:43axle_512emacs/clojure question: Any reason why I would get tab completion in the slime repl, but not while editing my .clj file?
11:43vijaykiranaxle_512: check if clojure_mode is on?
11:43semperosaxle_512: you have to do C-c TAB
11:44Wild_Catlucian: well, when they *do* name things they use the opposite meaning of what's associated with the name (hello, return :p )
11:44semperosin a file, whereas at the REPL simply TAB does completion
11:44lucianWild_Cat: that too
11:44axle_512semperos: that was it!
11:44lypanovzacht: 503 after 2-3 minutes here.
11:44axle_512semperos: thanks!
11:44semperosaxle_512: np
11:44Wild_CatI keep wanting to love Haskell for its elegance, but it keeps finding reasons for me not to.
11:45Chiron_Hi, for a structure like this: {:timestamp-1 {:links { .. } , :buttons {.. }}, :timestamp-2 {:links { .. } , :buttons {.. }} , this structure should be stored to a DB . what would be an idiomatic way to iterate over it?
11:45Chiron_as you figured it out, it is a data for analytics :)
11:46semperosChiron_: what are you trying to do by "iterating over it"? what output do you need?
11:46zachtlypanov http://search.maven.org suggests that the repository has nothing with noir, cljs, or lypanov in its name.
11:47zachtlypanov In which case a 404 is exactly right. :-)
11:48Chiron_I need values to be saved to a database . for something like this :timestamp-1 {:links {blog-1 4} , :buttons {blog-11 100} blog-11 should be saved to table buttons and blog-1 should be saved to table links
11:49lypanovzacht: problem is, its not doing that.
11:49lypanovhere its giving 503s.
11:49lypanovanyway, i'm done with this.
11:49lypanovtime to replace this half assed toolchain.
11:51lypanovits fixed.
11:52lypanovnope. just a fluke. !@#$.
11:54lynaghk`dnolen: I didn't even know there was a *clojurescript* var; if that's the case, are there plans to remove the core.match.js custom namespace?
11:55dnolenlynaghk`: not really, that var is bound in macro in the core.match.js ns.
11:57lynaghk`dnolen: okay. I'll just change the keyset issue then. Do you want the patch against master or alpha9?
11:57dnolenlynaghk`: master please.
11:58lynaghk`dnolen: sure thing.
12:00pepijndevoshow can I make overtone block until a sound has finished playing?
12:03semperosChiron_: here's some example code: https://gist.github.com/2949115
12:03semperoswith println's where you could write your DB-handling code
12:04semperosmain tactic there is using destructuring to deal with your map structures
12:04lypanovhow do most people deal with mavens complete lack of ability to keep a stable infrastructure?
12:04lypanovshould i run my own local mvn server?
12:05Chiron_semperos: Thanks! that is really cool. I really appreciate your time :beerchug:
12:05semperosChiron_: no problem
12:05semperoslypanov: that's what my company does
12:06solussddoes anyone know if enlive supports sibling selectors?
12:07pipelinelypanov: yes you absolutely should
12:07pipelinelypanov: btw this sucker makes maven way easier to live with http://www.sonatype.org/nexus/
12:09lypanovare there any sanely priced cloud solutions?
12:09lypanovor is this secure / easy enough to setup that i can just shove it on a rackspace instance and be done?
12:12lypanovfound the book. downloading.
12:20lypanovibiblio works.
12:20lypanovuk doesn't work because it is the same damn thing as repo1
12:21lypanov(lots of fun that the freaking mirror example uses it therefore)
12:22lypanovalso mirrorOf doesn't work.
12:22lypanov*sigh*
12:22lypanovDownloading: org/clojure/clojurescript/0.0-1069/clojurescript-0.0-1069.pom from repository central at http://repo1.maven.org/maven2
12:23lypanovstill looking at the wrong thing.
12:24lypanovand <mirrorOf>*</mirrorOf> doesn't appear to be listened to by leiningen for some reason.
12:24lypanov(it still uses the fallbacks)
12:25lypanovokay fix for that last one is to not have something that doesn't actually exist.
12:26lypanov( ;) )
12:28the-kennyIs Central broken? We're having massive problems here.
12:29lypanovits down yes.
12:29lypanovuse ibiblio.
12:29lypanovhttp://mirrors.ibiblio.org/pub/mirrors/maven2
12:29lypanovhttp://maven.apache.org/guides/mini/guide-mirror-settings.html
12:30lypanovfirst code block, replace uk mirror with http://mirrors.ibiblio.org/pub/mirrors/maven2
12:31lypanov(reason for that is that uk mirror is also down)
12:32lypanovits not really that its down. its just that they are all so incompetent that 404s are timing out instead of returning 404s.
12:36technomancyso this outage is about more than just the org.clojure group?
12:37lypanovyeah.
12:38lypanovbasically unless you have a repo mirror with all content you're gonna see massive delays during deploy.
12:38lypanovso i'm gonna take pipeline and semperos 's suggestion and just set up nexus or something locally.
12:38lypanovtwice now we've had release day critical failures.
12:38lypanov(and no, uberjar is not a solution i want to use)
12:39technomancyyeah, nexus would definitely insulate you from outages
12:39lypanovtechnomancy: i can't be angry at anyone other than myself that way :P
12:43technomancyrelated: http://whoownsyouruptime.com
12:43pepijndevoshow do you install supercollider plugins into overtone?
12:46technomancylypanov: what's your geographic region?
12:46lypanoveurope. .nl.
12:48technomancylypanov: it's taking 8 seconds here to return a 404 on central; is that close to what you're seeing?
12:48lypanov1 minute and upwards sometimes. let me check.
12:48Bronsayeah, here too
12:48Bronsa[italy]
12:50technomancyok, now I'm getting huge delays
12:52technomancy189.492 secs
13:03lypanovtechnomancy: trying in browser sometimes gives it back fast. more reliably broken without proxy as in curl.
13:50S11001001TimMc: what is this code-and-cocktails thing?
14:03Chiron_Hi, can we use a generic type in Clojure? in my case, I'm going to use Hector API http://hector-client.github.com/hector/build/html/content/getting_started.html
14:03Chiron_ColumnFamilyTemplate<String, String> template = .....
14:03S11001001Chiron_: yes, clojure is post-erasure, just pretend the typevars aren't there
14:03Chiron_S11001001: I'm totally in love with update-in and fnil xD blowed my mind
14:05uvtc"post-erasure"? What does Clojure have to do with 80's pop music?
14:06uvtcChiron_, also get-in. So nice.
14:06nDuffuvtc: Java's generics are a language feature that isn't actually represented in the bytecode
14:07nDuff...so, the extra type information is discarded after being used for checking during compilation.
14:08uvtcnDuff, Oh, I see. Tried to make a joke, then learned something. :) Thanks.
14:17TimMcS11001001: Beats me.
14:17Chiron_clojurebot: do you like Frank Sinatra?
14:17TimMclazybot: Do you like 70's music???
14:17lazybotTimMc: How could that be wrong?
14:18Chiron_huh! where is our lovely clojurebot ?
14:18hiredmanoom killed, what I get for using a t1.micro
14:51rdsrOn startup my clojure repl switches to a namespace I've decided.
14:51rdsrThis namespace just "uses" other namespaces and doesn't define
14:51rdsrany of its own vars, but when my repl starts up I'm unable to
14:51rdsraccess any of the public vars defined in other namespaces. Is
14:51rdsrthere a way I can accomplish this?
14:51rdsrHere's my startup command
14:51rdsrjava -cp $classpath clojure.main -e "(ns A) (clojure.main/repl) (in-ns 'A) (clojure.core/use 'clojure.core)"
14:51rdsrs/decided/defined
14:52rdsrwhat' im doing in namespce A
14:52rdsr(ns A
14:52rdsr (:use [B]
14:52rdsr [C]))
14:53gfredericksrdsr: you have a file with that code in it? is that file getting loaded?
14:54rdsr@gfredericks. Yes that file is A.clj
14:54gfredericksrdsr: how does it get loaded?
14:55solussd_can I "extend" a namespace without having to add (load …) forms to the original namespace file. E.g. if I wanted to add to the some.lib.thing namespace with a new file
14:55rdsrhmm. It mostly not getting loaded.
14:56nDuffrdsr: Consider require'ing A before switching to it.
14:56rdsrthanks @nDuff and gfredericks I'll try that out
14:58SrPxis clojure a lisp fam language? how is it different from cl and scheme?
14:59rdsrSo something like "java -cp $classpath clojure.main -e "(ns A) (clojure.main/repl) (require 'A) (in-ns 'A) (clojure.core/use 'clojure.core)"" should work right?
14:59nDuffSrPx: (1) Yes (2) Lots of ways; it'd be easiest to start with a book.
14:59AimHereYes; and the major difference is that it's not Lisp all the way up. Clojure is actually written in Java
14:59AimHereAlso what nDuff said
14:59AimHereAlso more parentheses
15:00AimHereYou get to play with [] and {} as well as ()
15:00nDuffAimHere: ...not to be forgetting ClojureCLR...
15:00AimHereOr clojurescript
15:01nDuff(well, clojurescript still has Java involved, albeit not at runtime)
15:01SrPxis it more or less productive? (know it is subjective but any words on that?)
15:01SrPxI just have to chose which dialect to learn but it is hard because I well, dont know
15:01nDuffSrPx: Clojure is written with a very major focus on being useful for real-world work.
15:02SrPxmore than java you'd say?
15:02nDuffSrPx: from that perspective, I'd take it over Scheme any day, and CL is just plain something of a mess (for historical reasons, but nonetheless)
15:02sritchieSrPx: clojure dev is much faster than java development
15:02nDuffSrPx: There's a major learning curve if you can't think in FP or LISPy terms yet, but once you've got that handled? Yes, very much so.
15:02AimHereWell CL is probably better if you want to write native applications; Scheme is better if you need an academic toy language. Clojure is for real work
15:03SrPxnDuff: learning clojure is enough to have an idea of what is lisp , what it has to offer, etc? without missing anything?
15:03rdsrthanks @nDuff and @gfedericks. Got it working now :)
15:03SrPxsritchie: kind of answer I'm expecting. what is faster than clojure, then? in your opinion
15:03AimHereSrPx, Pretty much, except that some of the implementation details aren't written in Clojure
15:03SrPxAimHere: sorry, what do you mean
15:04AimHereSo if you're doing that SICP thing of writing your lisp in your lisp for learning or experimentation purposes, maybe scheme or CL might be more useful
15:04mthvedtare there any good guides or docs for implementing pprint for some data structure?
15:05AimHereSrPx, if you want to know how to implement Clojure, you have to learn some Java; that might be irrelevant to you, but it might not. Depends what you want
15:06mattmossmthvedt: I *just* this moment did that, for a simple java object that pprint was stumbling over.
15:07nDuffSrPx: *nod* -- if having an idea of what a LISP means implementing one yourself, you might start with a simpler one. If you mean grokking enough of the concepts to be able to pick up another LISP quickly, Clojure should be fine.
15:07mattmoss(with-ns 'clojure.pprint (use-method simple-dispatch org.xyz.abc.LocalizedText #(pr (.toString %))))
15:07mattmosswith-ns coming from clojure.contrib.with-ns
15:08mthvedtmattmoss: thanks!
15:08mattmossAnd this article, which is sadly incomplete. http://richhickey.github.com/clojure/doc/clojure/pprint/PrettyPrinting.html
15:08lazybotNooooo, that's so out of date! Please see instead http://clojure.github.com/clojure/doc/clojure/pprint/PrettyPrinting.html and try to stop linking to rich's repo.
15:09mattmosso_O
15:09uvtcSrPx: one thing Scheme does differently is that with Scheme you use cons/cdr for lists. Clojure just uses regular lists, and has extra built-in syntax for vectors, hash-maps, and sets. Clojure's quite likeable.
15:11mattmossLol... for a moment, I thought I was being scolded. Then I see it's just lazybot.
15:12Wild_Catuvtc: aren't Clojure's lists implemented with cons cells?
15:12uvtcSrPx, so, if you go with Clojure, you sidestep the whole cons/car/cdr thing. Also, you asked about productivity: from Clojure you can directly access all Java libs (no wrapping libs or anything like that required). So, there's that.
15:12cemerickmattmoss: you were being scolded; richhickey.github.com is *old* :-)
15:12Wild_Cat(I do enjoy that they got rid of car and cdr, though)
15:12uvtcWild_Cat, as far as I know, no.
15:12ieureWild_Cat, They're actually arrays of java.lang.Object instances.
15:12Wild_Catieure: arrays? Now that's surprising.
15:12ieureWild_Cat, Go read the source. It's enlightening.
15:12Wild_CatI'd have expected vectors to be arrays, but surely not lists.
15:13mattmosscemerick: Yeah, true that... But I thought a bot was scolding me for my answer to the pprint question, not the link.
15:13mattmossI'm better now.
15:13uvtccemerick, where should I send feedback on the Clojure Programming book?
15:14cemerickuvtc: as in, errata? help@clojurebook.com will do. I think O'Reilly has some form for submitting errata as well, but I don't have a link handy.
15:14Wild_Catbtw, are there any Clojure books (published or close to being so) that were written with 1.4 in mind?
15:14uvtccemerick, Not errata. A section that seemed out of the blue to me.
15:15nDuffWild_Cat: really, a book that covers 1.3 is close enough; 1.4 is not very different at all.
15:15amalloyWild_Cat: lists are conses, but seqs are more general and might or might not be conses
15:16Wild_CatnDuff: fair enough -- what about books written for 1.3? :p
15:16nDuffWild_Cat: ...in terms of something recently published and quite up-to-date, I'd suggest the O'Reilly one (Clojure Programming)
15:16Wild_CatOK, thanks
15:16cemerickWild_Cat: The only significant additions in 1.4 are custom reader literals and mapv/filterv, and a variety of minor tweaks.
15:17cemerickuvtc: sure, help@clojurebook.com is a sane place for anything :-)
15:17uvtccemerick, thanks. Will do.
15:17Wild_Catcemerick: wasn't a bunch of stuff from contrib folded into the stdlib too? (note: Clojure noob, completely unsure of what I'm saying :p )
15:18nDuffWild_Cat: The contrib reorg was a 1.3 thing.
15:18cemerickWild_Cat: That happened in 1.2 and 1.3.
15:18Wild_Catright. Thanks guys.
15:18solussd_new question, if I have two namespaces that I want to alias using (require <namespace> :as <alias>), can I have them, somehow, share an alias? i.e. all symbols from both namespaces can be accessed under the same alias?
15:23cemericksolussd_: There's always a way, but such a thing would be a horrible thing to do to anyone that looks at the code later. :-)
15:28solussd_cemerick: ;) fine… what I really want to be able to do is extend an existing namespace
15:28cemericksolussd_: that's much easier to do; but just don't do it from library code
15:29solussd_cemerick: yeah, just for me. e.g. I want to add validator functions to noir.validation, for example
15:30cemericksolussd_: mindful use of in-ns, then
15:33jedmtnman1why does this work
15:33jedmtnman1,(((comp symbol name) "foo")
15:34clojurebot#<ExecutionException java.util.concurrent.ExecutionException: java.lang.RuntimeException: EOF while reading>
15:34jedmtnman1or not
15:34jedmtnman1,((comp symbol name) "foo")
15:34clojurebotfoo
15:34jedmtnman1but this does not
15:34mhanson,(not= true false)
15:34clojurebottrue
15:35mhansonIs that the idiomatic way to do not-equal in Clojure?
15:35jedmtnman1(-> {:name "foo"} :name (comp symbol name))
15:35mhansonOr is (not (= true false) the more common way?
15:35Bronsajedmtnman1: ##(-> {:name "foo"} :name ((comp symbol name)))
15:35lazybot⇒ foo
15:35jedmtnman1Bronsa: ah, hmm. is there a better way to write that
15:36jedmtnman1Bronsa: makes sense now that i see it, but still a little odd, no?
15:37Bronsaseems right to me
15:38TimMcjedmtnman1: ##(-> {:name "foo"} :name name symbol)
15:38lazybot⇒ foo
15:38Bronsayou can do ##(let [f (comp symbol name)] (-> {:name "foo"} :name f))
15:38lazybot⇒ foo
15:38Bronsaor that too.
15:38jedmtnman1TimMc, Bronsa, thanks!
15:38TimMcjedmtnman1: ##((comp symbol name :name) {:name "foo"})
15:38lazybot⇒ foo
15:39Bronsa,'foo ;even better!
15:39clojurebotfoo
15:39TimMcgenius!
15:39Bronsa:D
15:47Chiron_How core.match works? https://github.com/clojure/core.match#about unable even to understand the first example :"\
15:49amalloyabout 500 instances of jedmtnman1's question could have been averted if -> and ->> didn't implicitly convert symbols to lists :P
15:51Chiron_I don't mean under the hood.
15:52Chiron_Oh, it matches match [x y z] for possibilities [t f f] [f f t] [t t t]
15:52Chiron_right?
15:52clojurebotflatten |is| rarely the right answer. What if your "base type" is a list
16:05TimMcclojurebot: You're terrible.
16:05clojurebotNo entiendo
16:06mhansonclojurebot: help
16:06ohpauleezclojurebot: What he's saying is that you're bad at your job
16:06clojurebothttp://www.khanacademy.org/
16:06clojurebotc'est bon!
16:09llasramIs June 18th International Bot Non Sequitur Day or something?
16:10S11001001(inc clojurebot)
16:10lazybot⇒ 10
16:10arrdemwat
16:10arrdem(type clojurebot)
16:11amalloy(+ 3 3)
16:11clojurebot*suffusion of yellow*
16:11mattmoss(println clojurebot)
16:11arrdemooh this'll be good
16:14mhansonWhy are there two bots?
16:14arrdemon topic: any ideas how map can pass two arguments to an fn? I'm (map)ing over a list of strings and I'm getting an arity exception of two args to an fn which takes one.
16:14S11001001arrdem: give map another arg
16:14S11001001and it'll give the fn another arg
16:15_ulisesarrdem: care to paste the offending code?
16:15llasram,(map #(vector %1 %2) (range 5) (range 5 10))
16:15clojurebot([0 5] [1 6] [2 7] [3 8] [4 9])
16:15arrdemgithub.com/rdmckenzie/Doubletake/blob/master/src/doubletake/java/spec/core.clj
16:15raek,(map vector (range 5) (range 5 10))
16:15clojurebot([0 5] [1 6] [2 7] [3 8] [4 9])
16:16arrdemthe offending defn is on line 136
16:16llasramraek: Yeah, I was just explicitly calling out the arguments for pedagogical effect
16:24S11001001woe is this for, arrdem: apply (fn [x] ["alt" x])
16:26arrdemS11001001: it's as close to code generation for the fnparse library as I've been able to come
16:26arrdemS11001001: what this entire file does is do dependency resolution (where possible) and then generate what is almost valid clojure that I can complete by hand
16:27S11001001no, I'm saying that doesn't make sense
16:27S11001001,(doc apply)
16:28clojurebot"([f args] [f x args] [f x y args] [f x y z args] [f a b c d ...]); Applies fn f to the argument list formed by prepending intervening arguments to args."
16:28arrdemderp. so I could just be concat-ing
16:30S11001001also
16:30S11001001,(doc concat)
16:30clojurebot"([] [x] [x y] [x y & zs]); Returns a lazy seq representing the concatenation of the elements in the supplied colls."
16:31S11001001more like mappend interjection than mconcat
16:31arrdemcorrection: (concat ["alt"] (map....))
16:31arrdem,(doc mappend)
16:31clojurebotHuh?
16:31S11001001if you want a lazy seq instead of a vector
16:32S11001001oh, I was speaking haskell
16:32arrdemok.
16:32S11001001probably what you really want is ["alt" (map ...)]
16:32aaelonyWhat's the best way to debug Enlive. For example, what (h/html-content "blah") becomes?
16:32arrdemS11001001: also thanks, that was in fact the bug somehow. (e) was lying to me.
16:34muhooi find it harder and harder to keep different languages straight in my head. i was fixing something yesterday that wasn't clojure, and put the ( before the function name.
16:34S11001001type errors in lazy seqs get delayed until they're needed, so the backtrace has to be treated as a potential candidate list, rather than listing the actual location as the innermost or outermost frame you own
16:34S11001001it is probably allowed :)
16:35arrdemmuhoo: lol. I swear my next project is going to be a REPL which figures out what language I'm typing before trying to eval..
16:35arrdemS11001001: that makes sense. thanks again.
16:36technoma`the commas get me every time
16:38aaelonyaha, render is what i needed!!
16:38jtoyclojure doesn't have the means to parse this? "Mon Jan 31 09:23:21 +0000 2011" clj-time doesn't seem to work
16:39hiredman~google java date parsing
16:39clojurebotFirst, out of 486000 results is:
16:39clojurebotSimpleDateFormat (Java 2 Platform SE v1.4.2)
16:39clojurebothttp://docs.oracle.com/javase/1.4.2/docs/api/java/text/SimpleDateFormat.html
16:39jtoyhiredman: the problem is that I can't get Jan to be parsed
16:40hiredmanjtoy: I believe in you, read the docs
16:40jtoyhaha
16:40jtoythx
16:43jtoyhiredman: the doc is wrong, it says M Month in year Month ;July; Jul; 07 but it doesn't actually work
16:45amalloythe doc is not wrong
16:45amalloyhttp://docs.oracle.com/javase/1.4.2/docs/api/java/text/SimpleDateFormat.html#month
16:54jtoy (import '(java.text SimpleDateFormat)) ; (SimpleDateFormat. "E M d H:m:s Z y");(def parser (SimpleDateFormat. "E M d H:m:s Z y") ); (. parser parse "Mon Jan 31 09:23:21 +0000 2011") => java.text.ParseException: Unparseable date: "Mon Jan 31 09:23:21 +0000 2011" (NO_SOURCE_FILE:0)
16:54jtoywhat am I doing wrong here?
16:54hiredmannot reading the docs
16:56jtoyhiredman: which part?
16:56lypanovZ
16:56lypanovoops no.
16:57lypanovjtoy: the examples section is really weird.
16:57lypanovmaybe you're meant to follow that.
16:58lypanovi don't see how if thats the format you're meant to use this lib can possibly work though.
16:59jtoyhmmmmm...
17:00lypanovlike seriously, how f'n arbitrary is "MMMMM"?
17:00Wild_Catjtoy: (def parser (SimpleDateFormat. "EEE MMM dd HH:mm:ss Z yyyy"))
17:01lypanovi don't see the diff Wild_Cat.
17:01lypanovthe docs say "For parsing, both forms are accepted, independent of the number of pattern letters. "
17:01Wild_Catlypanov: yeah. Looks like the docs are wrong.
17:02lypanovso "not reading the docs" was really "not reading the docs badly"?
17:03Wild_Catwhy is it that no programming language has a sane, working, well-documented date/time parsing lib?
17:03technoma`Wild_Cat: because it's inhumanly difficult
17:03jtoyruby's is pretty sane
17:03lypanovaye.
17:03lypanovrubys rock.
17:03jtoyTime.parse("and it f*cking works")
17:04technoma`last I checked ruby Time objects had to either be in UTC or in local time
17:04Wild_Cattechnoma`: well, at the very least I'd like it to parse the ISO format...
17:04lypanovtechnoma`: not when you use rails.
17:06jtoyso is the answer that java/clojure doesn't have a library to parse that date?
17:06S11001001joda-time
17:06S11001001love it
17:06S11001001add it to all your projects
17:06brehautclj-time
17:07brehaut(which is a thin wrapper around joda)
17:07Wild_Catjtoy: it does. Look at the line I posted.
17:07Wild_Catjtoy: the documentation sucks, but it can be parsed.
17:07jtoyWild_Cat: I tested your line, i couldn't get it to parse
17:08jtoy(def parser (SimpleDateFormat. "EEE MMM dd HH:mm:ss Z yyyy")) ; (. parser parse "Mon Jan 31 09:23:21 +0000 2011")
17:08Wild_Cat,(.parse (java.text.SimpleDateFormat. "EEE MMM dd HH:mm:ss Z yyyy") "Mon Jan 31 09:23:21 +0000 2011")
17:08clojurebot#inst "2011-01-31T09:23:21.000-00:00"
17:08Wild_Catsee? it works!
17:08jtoyhmm, is it because I'm on the mac jam?
17:08jtoyjvm
17:08Wild_Catjtoy: I am on a Mac JVM too.
17:09Wild_Cat(1.6.0_33)
17:09jtoyJava(TM) SE Runtime Environment (build 1.6.0_31-b04-415-11M3635)
17:10RaynesWorks for me on a mac jvm too.
17:10RaynesIn fact, same jvm as you, jtoy
17:10S11001001what is "I couldn't get it to", jtoy?
17:10jtoy(.parse (java.text.SimpleDateFormat. "EEE MMM dd HH:mm:ss Z yyyy") "Mon Jan 31 09:23:21 +0000 2011")
17:10jtoyjava.text.ParseException: Unparseable date: "Mon Jan 31 09:23:21 +0000 2011" (NO_SOURCE_FILE:0)
17:11RaynesPerhaps if you live in a black hole just outside of the milky way...
17:11Wild_Catweird
17:12S11001001locale
17:12Wild_Catah, good point. jtoy: try removing the "Mon"?
17:13jtoyremoving Mon didnt work
17:13lypanovstart minimal and build it up then.
17:13jtoyok, it should work though, ill test on my server instead
17:13jtoyi really hate programming
17:14lypanovwhats your locale look like?
17:14technoma`you can't blame time formats on computers; those are humans' fault 100%
17:14lypanovtechnoma`++
17:14Wild_Catjtoy: if you can though, try supplying dates in YYYY-MM-DDTHH:mm:ssZZZZ format, with nothing language-specific
17:14Wild_Cat(in particular, avoid all non-numeric chars)
17:15lypanov"default locale" whatever the hell that means.
17:15arrdemlypanov: your c_locale?
17:15Wild_Catlypanov: nobody knows what it means >.<
17:16lypanovarrdem: i'd like to hope so but honestly i don't trust java to do the right thing.
17:16arrdem*actually. Java source is UTF8 through and through so... maybe not?
17:16lypanovencoding != locale.
17:17technoma`it's UTF-16
17:17technoma`and even that's just internal
17:17technoma`most macs default to an archaic MacRoman encoding
17:17Wild_Cattechnoma`: no, source file encoding is UTF-8. Internal string encoding is butchered up UTF-16.
17:18lypanovaye. bugs the crap out of me.
17:18Wild_Cat(although I don't remember how butchered up it is exactly0
17:18lypanovi'm sure they have 8bit strings in the jit.
17:18lypanoveven js engines use 8bit strings now.
17:19technoma`JS engines don't have nearly the legacy baggage of the JVM
17:19jtoyit works fine on my server, not sure why not on my mac
17:19jtoyso ill just leave it at that, i still hate programming though
17:19lypanovi love it.
17:19lypanovi just hate people. all of them.
17:19jtoyhaha
17:19technoma`especially people who observe daylight savings
17:19technoma`those are the worst kind of people
17:19mattmossgrrrr
17:20lypanovthat they observe it i don't mind.
17:20jcromartietechnoma`: hey that was my government's decision
17:20lypanovthat they change their f'n mindns… that i do.
17:20technoma`jcromartie: government's authority stems from the consent of the governed.
17:20borkdudethis is a nice website though: http://everytimezone.com/
17:20technoma`rise up!
17:20lypanovRISE UP!
17:20technoma`throw off your shackles
17:20arrdem.... #clojure is inciting revolution now?
17:20lypanovon that topic (completely off topic) anyone watching continuum?
17:21jcromartieooh that is nice
17:21Wild_Catjtoy: my guess is that your Mac isn't using English as its primary UI language.
17:21lypanovditto.
17:21jtoyWild_Cat: yes, its in chinese
17:21technoma`borkdude: .nl is #3 in terms of visitors to http://leiningen.org; you must be doing a great job spreading the word. =)
17:22lypanovjtoy: type Mon right then! :)
17:22Rayneslypanov: Goodness no. I've had enough with timp jumping and stuff with Fringe and Quantum Leap.
17:22borkdudetechnoma` I press f5 all day
17:22Wild_Catjtoy: well, there you have it. SimpleDateFormat will attempt to parse dates using your system's language, and neither "Monday" nor "January" is valid Chinese.
17:22lypanovRaynes: other than the flashbacks there is not much time jumping.
17:22Wild_Cat(which is why I recommended you stick to purely numeric dates)
17:22lypanovRaynes: and fringe is on a whoooole different level. as in, not just 4th dim.
17:23S11001001or always specify which locale you mean
17:23lypanovRaynes: its actually fun.
17:23Wild_Catlypanov: what is Continuum?
17:23technoma`jtoy: also consider developing on a virtual machine that matches your production setup
17:23borkdudetechnoma` kidding, well 27 students used it, but I don't know if that would explain it all ;)
17:23technoma`jtoy: developing on OS X opens you up to all kinds of subtle incompatibilities
17:23lypanovus tv series. i'm enjoying it but i'd like someone to explain wtf is going on with the whole backstory.
17:23jtoyWild_Cat: yeah, those dates come from a 3rd party, but i use numbers internally
17:23aperiodic++ to using a dev VM
17:23lypanovas in, i am supporting the bad guys…
17:23aperiodicsaves so many headaches
17:23lypanovdeath to mac.
17:24jtoyi am going to program with a vm
17:24mattmossdeath to mac (sent from my iMacBookPro)
17:24technoma`been meaning to try out vmfest as a vagrant alternative; anyone know how it stacks up?
17:24lypanovtechnoma`: it rules.
17:25Wild_CatVMs suck up memory. Tons of it.
17:25lypanovchef blows massive sweaty donkey balls.
17:25lypanovbuy more.
17:25jtoyi am planning to use a vm, how do you guys share the folders between OSes though
17:25technoma`oh gosh don't I know it
17:25jtoyvirtualbox
17:25technoma`re chef
17:25RaynesI tried using a VM. If I had a mac that was powerful enough to run OS X, I might consider it again.
17:25borkdudejtoy what machine do you have now?
17:25jtoymacbookair with 4 gb of ram
17:26tbatchellijtoy: with vmfest you can share local folders amongst VMs
17:26borkdudejtoy I used VirtualBox but I switched to Parallels, I'm really happy with it
17:26technoma`vbox isn't the zippiest on I/O, but it has a killer API for automation
17:26borkdudejtoy it's really easy to share folders with it
17:26lypanovi don't share files.
17:26lypanovwhy would you need that?
17:27lypanovRaynes: i'm 99% sure that i'm gonna ditch osx on my iMac anyway. tired of it.
17:27lypanovLion is freaking awful.
17:27jtoylypanov: so i can use a mac editor and test in the vm
17:27lypanovjtoy: ah, i use vim.
17:27lypanovanything less than vim is the suck.
17:27jtoylypanov: me too, macvim
17:27technoma`yeah, shared dirs between the VM and the host feels a bit like an antipattern
17:28lypanovjtoy: from my experience doing it in term is better overall.
17:28lypanovmacvim blows anyway.
17:28borkdudejtoy http://www.mupromo.com/ <- Parallels for real cheap
17:28lypanovvirtualbox.org. vbox for real cheap.
17:28lypanov:P
17:29lypanovjtoy: are you on lion?
17:29jtoyyes
17:29borkdudelypanov I used virtualbox, but being able to keep pressing Cmd-c instead of ctrl-c without configuring anything is really worth the money to me :P
17:29lypanovjtoy: if not then yeah, term.app blows so then iterm2.
17:29lypanovborkdude: 4 win?
17:30jtoyIn short, MacVim is a more feature-rich, more Mac-integrated version, while vim-cocoa follows a simpler, more lightweight and faster approach.
17:30lypanovparallels/vmware are far better for win.
17:30jtoynever heard of it anyway
17:30borkdudelypanov windows vm in osx yes
17:30lypanovbut vbox is fine for linux vm.
17:30lypanovjtoy: yes. you're right.
17:30lypanovscrew more mac integrated though. :P
17:31lypanovbrehaut: unless you actually know vim.
17:31nDufflypanov++
17:31borkdudealso virtualbox only recently made it possible to expand existing virtual disk images, that was really crazy
17:32technoma`huh; I've been doing that for ages
17:32borkdudetechnoma` really? how
17:32technoma`it just expands on-demand
17:32nDuffconvert to raw, dd onto the end, convert back
17:32nDufftechnoma`: only if you made the base size large enough; I presume borkdude is referring to the case where one didn't.
17:33borkdudenDuff right
17:33SrPxAnyone here who logs the chan, could you send me today's log please?
17:33lypanovi use pallet.
17:33nDuffSrPx: it's googlable.
17:33lypanovso when i want it bigger i change the config and rebuild.
17:33technoma`nDuff: sure, but since it expands on demand why would you ever make the base size something other than absurdly huge?
17:33lypanovi can't imagine having to manually maintain a vm image.
17:33lypanovit'd be just as bad as having my mac be my dev env again.
17:34nDufftechnoma`: Not wasting space (and fsck time) on extra inodes and other metadata?
17:34lypanovwhole point is reproducibility and transparency.
17:34borkdudehttp://www.webupd8.org/2011/02/how-to-easily-resize-virtualbox-40-hard.html
17:34borkdudetechnoma` I just wanted to be sure that my VMs don't took up more than X space
17:35borkdudedid not take
17:35nDuff*nod* -- the error conditions when they need to expand but don't have the physical space available are more corruption-inducing than merely being out-of-space
17:35nDuffso that's a valid concern too.
17:35technoma`hm; I guess I've just been lucky
17:36cshell_wdoes anyone know where clojure conj 2012 is going to be held?
17:36SrPxhmm
17:36SrPxnDuff: thanks
17:37borkdudeI also like the fact that Parallels just stuffs the virtual machine definition and disk into one "thing"
17:37borkdudeI can just copy the thing if I want another virtual machine, or make a template out of it, etc
17:37clojurebotmy lisp machine is the jvm
17:37lypanovfor win using vbox is silly.
17:37lypanovbut while i'm on mac and vmware / parallels have no support for e.g. vmfest.
17:37lypanovi don't care for them.
17:38technoma`yeah, automation wins every time
17:38nDuffThere's automation available for VMware
17:38lypanovnot for mac.
17:38nDuffAhh.
17:38borkdudelypanov I don't have that many VMs, so not an issue for me I guess
17:38lypanovtechnoma`: lets put pallet this way, i replaced my entire vagrant/chef infrastructure within days. to upgrade to chef 10.0 would have taken longer.
17:38technoma`hah; nice
17:38lypanovborkdude: somedays i run 8+.
17:39technoma`I have a sneaking suspicion chef's client-server architecture is designed specifically in order to make it so they can sell subscriptions
17:39lypanovits just crap.
17:39lypanovcomplicated crap.
17:39lypanovmy pallet code is completely readable and tiny in comparison.
17:40lypanovcp -ax'ing recipes is not my idea of reusability for the year 2012.
17:40nDuffThere _are_ aspects to Chef that are more complex than some other systems, but those complexities are there to add features that aren't necessarily available elsewhere.
17:40SrPxhmm thanks you guys for the answers you gave some hours ago ( :
17:40lypanovnDuff: pallet can do everything and more.
17:40lypanovchef is lacking huge amounts of things i can do with pallet due to its embeddable nature.
17:40SrPxnDuff: are there languages more productive than clojure ?
17:40nDufflypanov: when I last looked at it, admittedly a bit over a year ago, pallet was not even _remotely_ close to feature-competitive.
17:40lypanovout of the box no.
17:41lypanovbut if you can actually code, chef is a joke.
17:41lypanovand feature checks lists always put the worst at the top.
17:42nDufflypanov: I'd have to actually see a large-scale, complicated environment being maintained with pallet in practice before I could be sold.
17:42technoma`chef is a great example of making things that should be orthogonal tightly coupled
17:42lypanovdepends on what you mean by "see" nDuff
17:42nDufflypanov: ...and to be clear, when I say "in practice", I mean real-world, ie. deploying proprietary "solutions" that don't allow systems to be nuked-and-paved but force incremental maintenance.
17:43lypanovno clue. never worked on a system that was so badly designed that i couldn't ditch half of it at a days notice.
17:43lypanov(i.e., never worked in a large company built on legacy, would never wish to)
17:44lypanovtechnoma`++
17:44nDufflypanov: I very, very much appreciate wanting to stay in a greenfield environment, but _someone_ has to have a toolchain that's up to managing the legacy applications.
17:45lypanovi have to be honest i don't think chef is.
17:45nDufftechnoma`: I'm not sure it's as much so as you may think. The services offered by the Chef server are actually well-defined and limited; it's the client side that's... err... more of a mess.
17:45lypanovpuppet maybe sure.
17:45lypanovbut chef is insanely limited.
17:45nDuff*snerk*.
17:45lypanovanyway i do agree that i don't think its malicious on ill intended on the chef guys part.
17:45nDufflypanov: I was half of the two-man team managing MessageOne's operations -- multiple multi-thousand-machine DCs worldwide -- on Puppet.
17:45lypanovthey are nice guys that want to do a good job.
17:45nDufflypanov: Puppet is utter, utter, UTTER crap.-
17:45lypanovnDuff: i know. but it works.
17:45nDuff...now, mind you, the other half of that team is now at Puppet Labs
17:45lypanovhaha.
17:46nDuff...so maybe we came away with somewhat different impressions...
17:46nDuff...but I moved to Chef for my next gig, and came away far happier.
17:46lypanovyeah chef is far better.
17:46lypanovbut its not the best imo.
17:46lypanovseen the company list for pallet?
17:46lypanovthey have some impressive clients.
17:46technoma`inventing your own language and dependency mechanisms inside an existing language limits the damage you can do vs designing a language from scratch =)
17:47lypanovtechnoma`: yes.
17:47nDuff...but I spent enough time investigating Pallet to at least get a few patches in, and my impression at the time was that it simply didn't have the facilities I needed.
17:47lypanovnDuff: no the base system is small and limited.
17:47lypanovbut i find that my dev speed with it is far better than chef.
17:48aperiodiccshell_w: i seem to recall hearing New York, which is consistent with the image on clojure-conj.org, but don't quote me
17:48lypanovmaybe its just because i actually got into clojure via pallet.
17:49seancorfieldaperiodic: the NYC October 1st thing is SkillsMatter; the conj is in November (and will be in Raleigh/Durham as far as I know?)
17:50aperiodicseancorfield: I assumed so as well, but I seem to recall lynaghk telling me it was in NYC.
17:50aperiodiccshell_w: the real answer is "wait until they announce it"
17:51seancorfieldthat would be more consistent with the image on the web site, true... so i might finally get to go to NYC :)
17:51aperiodicI don't know where lynaghk was getting his info, though. it's probably all hearsay at this point.
17:52lynaghk`aperiodic: dude, I know you live in portland but...look at that cityscape: http://clojure-conj.org/
17:52hugodnDuff: I would be interested in hearing what you were missing from pallet, if you have some time to pass by #pallet
17:52lynaghk`aperiodic: that look like raleigh to you? =P
17:54aperiodiclynaghk`: i can, in fact, recognize NYC, i was just pointing out that nothing's official at this point.
17:55RaynesI didn't see any dead hookers, so I'm unconvinced.
17:55lynaghk`aperiodic: there's also a nyc grid coordinate reader literal in JIRA
17:55cshell_waperiodic: thanks, it did look like NYC but I wasn't sure
17:56cshell_wany idea on dates? I have to be in nyc for thanksgiving
17:56aperiodiclynaghk`: grid coordinate reader literal?
17:56technoma`lynaghk`: sign me up
17:57technoma`wait aren't NYC blocks already labeled by UUID? so you should get that for free.
17:59lynaghk`technoma`: the literal is useful when you want to query .asOf("New Amsterdam")
18:00dmiles_afkhttp://pastebin.com/ysN0PAz3 - here is teh C# syntax and the prolog Syntx.. what "should" the Clojure syntax be?
18:00dmiles_afki suppose this is a Clojure-CLR question
18:45emezeskel
18:46mwillhiteanyone run into this before? Exception in thread "main" java.lang.IllegalArgumentException: No matching method found: setRequestHeaderSize for class org.mortbay.jetty.bio.SocketConnector
18:48bbloommwillhite: much more information needed
18:48mwillhiteha
18:48mwillhitenp
18:50bbloommwillhite: what libraries are you using? what are you trying to do? do you have a stack trace? do you have a reliable repro case? a minimal one?
19:03mwillhiteno worries, I was just tossing it out there, its a complicated app but we got it figured out…it was a ring dependency conflict
19:03mwillhitethanks thos
19:03mwillhite*though
19:05dmiles_afkany anwers to my question?
19:06dmiles_afkhttp://pastebin.com/ysN0PAz3 - here is teh C# syntax and the prolog Syntx.. what "should" the Clojure syntax be? (i suppose this is a Clojure-CLR question)
19:07hiredmandmiles_afk: I guess I don't understand the context
19:09dmiles_afkthis code idiom needs to be used several 100 times.. a codebock that looks like that C#... new ResetEvent+make a lambda + register it + call something + wait fo the evetn to finish + unregister the event + return some value
19:09hiredmanI would be more inclined towards the prolog style if I was writing a generate search/query interface, something more method/fn call like if it wasn't a search, but just a quick lookup
19:10hiredmanif you are only ever expect one answer, and a just getting via the "primary key" then method/fn like, if it is a search with possible multiple results, prolog
19:11dmiles_afkin this cases of these functions yes only one answer is ever needed
19:12dmiles_afkfor the prolog version i hade to create helper functions like cli_new_event_waiter/cli)block_unbtil_event
19:13dmiles_afkok so the clojure-clr version probly will want the same two functions
19:14dmiles_afkoh so that anonomous function .. (cli-block-until-event WaitOn 10000 #'(lambda (Evt) (equals (jcall "QueryID" Evt) QID)))
19:15dmiles_afkwould be like that that?
19:15dmiles_afkminus the CL jcall of course :)
19:16hiredmanannd clojure doesn't have a special form "lambda"
19:16dmiles_afki am very clojure newbie.. but it does have this sort of lambda?
19:16hiredmanit is fn
19:16hiredmanor #()
19:16hiredman#' means something entirely different in clojure
19:16nDuffdmiles_afk: ...though what you look for smells a lot like reify
19:17dmiles_afkso be like? (cli-block-until-event WaitOn 10000 #(fn (Evt) (= (QueryID Evt) QID)))
19:17hiredmanno
19:18hiredman#() is a synonym for (fn [] ())
19:18hiredmanso #(fn ...) is almost never what you want
19:18hiredmanwell
19:18hiredman#(...) is a synonym for (fn [] (...))
19:19dmiles_afk(cli-block-until-event WaitOn 10000 #([Evt] (= (.QueryID Evt) QID)))
19:19hiredmanarglists in clojure are specified using vectors
19:19hiredmannah
19:20hiredmanat this point I will refer you to the number of fine clojure books available on amazon, and the detailed docs on clojure.org
19:20dmiles_afki see though.. you answered my main question
19:21dmiles_afkis that such a code idiom might be fin the prolog way rather than constructing a macro to relfect the C3 structure
19:22dmiles_afkis that such a code idiom might be fine the prolog way rather than constructing a macro to relfect the C# structure
19:23dmiles_afki had worjdered if that code was so comman .. creating a ResetEVent that clojure didnt have already someting in the library for this
19:25dmiles_afksort of the way C# uses "using"
19:27nDuffdmiles_afk: Asking questions in such a way that folks need to know C# to answer them is going to substantially reduce the number of answers you get here; most of us are JVM-based.
19:30devn(or not JVM-based)
19:31devnwhat i mean is: Java is not a pre-requisite per se, nor is any other language. It's best to describe what you're interested in doing.
19:31devn(without resorting to "How do I write this C code in Clojure?")
19:32nDuffdevn: ...well, the questions coming from dmiles seem fairly specific to CLR interop
19:32dmiles_afkjava doesnt have the registration of event handlers.. so a bit awkward portign it to java.. but can be done i think
19:34nDuffdmiles_afk: Are you asking how similar code would be implemented using Clojure idioms on both sides, ie. where the API you're interacting with is natively Clojuresque?
19:34dmiles_afkyes nDuff, good paraphrase
19:35dmiles_afkclojure would end up creating (proxy [s Evt] ...) that would hold some fn
19:35dmiles_afki guess really wonderign if a macro is what a user would want to type to do that code
19:36dmiles_afknderign if a macro is what a user might feel most comforttable when they want to call that code
19:36dmiles_afksorry.. "when they want to impelment that"
19:37dmiles_afkthen when i expand their macro.. what closureqeness should i be doing
19:37frozenlockI'm doing a function of the form (with-something &body). I would like to provide some keywords argument, such as with {:keys [arg1 arg2]}. Is their a way to combine the two? &body and &{:keys}
19:38dmiles_afkwhen a personon interates a list.. they ussualyl get a free hidden iterator out of clojure.. i was hoping i could get a free hidden resetEvent object
19:39dmiles_afkoh in JVM terms a hidding object.wait() object.notify()
19:39dmiles_afkhiddem object.wait() object.notify()
19:50dmiles_afkok.. my question has been answered :) the answer i's i do a wait/notify inside a macro that inserts 4 functions, Setup,testEvent,sendRequest,AfterQuest is recived
21:55brehautis it possible to get lein to only AOT compile when building a jar/uberjar rather than for the repl?
22:02antares_brehaut: rather than the repl?
22:03brehautantares_: i have a project that i uberjar for deployment, the only AOT stuff is to get a main entrypoint. it doesnt need to be AOT'd when teh repl is launched
22:04antares_brehaut: I am afraid main ns will always be AOT compiled, even with a separate profile (lein2)
22:04brehautthats what i thought :(
22:04brehautoh well
22:04antares_brehaut: you can keep the repl open, why restart it all the time?
22:05SrPxis clojure better than cl in general? ;s
22:05SrPxoh what a bad question
22:05SrPxI mean,
22:05brehautantares_: its not a problem for me, its a project with non-clojure people getting started, and explaining the timeout with nrepl as it compiles the entry point is proving to be a real headache
22:05SrPxis clojure kind of updated taking in account cl and schemes mistakes, or something?
22:06antares_brehaut: ah
22:06brehautantares_: my current solution is to get them to run a lein compile first
22:06antares_SrPx: Clojure was designed with some problems in CL in mind, yes
22:06antares_brehaut: yes, that's probably the best solution right now
22:07dnolenSrPx: it's a Lisp with modern affordances yes. CL is not evolving as a language, and there's lots of pressure to keep Scheme very miminal.
22:07SrPxantares_: can ou name some?
22:08SrPxdnolen: are there even newer lisps?
22:08dnolenSrPx: people are creating new lisps all the time - the beauty of Lisp is that's not a herculaen task.
22:08antares_SrPx: I'd name immutable data structures, solid concurrency/time model, syntax that does not use lists for everything (see let forms or defn, for example)
22:09antares_SrPx: Clojure influenced at least 1 Lisp I know of, Joxa
22:09antares_and some non-Lisps, too (like Elixir)
22:09SrPxI want to get into it but I'm not sure how... many implementations, not sure if I even get the need for macros
22:09SrPxantares_: hmm
22:11dnolenSrPx: Lisps generally implements themselves in terms of macros over primitive forms
22:11antares_and there are multimethod implementations in JavaScript and so on, inspired by Clojure (or even directly ported)
22:13SrPxantares_: sorry what?
22:13SrPx(googling that)
22:13antares_SrPx: if you want to get into a new language, just start building something in it. In a few months you will have some initial feeling that is beyond "I like/dislike the syntax". Clojure Programming from O'Reilly is the book I recommend for beginners.
22:13dnolenSrPx: what languages are you familiar with?
22:13antares_SrPx: people port good features from clojure to JS, that's the point
22:13antares_some can be ported
22:13antares_some are relatively unique to lisps
22:14aduantares_: my favorites are (1) rot13 (2) json (3) xml (4) scheme, usually in that order
22:14adualso, webapps in languages prone to that sort of thing
22:15antares_adu: sorry?
22:15adu"things to build in a new language"
22:15antares_ahhh
22:15SrPxdnolen: python c++ lua and javascript , all very similar
22:15antares_yes, json parser and generator is a good start
22:15SrPx(except c++)
22:15antares_but I think to get the real feel you need to build a little service or a Web app
22:16SrPxantares_: i see
22:16aduit's easier to build a webapp if you already have an xml serialization :)
22:17dnolenSrPx: Clojure is pretty different from all of those.
22:17SrPxI know
22:17SrPxlisps are pretty different from anything non - lisp, I guess
22:17dnolenSrPx: so you'll have some fun ahead of you if you stick with it.
22:17antares_I'd say there are similarities between python/Clojure and JS/Clojure, although immutable data structures will be novel
22:18aduhow similar is clojure and racket?
22:19antares_adu: I am barely familiar with racket but it 1) Has mutable data structures, 2) Has no interop with another language, 3) Does not have the same concurrency model. Otherwise lisps are largely similar.
22:19aduracket has immutable pairs...
22:19adu(which is novel for a scheme)
22:19antares_that's my opinion, I am only really familiar with Emacs Lisp and Clojure
22:20SrPximmutable data structures?
22:20antares_adu: yes but by default lists and maps (dictionaries) are mutable, right?
22:20SrPxantares_: I thought you said they removed those
22:20SrPxwhat they are
22:20antares_SrPx: who removed what?
22:20aduantares_: lists are immutable by default in racket (hence novel)
22:21antares_SrPx: if you have a vector of [1 2] and want to ad something, you do not modify the same data structure. Instead, you get back a new vector (but the implementation is not naive copying, so it is pretty time and space efficient)
22:21aduhashmaps (iirc) are mutable
22:21SrPxsomeone said an improvement from cl to clojure was not having those?
22:21antares_adu: aha. Good to know.
22:21SrPxantares_: like haskell?
22:21antares_SrPx: the opposite
22:22antares_yes
22:22aduantares_: racket vectors are mutable tho
22:22SrPxantares_: why is this useful
22:22antares_SrPx: it makes many classes of problems with concurrency completely go away
22:22aduantares_: I've noticed that with Haskell
22:22antares_you never have to worry "does this function modify what I pass to it", like you have in C++ all the time
22:23SrPxantares_: but if this is a default behavior will not it be very hard to implement things that require mutability, like, for example, a game character with position, hp, exp and so on?
22:23antares_which makes for easier testability and maintainability
22:23aduI probably have more experience with Haskell than Scheme
22:24antares_SrPx: it's a typical FP misconception that things "cannot be mutated"
22:24antares_SrPx: they can, but in a different way
22:24SrPxantares_: which way?
22:24antares_SrPx: you can add things to lists, the thing is, you do not modify the original data structure
22:25SrPxantares_: the character hp case?
22:25antares_SrPx: read a Clojure book, it explains things much better than I can on IRC :)
22:25antares_SrPx: hp case?
22:25SrPxantares_: sure, thanks !
22:25SrPxeh..
22:26SrPxlike a character with a HP that can go up or down. normally it would be a hashtable with a hp key
22:26antares_SrPx: there is also a talk by Clojure creator about Clojure's approach to state/mutation/identity, it is not easy to understand the first time but it usually seriously changes perspective for developers, especially those who have worked with concurrency a lot
22:26antares_if you want I can find a link
22:27SrPxnot yet, thank you!
22:27SrPxstill trying to get the basics
22:27dnolen,(update-in {:hp 100} [:hp] #(- % 10))
22:27clojurebot{:hp 90}
22:27antares_SrPx: basically, you can have atomic references in Clojure (one approach) so if you want to mutate something that is a hash map, you do it in a way that looks like you are mutating an existing thing but in reality a new data structure is created and then atomic reference is switched
22:27dnolenSrPx: no mutation occurred ^
22:28antares_SrPx: the key to understanding is that identity ("a list of todos") and state ("current items on the list") are separate in Clojure
22:28antares_in most languages, they are one thing and it means you have a whole group of issues and features to solve them
22:29SrPx,(update-in {:hp 100 :mana 50} [:hp] #(+ % 10))
22:29clojurebot{:mana 50, :hp 110}
22:29SrPx,(update-in {:hp 100 :mana 50} [:hp] #(+ % :mana))
22:29clojurebot#<ClassCastException java.lang.ClassCastException: clojure.lang.Keyword cannot be cast to java.lang.Number>
22:29SrPxheh
22:29antares_ah, I am getting the :hp thing
22:29antares_SrPx: basically, in clojure you'd have an identity (character) and a number of states it goes through
22:29SrPxantares_: hmm
22:29antares_which is how it is in the real/virtual world, right
22:30antares_not the same thing that changes "in place"
22:30antares_in moment A this identity will point to {:hp 100}
22:30antares_after a hit, it wil point to a different state, {:hp 80}
22:30antares_but the original state is not modified.
22:30SrPxantares_: just wondering, wont this be a big punch on performance?
22:31SrPxantares_: I imagine if you have to copy an entire 20-keys hash for each position update which happens serveral times a second for thousand of diferent objects
22:31antares_SrPx: a naive "copy everything" approach would but guess what, Google' Guava works that way and Google seems to find it OK to have in their "standard library"
22:31antares_SrPx: clojure's approach is not naive
22:31antares_data structures are implemented as trees
22:31antares_so there is structural sharing going on
22:31antares_internally
22:32SrPxhmm
22:32antares_so a list A = (1 2 3)
22:32antares_when added a 0 at the head
22:32antares_becomes (0) => (1 2 3) kind of structure
22:32antares_where the "tail" is list A
22:32antares_and the entire thing is list B
22:33antares_there are nice colorful pictures that explain this in various books and blog posts
22:33antares_SrPx: are familiar with git?
22:33antares_*are you
22:33antares_or mercurial
22:33antares_actually, no, mercurial is somewhat different
22:34antares_SrPx: I think you need to watch http://www.infoq.com/presentations/Value-Identity-State-Rich-Hickey, it is a bit heavy on philosophy in the beginning but there are pictures and examples in the 2nd part
22:37xeqibrehaut: you can add :prep-tasks [] to not do javac and compile
22:37brehautxeqi: thanks
22:37xeqibut then you'd have to either `lein compile, jar` or use a profile with them back on
22:37SrPxcalm down o.o
22:38antares_SrPx: ehm?
22:38SrPxwrong window
22:38SrPxantares_: not sure if I'm confortable with this behavior?
22:38SrPxhave to put a little more thuoght on it
22:38SrPxlet me check it
22:41gfredericksSrPx: mutable data structures are the new GOTO
22:41antares_SrPx: Clojure was designed this way by a person with like ~ 20 years of development of complex systems in C++, Java and C#. It is not a nice theory somebody came up at a uni somewhere :) so don't worry, it certainly will take some time to get this but it has plenty of benefits (mostly around concurrency, but not just)
22:42antares_SrPx: I'd say, play with basic data structures in the REPL and then try atoms
22:42antares_atoms are easy to understand and demonstrate identity/state separation
22:42SrPxgfredericks: wow, this is a strong statement
22:42antares_the rest will sink in after that
22:43gfredericksSrPx: the more I use immutables the more I feel that way
22:43SrPxantares_: so on that topic, clojure, when well done, will automatically scale up to additional processor cores?
22:43antares_SrPx: in the world wtih 16 cores being the norm (we are not there yet but it no longer feels surreal), I'd say gfredericks is close to being correct
22:43SrPxantares_: so one can say clojure, haskell and others are soon to outperform C++ and such?
22:44dnolenSrPx: outperform at what? developer happiness?
22:44gfredericksGOTOs are quite performant
22:44SrPxdnolen: too?
22:44SrPxdnolen: but I meant performance
22:44antares_SrPx: Clojure, haskell and several other languages will make it much easier to write radically more peformant systems for multicore machines
22:44SrPxdnolen: just for curiosity actually, because I am searching developer happiness indeed (:
22:44gfredericksbut you could still write 1.5x more performant code with 20x more effort
22:45antares_SrPx: C++ cpmpilers will probably produce faster for a long time but single threaded performance won't matter as much
22:45SrPxI see gfredericks
22:45antares_and it is not really about just crazy performance
22:45antares_it is about maintainable software, too
22:45dnolenSrPx: C++ is very close to the metal, I imagine you can always write faster code in it than Haskell or Clojure or any other FP lang. Just depends on what you'd rather spend your time on.
22:45dnolenSrPx: that said, Haskell & Clojure both take performance very seriously.
22:46lynaghk`gfredericks: I'd never thought about it that way re: goto. The issue with goto is "how the hell did I get here?" and with mutable state, "how the hell did this get this way?"
22:46gfrederickslynaghk`: :D I think it's mostly the chaos of unnecessary powers
22:47antares_SrPx: so, Clojure tries to be "fast enough for the 80% cases, constantly looking for ways to improve on multicore", when it comes to performance. But performance is only part of the story, like I said.
22:47SrPxHmm, okay.
22:47gfrederickslynaghk`: the public-attributes issue from OOP is similar
22:47antares_as for haskell, I am not familiar with it enough to judge but I've heard from people who use haskell for very performance sensitive things and it is surprisingly close to C
22:47lynaghk`gfredericks: unnecessary is a hard thing to pin down. I just spent the last hour putting together slides about why something like Hiccup is nicer than Handlebars because the former uses the same abstractions (i.e., on standard data types) and lets you do whatever you want.
22:48antares_but it takes 1/10 of time to develop the same thing in haskell compared to C (again, just anecdotal evidence of some people I know)
22:48gfrederickslynaghk`: yeah; I suppose it's the sort of thing that takes decades to notice
22:50SrPxantares_: which is probably true
22:51devnif you can get designers to use hiccup, I applaud
22:51lynaghk`gfredericks: heh. I can understand where the no-logic-in-templates folks are coming from, but in practice I've always found it to be more annoying than helpful. Then again, maybe I'm just not working on big enough apps/teams for it to get useful.
22:51lynaghk`In the same way that Ruby folks complain about Java's insane config and factory factories---until they try to build a sufficiently complex app.
22:52lynaghk`devn: most of the time I sit down over beers with designers to work out general markup and structure, then they handle 95% CSS
22:53lynaghk`devn: I'm not sure if that's something super-specific to the kind of work that we do, though (data visualization)
22:53brehautlynaghk`: i think that with referential transparency, all the so called advantages of logicless templates evaporate unless you really want non-technical people to be doing technical work
22:55lynaghk`brehaut: yeah, I think something along the same lines. Referential transparency and immutablity takes away most of the pain of logic-ful templates. My guess is that most of that pain comes from folks who don't have a the distinction in their mind anyway, and start to do crazy stuff in templates just for convenience.
22:56brehautlynaghk`: yup agreed. its hard to put the mutable cat back in the bag
22:56gfredericksI like that (transients aside) all of the intentionally mutable stuff in clojure is a reference to a single value
22:57gfredericksrather than a composite structure of some kind
22:58antares_SrPx: if you have any questions, please ask here, many folks in here would be happy to help
22:58SrPxandrewclegg: indeed you are being very helpful, thank you very much!
22:58SrPxandrewclegg: meant for antares_ sorry
22:58gfredericks(inc andrewclegg) ;; for being helpful
22:58lazybot⇒ 1
22:59lynaghk`gfredericks: what do you mean? Do you think (swap! ref #(update-in ...)) is an anti-pattern?
22:59gfrederickslynaghk`: no; an atom pointing to a map is still a single pointer to an immutable object
23:00gfrederickswhich is much simpler than e.g. an array
23:00gfredericksI think mutable data structures are essentially equivalent to something like (atom {:foo (atom 1) :bar (atom 2)})
23:00gfrederickswhich is of course terrible horrible no good very bad
23:01lynaghk`gfredericks: The only appeal to me about something like that would be more efficent view updates
23:01gfredericksoh that sounds like a fun problem
23:01devnlynaghk`: more ownership over the layout makes for a faster design loop IMO
23:01gfredericksI've been mulling over how to replace backbone with cljs for a while
23:01devna layout does not live forever
23:02lynaghk`Haven't run into a situation where that is absolutely crucial, though. Most apps lately have been using the idea of binding a collection to view items according to a key-fn.
23:02uvtcJust learned about `mapcat` and added an example to http://clojuredocs.org/clojure_core/clojure.core/mapcat that I thought was needed (I don't yet get what the 2nd example there is doing). Please LMK if it's not good.
23:02lynaghk`devn: yep, for sure.
23:09antares_uvtc: the 2nd is where they split strings?
23:09xeqibrehaut: :profiles {:dev {:prep-tasks ~(with-meta [] {:replace true})} will stop javac,compile for most tasks, but allow it for jar/uberjar
23:10brehautxeqi thats great, thanks!
23:10xeqiI forgot you could replace earlier
23:10uvtcThere are 3 examples for mapcat. Mine is the 3rd. Mine consists of three pieces: the part where you see what the `map` is doing, the part where you see a way to get what you want, and the part where you see that mapcat can get you there in style. :)
23:10uvtcantares_, ^^
23:10xeqisupposedly :prep-tasks ^:replace [] should work, but I couldn't get the metadata to stick
23:11antares_uvtc: ah. Then you example is a lot better than the 2nd one.
23:11uvtcGreat. Thanks, antares_.
23:14gfredericks,`C#
23:14clojurebotC__27__auto__
23:15amalloylynaghk`: well, (swap! x #(update-in % ...)) is usually a mistake, but only because it should have been written just as (swap! x update-in ...)
23:17lynaghk`amalloy: noted, thanks!
23:17SrPxwait I still don't get it well, why are macros necessary? functions seems to be everything we need
23:17dnolenit always fun to change an atom from a inside a filter operation *evil laugh*
23:18dnolenSrPx: a lot Clojure the language is defined in terms of macros.
23:18SrPxbut it could be def in term of funcs
23:18amalloySrPx: functions are all you need from a fundamental point of view. macros remove redundant code, and make some things that could technically be done with functions much prettier
23:18SrPxamalloy: an example?
23:18gfrederickspattern matching
23:18gfrederickslogic programming
23:19SrPxcode example, I mean
23:19amalloy(let [x 1] x) could be written as ((fn [x] x) 1)
23:19dnolenSrPx: show me the functions that can provide destructuring *syntax*
23:19kovasbi don't think the likes of deftype/defrecord could be done with functions
23:19amalloylet is (or could be) a macro that lets you write the nicer version on the left instead of the ugly stuff on the right
23:20uvtcSrPx: macros let you create new operators/syntax in the language. For example, you can make your own specialized type of `for` loop using macros. You can see which parts of Clojure are macros by using `doc` --- a line in there should tell you if the thing you're asking about is a macro. For example:
23:20uvtc,(doc for)
23:20clojurebot"([seq-exprs body-expr]); List comprehension. Takes a vector of one or more binding-form/collection-expr pairs, each followed by zero or more modifiers, and yields a lazy sequence of evaluations of expr. Collections are iterated in a nested fashion, rightmost fastest, and nested coll-exprs can refer to bindings created in prior binding-forms. Supported modifiers are: :let [binding-form expr ...], ...
23:20uvtc&(doc for)
23:20lazybot⇒ "Macro ([seq-exprs body-expr]); List comprehension. Takes a vector of one or more binding-form/collection-expr pairs, each followed by zero or more modifiers, and yields a lazy sequence of evaluations of expr. Collections are iterated in a nested fashion, rightm... https://www.refheap.com/paste/3223
23:20SrPxamalloy: wow I actually found the right one surprisingly englightening for other reason
23:20gfredericksSrPx: enlightening != fun to read
23:20uvtcThere --- lazybot says it's indeed a macro, right at the beginning.
23:21dnolen,(let [{hit-points :hp} {:hp 100 :mana 10}] hit-points)
23:21clojurebot100
23:21dnolen,(let [{[f & r] :items} {:hp 100 :mana 10 :items '[sword bread]}] [f r])
23:21clojurebot[sword (bread)]
23:21SrPxgfredericks: didnt say that
23:22gfredericksSrPx: yeah I shouldn't have said it
23:22gfredericksSrPx: macros also give you compile-time optimizations
23:22gfrederickse.g., assert
23:22gfrederickser
23:22antares_SrPx: a good example of a simple but useful macro is if-let
23:22gfredericksthat's more an example of something slightly different I guess
23:23antares_SrPx: books often use "unless" (the opposite of if) but I find it much less useful (never had the need to write unless, but use if-let all the time)
23:23gfredericksantares_: because if-not is shorter :P
23:23gfredericksno it isn't
23:23gfredericksbut it probably uses fewer pixels
23:24antares_gfredericks: no, because if-let captures a common "structural" pattern and unless is a matter of taste
23:24SrPxdnolen: what did you do there with the [f & r] thing
23:24gfredericksantares_: my comment was less stupid back when if-not was shorter
23:24dnolenSrPx: destructured the head and the tail of a sequential data structure '[sword bread]
23:24uvtcgfredericks: hehehe ("Your language is ok, but too fast and loose with it's pixel usage...")
23:25dnolen,(first '[sword bread])
23:25clojurebotsword
23:25dnolen,(rest '[sword bread])
23:25clojurebot(bread)
23:25antares_SrPx: [f & r] destructures a value that is a collection. f gets the first element value, r becomes the "rest".
23:25gfredericksuvtc: dashes are cheaper than underscores
23:25dnolen,(let [[first-thing & rest-of-it] '[sword bread]] [first-thing rest-of-it])
23:25clojurebot[sword (bread)]
23:26SrPx,(let [{[f & r] :items} {:hp 100 :mana 10 :items '[sword bread apple hammer]}] [f r])
23:26clojurebot[sword (bread apple hammer)]
23:26SrPxokay
23:27gfredericks"why does clojure need macros?" kind of turns into "why do languages need features?"
23:27SrPx,(let [{[x & y] :items} {:hp 100 :mana 10 :items '[sword bread apple hammer]}] [x y y])
23:27clojurebot[sword (bread apple hammer) (bread apple hammer)]
23:27dnolenSrPx: that actually expands out into function calls of course - but the sugar avoids the tedium. major selling of point of macros.
23:28dnolenSrPx: most languages you would need to extend the compiler ... ugh.
23:28SrPxI don't get that syntax, how do that stuff end up on x / y
23:28SrPxdnolen: Hmmm...
23:28metellus{[x & y] :items} means you only want :items from the map
23:28SrPxI got that, but how? would that happen without the let?
23:29antares_SrPx: consider a, b = (1, 2) in Python
23:29SrPx({[x] :items} {:items '[a b c]})
23:29SrPx,({[x] :items} {:items '[a b c]})
23:29clojurebot#<CompilerException java.lang.RuntimeException: Unable to resolve symbol: x in this context, compiling:(NO_SOURCE_PATH:0)>
23:29SrPxantares_: continue
23:29antares_SrPx: let is how you assign locals (local vars)
23:29SrPxhmm
23:29antares_SrPx: so, a and b gets their values from positions
23:29dnolenSrPx: anyplace where you can bind names, destructuring works. let, binding, function arguments, loop/recur, etc.
23:30antares_now imagine that everything after (1, 2) would also be tacked on to b
23:30antares_this is how it works in the case of (let [[a b] [1 2 3 4 5]] b)
23:31SrPxoh I see
23:31antares_and this "pattern matching" can be nested
23:31gfredericks,(macroexpand-1 '(let [{[x & y] :items} {:hp 100 :mana 10 :items '[sword bread apple
23:31gfredericks hammer]}] [x y y]))
23:31clojurebot#<ExecutionException java.util.concurrent.ExecutionException: java.lang.RuntimeException: EOF while reading>
23:31gfredericks,(macroexpand-1 '(let [{[x & y] :items} {:hp 100 :mana 10 :items '[sword bread apple hammer]}] [x y y]))
23:31clojurebot(let* [map__220 {:hp 100, :mana 10, :items (quote [sword bread apple hammer])} map__220 (if (clojure.core/seq? map__220) (clojure.core/apply clojure.core/hash-map map__220) map__220) vec__221 ...] [x y y])
23:31SrPxso let's first argument is a array with 2 values, the first one would be the thing to the left, the second one would be the thing to the right, in relation to pythons a,b = 1,2 ?
23:31SrPxwith that tail stuff added
23:31SrPxan array*
23:31metellusit can take any even number of values
23:32metellus,(let [a 1 b 2])
23:32clojurebotnil
23:32metellus,(let [a 1 b 2] (+ a b))
23:32clojurebot3
23:32SrPx,(let [a b] [1 2] a b)
23:32clojurebot#<CompilerException java.lang.RuntimeException: Unable to resolve symbol: b in this context, compiling:(NO_SOURCE_PATH:0)>
23:32gfredericks,(let [x [1 2], a (first x), b (rest x)] [a b])
23:32clojurebot[1 (2)]
23:32SrPx,(let [[a b] [1 2]] a b)
23:32clojurebot2
23:32antares_SrPx: in Python it would look like a, b = [1, 2, 3, 4] and a would be 1, b would be [2, 3, 4] (just as example, I know this is not valid Python)
23:32SrPx,(let [[a b] [1 2]] [a b])
23:32clojurebot[1 2]
23:32SrPx,(let [[a b] [1 2 3 4]] [a b])
23:32clojurebot[1 2]
23:32SrPxwhat!?
23:33metellus,(let [[a & b] [1 2 3 4]] [a b])
23:33clojurebot[1 (2 3 4)]
23:33SrPxoh ok
23:33antares_SrPx: you need & if you want the entire tail
23:33SrPxbut you used a different syntax
23:33SrPx[a 1 b 1] vs [[a b] [1 1]]
23:33metellusthey're different things
23:33antares_SrPx: I was trying too hard to stay close to the Python example :)
23:34SrPxI see
23:34antares_ah, wait
23:34SrPxso either way works
23:34SrPxwhat is the prefered?
23:34antares_SrPx: this example is for collections like vectors or lists
23:34antares_SrPx: you can also destructure maps, this is slightly different
23:34SrPx[var val var val var val...] or [[var var var] [val val val]], is that it?
23:34antares_and then you can combine the two
23:34SrPxõo
23:34antares_no, that's nesting (if I understand you correctly)
23:34gfredericksSrPx: the one you want is preferred
23:35antares_SrPx: imagine that you have a Web form that sends :name and :age
23:35antares_SrPx: and your Web library passes them to you as a map, {:name "joe", :age 30}
23:35antares_but you wnat to pick them into locals and use them separately
23:36antares_like log "saw Joe, 30 years old"
23:36antares_you need separate vars for that, right?
23:36antares_this is what map destructuring does, takes values from a map
23:37antares_,(let [{:keys [name age]} {:name "Joe", :age 30}] name)
23:37clojurebot"Joe"
23:37antares_,(let [{:keys [name age]} {:name "Joe", :age 30}] age)
23:37clojurebot30
23:37antares_,(let [{:keys [name age]} {:name "Joe", :age 30}] (format "Saw %s, %d years old" name age))
23:37clojurebot"Saw Joe, 30 years old"
23:38SrPxõo
23:38antares_SrPx: I wish I could do a multiline example but clojurebot is not advanced enough. It would make more sense
23:38antares_let me gist it
23:38antares_clojurebot: when will you grow up?
23:38clojurebotExcuse me?
23:38SrPx,(let [{:keys [a b]} {:name "Joe", :age 30}] a)
23:38clojurebotnil
23:39SrPx,(let [{:keys [name]} {:name "Joe", :age 30}] name)
23:39clojurebot"Joe"
23:39SrPx,(let [{:fff [name]} {:name "Joe", :age 30}] name)
23:39clojurebot#<ExecutionException java.util.concurrent.ExecutionException: java.lang.RuntimeException: java.lang.Exception: Unsupported binding form: :fff>
23:39SrPxbinding form, interesting
23:39SrPxis not there a less redundant way to write that single example?
23:40antares_SrPx: https://gist.github.com/82d0c67a18fd624207f1
23:40SrPx(let-keys {:name "Joe", :age 30} name)
23:40SrPxor something
23:40antares_SrPx: you can write a macro that would do that, in Clojure itself :)
23:40metellusSrPx: two different things are happening here
23:41antares_but I think most of the time going that far is not worth it
23:41antares_SrPx: in my gist above I destructure right what is passed in the function
23:41metellusor really, the reason that looks awkward is because this is a contrived single line example
23:41antares_without using let
23:41SrPxwait
23:41antares_what metellus said
23:42SrPxyou are using that in the place of function(what_would_be_here) { }
23:42antares_we have to use let and fit everything into one line
23:42SrPxI think I get it now
23:42antares_SrPx: yes, I destructure right on the parameters
23:42antares_SrPx: in, say, Python, I would do "give me name from kwargs, then give me age"
23:43antares_here you have them in the params definition, sort of
23:43SrPxhold on, { } is a dict and [ ] is an array right
23:43antares_yes
23:43SrPxthis is not usual for lisps is it
23:43antares_SrPx: correct, CL and Scheme use lists for everything
23:43antares_but that's why let in emacs lisp is pretty noisy
23:43antares_Clojure by design uses vectors for let, defn and in some other places
23:44antares_[ and ] stand out visually
23:44antares_so this is intentional
23:45uvtcSrPx: in Clojure, `[]` produces a vector. The term "array" is generally used for referring to Java arrays (which you shouldn't encounter while learning Clojure).
23:45antares_SrPx: for comparison: https://gist.github.com/4af7b60fcc19aefc2493
23:46SrPxantares_: this is good... any other syntax sugars?
23:47uvtcSrPx: there's a handful of them. #{:a :b :c} is for creating a set. #"foo" is for creating a regex.
23:47antares_SrPx: in more sophisticated forms like cond, condp you will find similar simplifications
23:48antares_yes, sets and regular expressions in the syntax is a good example of what many lisps do not have
23:48SrPxcan I somehow use macros to turn it into an array language?
23:49antares_SrPx: what is an array language?
23:49brehautsomething like APL or J i think
23:49SrPxit is a language where arrays can be treated like instances
23:49michaelr`good morning
23:49tvladeckhi, does anyone here use vimclojure?
23:49antares_SrPx: there are macros in math/stats packages like Incanter that make it possible to write things similar to (1 + 2 + 3) instead of (+ 1 2 3)
23:50brehaut~anyone
23:50SrPx((+ 1) [1 2 3 4]) would translate into [2 3 4 5] or something like that
23:50clojurebotJust a heads up, you're more likely to get some help if you ask the question you really want the answer to, instead of "does anyone ..."
23:50tvladecksure
23:50SrPx(+ 1) being partial application
23:50clojurebot1
23:50tvladecki can't get vim to connect to a running nailgun server
23:50antares_SrPx: partial application is done a bit differently but yes, you can even do things like that
23:50dnolenSrPx: people were asking that question in 1979 http://dl.acm.org/citation.cfm?id=804474
23:50SrPxbrehaut: how would he ask ? o.o
23:50tvladecki keep getting the error: 10 Reason:
23:50tvladeck 11 Vim(let):E484: Can't open file /var/folders/4r/6ndrr64x24n9kfxh7xcfmt_r0000gn/T/vPI9Uyw/1
23:51antares_SrPx: I would not say it is always a good idea, but Clojure will give you that much freedom in case you need it
23:51brehautSrPx: he would ask his question directly, eg 'I'm using vimclojure and i [want to do X|cant get Y to work]'
23:51SrPxI need to see this article
23:51arubinIs there any particular reason why maps are functions but records are not?
23:51SrPxdamn
23:52SrPxbrehaut: ok
23:52tvladeckapologies; new to clojure and programming in particular. i am trying to use vimclojure and cannot for the life of me get a repl started in vim
23:53brehauttvladeck: no offense. its just a channel etiqutte thing
23:53tvladeckbrehaut: for sure. no worries
23:54antares_arubin: there is but I cannot find the link and recall it myself
23:54antares_arubin: basically, this is by design
23:55brehauttvladeck: now hopefully someone who uses vimclojure will be around and can help you. there are people who use it who frequent the channel
23:55tvladeckbrehaut: awesome. going to spend that time doing the emacs tutorial :)
23:55brehautgood plan :)
23:55emezesketvladeck: are you using lein-tarsier?
23:55tvladecki am
23:56SrPxdnolen: how did you find that paper so fast and how can I read it
23:56emezesketvladeck: how did you go about installing the vimclojure plugin?
23:57tvladeckpathogen
23:57brehautSrPx: dnolan is actually citeseer; the number of scheme and haskell papers cited gained critical mass, and the result was an intelegent entity that inhabits the channel and produces clojure libraries
23:58emezesketvladeck: I don't know what all this /var/folders/4r/... business is
23:58tvladeckemezeske: me neither!
23:58xeqiand builds clojurescript
23:58uvtctvladeck, if you're new, you might just consider having vim open in one window, and the `lein repl` running in another. You can make changes to your src/core.clj file, then in the repl reload those changes by doing `(require 'foo.core :reload)`.
23:59brehautxeqi: its the only scenario that makes any sense
23:59dnolenbrehaut: haha
23:59tvladeckuvtc: that's how i have been doing things, and it's actually quite productive
23:59uvtctvladeck, (that is, assuming for that example that your project is named "foo")
23:59tvladecklein repl (namespace) is pretty good
23:59uvtctvladeck, me too (though I'm using Emacs)
23:59dnolenSrPx: Lisp is 50 years old. Nearly any CS idea anyone has ever had has probably appeared in a Lisp paper in some form or another.