#clojure logs

2012-10-31

00:01flying_rhinohello guys
00:07flying_rhinodoes clojure have hygienic macros?
00:09tmciverflying_rhino: I don't have much experience with macros, but I believe the answer is yes, as long as you use gensym.
00:10flying_rhinotmciver: thanks
00:10flying_rhinocan s-expressions be used as replacement for xml in clojure?
00:11tmciverflying_rhino: how do you mean? As in replacement for configuration files?
00:11nightfly_For serialization?
00:11flying_rhinoboth
00:12flying_rhinoboth as a replacement for configuration files and selilization.
00:12tmciverI think the answer is yes to both. For example, lein uses a clj file for config, and you can prn a sexp in a form that can later be read in by the reader.
00:13flying_rhinothanks
00:15amalloyit's not a super-valuable question to have answered about clojure, though. you can use sexps for those things in java too, or any other language, but nobody does. it's entirely a cultural question, not one of "can clojure X"
00:16tmciveramalloy: well, nobody does because it would be a PITA; but it's easy in clojure.
00:16flying_rhinoyeah, you can write s-expression parser in any language true. But it is better when language itself supports it
00:16flying_rhinoXML is verbose as hell and major PITA, imho.
00:17flying_rhinoalso the fact that lang itself supports it means it is standardized.
00:18flying_rhinosince I think there are several slightly different versions of s-expressions, if I am not mistaken. (I don't think scheme and CL ase same)
00:18flying_rhinoanyway thanks
00:23technomancyclojure doesn't have hygenic macros
00:23technomancythe problems hygenic macros are designed to solve aren't present in clojure
00:24flying_rhinotechnomancy: can you elaborate please?
00:25Iceland_jackHygenic macros were created to avoid capturing variables
00:25Iceland_jackclojure's namespace prevents that
00:27technomancyspecifically building forms using backquote makes accidental symbol capture nearly impossible since backquote adds namespaces to every symbol
00:30amalloymy understanding is that racket's hygenic macros make it actually-impossible; anyone know if i'm wrong about that?
00:31amalloyjust as a matter of tangential interest
00:31technomancyyeah, s/racket/scheme/
01:26flying_rhinoHow fast is Clojure compared to Java?
01:27flying_rhinobenchmarks from a few years ago where quite disheartening.
01:29mjcwas the meeting practically intolerable, or actually intolerable ?
01:29Iceland_jackAre you playing the speed game or is Clojure too slow for some application you had in mind flying_rhino?
01:29Iceland_jackChoosing a programming language always has a trade-off
01:30mjcyeah, if you're deploying production benchmarks, there may be serious problems
01:30flying_rhinosince I am contemplating to create aplication that may (or may not) require a lot of speed, it is important to know if clojure might handle it.
01:31flying_rhinoI would hate to be stuck with bad performace if I commit to clojure
01:31flying_rhinocan you consistently get like 80% of Java?
01:31_tcawell then maybe you should at some point figure out what your application will do so you can figure out the requirements
01:33flying_rhinoI have it figured out mostly, but I can't tell you exactly. I do know that less than 50% of Java is unaceptable.
01:34Iceland_jackxx% of performance in language X from language Y is pretty vague, certain features of Clojure are going to differ more than others
01:34Iceland_jackIf you want to be sure you should maybe consider Java
01:36scottjflying_rhino: in micro benchmarks there's a pretty big performance penalty for writing idiomatic clojure. normally you can write unidiomatic clojure and get close to java, maybe 80%, maybe 100%, it depends.
01:36Iceland_jackAlso microbenchmarks don't tell the entire story
01:36flying_rhinothanks scottj
01:38flying_rhinowhat's penalty if some variables in your code need to be changed often? IE it you use immutability at places where muttability can makes more sense?
01:38flying_rhino*mutability makes more sense
01:41flying_rhinofor example, the project I have in mind is RTS-like game. Like in AoE, it has every turn last 0.25 seconds. That means generating new state every 0.25 sec. Does it make sense to make something like that in Clojure?
01:42shachafWhy not?
01:42flying_rhinobecause I am making new state often, instead of changing existing one.
01:43flying_rhinowhich may not be very smart thing to do
01:44_tca.25s is an eternity
01:45flying_rhinoalso it has to update hella lot critter data.
01:47flying_rhinoalthought I can see benefits of immutability there, too.
01:47flying_rhinohow quickly can GC discard data from previous turn?
01:49flying_rhino(stuff like that worries me a lot)
01:51_tcait obviously depends on how much garbage you generate, but from what your game sounds like you will never even notice it
01:53flying_rhinothere will be like thousand critters bumbling around creating new state every 0.25 sec. And there are some unique things (like some creatures leaving trail) so there might be lots of garbage.
01:53flying_rhinowell couple hundred, at least
01:53_tcathats very little garbage
01:54mroweyou should see the average spring web app! ;-)
01:55_tcaflying_rhino: gc is overall faster and only an issue for games like an FPS where you might get deaths from a 5ms gc pause
01:56Iceland_jackBut FPS aren't normally written in GC languages anyhow
01:56_tcaand trust me you aren't making as much garbage as you think
01:57flying_rhinosome guy created turn based game in clojure. He said that he would never use functional language for real time game. Now, mine game is RTS not FPS and it is turn based that fakes real time (like Age of Empires) so it is differentbut I am worried.
01:57flying_rhino*different, but
01:58flying_rhino_tca: I hope you are right
01:59flying_rhino_tca: thanks
01:59mjcthat's who I always like to take important decision making advice from.. "some guy"
02:00flying_rhinomjc: the fact that he created a game nakes his judgment at least worth something.
02:00flying_rhino*makes
02:02flying_rhinoanother consideration is that I want some critters to leave trail, which will generate a lot of data real fast. Again I probably worry too much. I will create some benchmarks myself to see what makes sense and what doesn't. Thanks.
02:06flying_rhinothere is a lot to take into consideration. How would functional A* look like?
02:09flying_rhinoserious has anyone ever made functional A*?
02:11dhklflying_rhino: You can find a discussion of functional A* in "Joy of Clojure"
02:11flying_rhinodhkl: thanks
02:15flying_rhinofrankly I would have felt much better if clojure had at least optional mutalibity. I know immutable is often better and I know that Clojure is sophisticated as hell but I am uneasy. It is like flying super advanced plane with no ejection seats, and everyone insisting that you don't really need those.
02:29dhklflying_rhino, wouldn't an aggresive use of atom in place of other reference types give you more or less the kind of mutability you're looking for?
02:30flying_rhinonot sure
02:33mrowepossibly dump question.. I have a function that takes arguments: [thing & other-things], but it doesn't like being passed a seq as the 2nd argument. do I need to somehow "expand" the seq before passing it?
02:34scottjmrowe: (apply your-function thing other-things)
02:35mrowescottj: awesome, thanks :)
02:36mroweI knew it would be obvious once someone told me ;)
02:36scottjmrowe: other options are (defn a ([thing] ...) ([thing other-things] ...)) or (defn a [thing & [other-things]] ...)
03:26sunkencityrylehI have a protocol that I have a special function for PersistentList in, but I'd like to define my own subclass of PersistentList instead, just to be sure that nothing accidentally triggers this function. How do I go about that in clojure? Do I just deftype and then create a list from that in the protocol, or can i subclass?
04:39kralnamaste
04:58ejacksonwhispers of EuroClojure 2013 !
05:05andrewmcveigh|woejackson: any whispers of where?
05:05ejacksoni see Germans speaking of it...
05:06andrewmcveigh|wointeresting...
05:06_uliseswe have direct flights to Frankfurt you see
05:08ejacksonhehehe
05:08ejacksonwho'd a suspect you'd need that in England ?
05:10andrewmcveigh|woindeed. Next time I'm packing shorts, even if it is London in May.
05:12ejackson:)
05:13tomojI wonder if it would be possible to have the repl's namespace state separate from the namespace state with which load-file happens
05:15borkdudeIs it possible to say: require/use this namespace x from namespace y?
05:15borkdudeinstead of from the current namespace
05:17tomoj(binding [*ns* (find-ns 'user)] (require '[incanter.core :as incanter]))
05:17tomojseems to work
05:17borkdudeok tnx
05:17tomojbut.. doesn't seem like a very good idea generally
05:18borkdudetomoj there was someone who wanted to include a set of standard helper namespaces in every one of his namespaces and wanted to write a function for it
05:18borkdudetomoj it didn't seem like an idiomatic approach to me, but just wondered what is the cleanest way to get it done
05:19tomojI guess it's not that bad if the person reading the code has M-.
05:19tomojfor anyone reading the code on github, that sucks
05:19tomojor reading the code without a jvm
05:20ejacksonyeah
06:35alexnixontset
07:12rodnaphhey, i'm trying to use aleph to create a simple websocket server, which works for a short time but then messages stop coming through the channel - do i need to do something to keep it open? https://github.com/rodnaph/lewis/blob/stats/src/lewis/ws.clj
07:15clgvrodnaph: I didnt use aleph yet - but maybe an exception happened on client or server which faulted the channel?
07:16rodnaphthat's possible. i'm using wrap-reload too, could be causing probs? maybe defonce the channel? is there a way i can check if a channel is "working" ?
07:31clgvrodnaph: you could wrap code that is using the channel or called in a thread of the channel (if there is something with aleph) in a try-catch-block and then print every exception to debug your problem
07:38sunkencityrylehis there some tool that can be used with clojure to get a list of possible exceptions that can come up when calling a function?
07:52clgvsunkencityryleh: no
07:52clgvsunkencityryleh: or do you mean for interop with java?
07:53mklappstuhlclgv: he is gone
07:53clgvmklappstuhl: damn, i have those notifications invisible for less spam ;)
08:23rodnaphclgv: thanks for the advice i'll try it.
08:28MasseRI have a situation where I need to override a side-effectful (streaming) java class method. I want the data from that method concatenated and converted into a clojure sequence. For example: foo.processStream(page1), foo.processStream(page2) etcc. processStream calls at some point some other method which should be overriden. How should I approach this? I tried proxying and it's trivial to override the method (and test the original api) but getting the ...
08:28MasseR... data out of it escapes me
08:33luxbockany idea why find-doc doesn't work in the nREPL of Emacs?
08:34luxbockworks fine when I use REPL normally
08:35MasseRWith java I would probably create a new member variable (List<Map>) which I would fill from the overridden method
08:36MasseROne way would be to set! the list but..
08:46clgvMasseR: can you make a gist where you describe your problem with examples? "getting data out" is not very specific ;)
08:47_ulises+1
08:52MasseRclgv: https://gist.github.com/3986869
08:52MasseRis that enough information?
08:52clgvwe'll see ;)
08:52mailheadersWhat is it conscerning?
08:53MasseRmailheaders: The best way to 'get data out of evented java api'
08:53clgvMasseR: so looks like you need a gen-class in that interop scenario. you can have a state variable in gen-class
08:54clgvMasseR: But the questions is whether it is worth to use clojure for that class. you might be faster with plain java just for that class
08:55mailheadersNo that is not the question.
08:56mailheadersThe question is at what level is energy being allocated.
08:57clgvtrolling? :P
08:57MasseRclgv: Shouldn't I then need to 1. gather the data as for example List<Map> and then convert that list into '({})
08:57MasseRs/1.//
08:57clgvMasseR: seq can convert java.util.List ^^
08:58mailheadersI am trying to tell you they have attacked the human mind.
08:59clgv&(let [l (java.util.List.)] (doseq [e (range 10)] (.add l e)) (map inc l))
08:59lazybotjava.lang.IllegalArgumentException: No matching ctor found for interface java.util.List
08:59clgv&(let [l (java.util.LinkedList.)] (doseq [e (range 10)] (.add l e)) (map inc l))
08:59lazybot⇒ (1 2 3 4 5 6 7 8 9 10)
08:59clgvMasseR: so you actually dont need to convert it - as you can see above
09:00mailheadersThe question is what is the nature of the human mind.
09:01mailheaders8 Chapters
09:01MasseRclgv: Thanks
09:02mailheadersObama is an object code in a psychoanalist system.
09:02mailheadersFreenode "caught a case".
09:03mailheadersDo you understand what is meant by catching a case.
09:03mailheadersIdentify the threat contaigen -> quarenteen -> triage -> treatment
09:04mailheadersYou failed the turing test.
09:05mailheadersAt what point do you stop and ask a question.
09:05mailheadersAt what point should a human mind interact?
09:05mailheadersYou arent doing it.
09:06mailheadersCase and point.
09:06mailheaderscontaigen identified
09:07CubicDid I miss something?
09:08mailheadersI asked a question, and everyone responds with retard comments as usual.
09:08mailheadersBuzzword morons.
09:08mailheadersNever allowing the conversation to develop.
09:09mailheadersTry this again.
09:09mailheadersDo you understand what is meant by catching a case?
09:10mailheadersLets see if theres even a spark of intelligence in this channel.
09:13mailheadersIf oboma is re-elected he is willing to take it all the way to WW III
09:13mailheadersDo you understand the implications here?
09:13clgvmailheaders: can you please stop spamming with off-topic nonsense?
09:14mailheadersWhat is with peoples obsession with topic on this network?
09:16mailheadersJason Ross says artificial intelligence will not understand metaphor.
09:17mailheadersNow does darrpa's analysis of defence papers even come close.
09:17mklappstuhlmailheaders: what is your point? This channel is about a specific programming language. If you want to talk about politics you are probably at a better place somewhere else
09:19mklappstuhlclgv: There is also /mute I think
09:20clgvmklappstuhl: I am not that fluent speaking in IRC ;)
09:22mailheadersSong of Soloman is the true turing test.
09:22mklappstuhlclgv: Actually it's english with a slash in the beginning :)
09:22mklappstuhl:D
09:22mailheadersnot yip yapping about java like a barking poodle
09:23clgvyeah but it doesnt do everything with a prefixed slash ;)
09:23mailheadersclgv: so don't tell me I don't pass the turing test
09:23mailheadersI don't see you robots cleaning my house.
09:24mailheadersThis is what I am talking about misallocation of energy.
09:24mailheadersThat is the question.
09:26samratcould someone help me with this, please: http://www.reddit.com/r/Clojure/comments/12easa/transforming_some_data_contained_in_a_hashmap/
09:27mailheadersCan an A.I understand a metaphor of something that cannot be externally observed?
09:27mailheadersNO
09:27mailheadersMake it easy for you.
09:27mailheadersThe answer is NO.
09:28CubicMute doesn't seem to work.
09:28mailheadersimmutable object
09:29mailheaderstwo eternal constants
09:29ToBeReplacedsamrat: your solution looks okay to me
09:30mklappstuhlCubic: hm, right. It'S only possible for admins
09:30ToBeReplacedi'd try to avoid what you're trying to do... trying to do relational things over maps is a pain
09:31mailheadersyou are not an admin you are just a drone
09:31TimMcmklappstuhl: /ignore mailheaders is what you want
09:31TimMc/ignore -replies mailheaders is even more effective.
09:32clgvsamrat: you could refactor the data model to have explicit rating maps {:movie "batman" :rating 4.5 :user "Toby"} then it would be an easy (group-by :movie prefs)
09:32CubicI don't think that works either.
09:32mailheadersyes drones have the option of sticking their head in the sand like a frieghtened ostrich
09:32TimMcOh, you're using the web client... maybe it doesn't have ignore.
09:32mklappstuhlclgv: Looks like I'm not fluent in IRC either :P
09:33mklappstuhlTimMc: I'm using weechat and it doesnt work
09:34mailheaderssee what i mean about misallocation of energy
09:34mailheadersso here you are 10 lines latter chatting about how to ignore chatters, chatter chatter chatter
09:36mailheaderslearn to use your brain if you have one before learning to use a fancy calculator
09:37TimMcHmm. I guess I shouldn't expect that command to be the same for all clients.
09:37CubicTimMc: I think we'll have to fall back to lo-fi ignore then.
09:38mailheaderscracking the mind
09:38chronnoFWI, "/ignore mailheaders ALL" worked for me
09:38mailheadersdo you like crackers?
09:38mklappstuhlTimMc: I actually thought that the commands are just relayed to the actual irc server
09:40mailheadersmklappstuhl: do a tracerout on the server you are connected to
09:40mpanI have some data which could be directly encoded as literal maps/vectors/etc. Is there a recommended way to store them to have them accessible from a program?
09:40mpanIt would work to just make them part of the source, but I'm unsure if that's a good idea.
09:42mpanAre there any particular advantages to having a separate file to read and eval vs just having it as a file in the source?
09:42mailheadersyou guys code anything useful for intelligence gathering?
09:42clgvmpan: well then store that data as clojure code in your resources directory (for example)
09:42mailheadersi can do beta testing, if you will obey my QA reccomendations
09:42mpanI guess what confuses me is I can't draw the distinction between being part of the core of the code vs being data that happens to be code vs... oh hey wait I think I know where this is going
09:43mpanThis is intentional, isn't it?
09:43clgvmpan: lisp: code is data, data is code ;)
09:43mpanIt hadn't quite sunk in so fully before
09:44clgvone example for configuration data is leiningen's project.clj
09:44mpanIs read-file'd and eval'd?
09:44clgvyou could take inspiration from it in case it fits your use case
09:44mpanI'm not completely sure about my use-case, but it's a school deadline, and decent is better than unfinished
09:45mpanThat's for sure
09:45mpanAlso, what if my file needs to contain multiple "values"?
09:46mpanNot sure if that's the term I should be using
09:46clgvthats more tricky then.
09:46mpanbut, say, multiple top-level s-exprs
09:46CubicHm, would that mean that saving i.e. levels in a game as clojure source code would actually be idiomatic?
09:46mpanCubic, sounds like it, interestingly enough
09:46ToBeReplacedmpan: there's lots of advantages to having your data stored in other formats, but if using a wide brush, you should avoid that until there's a clear need.
09:46TimMcmklappstuhl: Some are local, some are sent to the server.
09:46clgvCubic: why not? you would probably build a highlevel language for it
09:47mailheaderstalk it up
09:47mailheadersjust dont put the wide brush under your nose
09:47mpanUh, so what I need is a few rather large vectors of maps of domain-specific-stuff accessible from the program
09:47clgvCubic: something like: (level 1 (wall [10 20] [10 50]) (monster :ork [12 12]) ...)
09:48mklappstuhlmpan: what school are you on that you are using clojure?
09:48mailheadersyes everyone can make a graven image for themselves
09:48mpanThis assignment doesn't specify a language requirement, thankfully
09:48ToBeReplacedmpan: ex. storing your multiple values in json meets your need, but so would def's in a clojure source file... when you read in the data can vary accordingly
09:48mailheadersthats what choice is all about
09:48CubicI've been thinking if there was any point in adding scripting to a clojure program, but I couldn't think of anything. The way I understand it, you can just embed an nREPL server and use that for "scripting".
09:48mailheaderseternal life and eternal death
09:49TimMcmpan: There's a difference between read and eval. If you're just storing vectors of numbers and strings and such, you only need read, not eval.
09:49mailheadersthe leader of this network runs a company called death works
09:49mpanThe insides may be oddly arbitrary beyond just literals
09:49TimMcso you can (read-string (slurp "data.clj"))
09:50mpanbut that part is, I imagine, domain-specific concerns
09:50mailheaderswhat you can do is make your graven image on a 3d printer just join #reprap
09:51mpanBut is it the case that if I want to use read-string, I want to put this "data" file somewhere outside the usual search path for ns-loading?
09:52mailheadersgo out and eat texturized soy protien with artificial flavors and let the micro fungus pass the blood brain barrier
09:52clgvTimMc: mpan: (read-file "data.clj") even.
09:52mpanbut data.clj isn't something that the compiler would normally load except that we specifically tell it to?
09:52mailheadersthen come home and type bullship into your fancy calculator
09:53mailheadersand while the fungus eats your brain don't worry wolfram alpha will micromanage your "friends" for you with the new facebook app
09:54mpanWell, this is really cool
09:54mpanThank you guys, and I think I know what to implement now
09:55mailheadersand prostitute robots will come to your house to harvest your reproductive organs for the fetus growing lab
09:55mklappstuhlI'm comparing the java and clojure libs for riak right now and the java stuff just makes me wanna cry while the clojure stuff is so beautiful
09:56clgvmklappstuhl: sometimes even tough guys need to cry ;)
09:56CubicSo, read-string creates a form from a string, and eval then evaluates it?
09:57mklappstuhlThe company I'm working for is using Java for mostly everything and until now I havn't been able to convince them to give clojure a shot :/
09:58clgv&(eval (read-string "(println \"Cubic: yes\")"))
09:58lazybotjava.lang.SecurityException: You tripped the alarm! eval is bad!
09:58clgvah right, sandbox^^
09:58mpanwhy can't they just enforce eval recursively?
09:58mpanoh wait, that sounds scary
09:59clgvmpan: there is also load-file load-string etc...
09:59mailheadersthey are not the enforcers
10:00mpanI was originally wondering about substituting a "fake" read-string etc which did the usual checks
10:00mpanbut that sounds harder the more I wonder about it
10:00mpanas in, the same enforcement as stuff at the top-level
10:00clgvmpan: I have a dsl which now even uses namespaces for organization
10:01mpanclgv: does that mean you have ns swapping in the middle of things?
10:01mpanmklappstuhl: there's a certain "LISP is lunatic fringe" attitude that needs to be fixed first, unfortunately
10:01clgvmpan: huh? I don't know what you mean by that. I meant that I use regular namespaces for the DSL documents as I do in the code of the lib
10:02mpanI'm only used to use-cases where you specify a ns at the beginning of a file and stick with it
10:02mpancircumventing that would come with its own complications?
10:03clgvyeah the documents have the namespace at the beginning
10:04mpanI was worried about "the ns you are in at the time you load them" but that seems to be an artificial line anyway
10:04mpannot sure what to call that
10:06clgvmpan: well, leiningen creates a temporary namespace and loads the project.clj in there if I remember correctly.
10:08mpanif I just load something, it ends up in the current ns? (for cases where such a distinction exists)
10:08S11001001mpan: yes
10:08mpanI suspect my current use-case doesn't encounter that distinction, though
10:09mpanI'll probably just wrap the many maps in a larger enclosing map
10:09mpanThanks you all!
10:09AWizzArdWhy is a -main method not public? I noticed that in my test namespaces I can’t call (-main …).
10:10S11001001AWizzArd: it's not a method, just an ordinary function, and has as much privacy as you give it
10:10S11001001AWizzArd: in other words, gen-class doesn't change the behavior of def or defn
10:13AWizzArdS11001001: I did a defn on -main, not a defn-. So I expected it to be publicly available from other NSes.
10:13AWizzArdSo far I solved this by calling (#'-main …). But still very strange, no?
10:13S11001001sure
10:16AWizzArdS11001001: btw, do you use Emacs + Leiningen + nrepl?
10:16S11001001AWizzArd: yes
10:16AWizzArdDid you use Slime before?
10:17S11001001yes
10:17AWizzArdI noticed that several useful key combinations are gone. For example, „C-c C-c”, to compile the expression under the cursor.
10:18AWizzArd„C-c M-p” is gone too. Is that cause the Emacs support is still young? Or do you know of any good reasons why all those nice key combinations really should be different?
10:18TimMcAWizzArd: Wait, so in your test ns you have (:use foo.core) and then (-main ...) doesn't work?
10:18clgvAWizzArd: (defn -main [] ...) leads to a public function "-main" that is public and usable from other namespaces.
10:18CubicC-c C-e does almost the same thing, except cursor has to be at the end of the expression
10:19clgvAWizzArd: I have called -main often from REPL for testing purposes
10:19AWizzArdTimMc: yes, I :use my main NS, but calling (-main …) doesn’t work.
10:20CubicAnd I believe C-M-x is exactly the same thing as C-c C-c in slime.
10:20TimMcAWizzArd: What Clojure version?
10:20AWizzArdTimMc: 1.4
10:20AWizzArdCubic: it is good that there is some equivalent. But why a new key combination?
10:20S11001001AWizzArd: that nrepl isn't a complete port
10:21duck1123AWizzArd: are you sure you're using slime and not nrepl?
10:21AWizzArdI guess 99% of all nrepl-Mode users were slime users before, and already learned several key combinations.
10:21AWizzArdduck1123: yes. That -main thing is in slim.
10:21AWizzArd+e
10:21CubicAWizzArd: I don't know, I guess they didn't really go for SLIME compatibility. Ask the author of nrepl.el. You can change those bindings if you feel like it.
10:22TimMcAWizzArd: Could not reproduce. Can you make a reduced test case?
10:22duck1123I keep trying nrepl from time to time, but it hasn't been stable enough for me to switch yet. I also don't like that I have to be in the buffer to use C-c M-n
10:23MasseRclgv: Thanks. 46 lines of java later I'm rolling
10:23clgvTimMc: http://xkcd.com/583/
10:24AWizzArdduck1123: The newest Clojure 1.5 alphas don't work with slime anymore.
10:24Cubicduck1123: How would you expect it to behave?
10:25duck1123Cubic: With Slime, I can be in another buffer and it'll prompt me for the ns I want to switch to
10:26AWizzArdTimMc: I can see if I can produce such a condensed test case.
10:28CubicIs there any way you can force recompilation of a file from the repl? Right now I always have to restart the thing when I make some changes to a file, which is rather annoying
10:29AWizzArdCubic: you could reload the code, and thereby recompile it.
10:29AWizzArdIn Emacs in the code buffer: C-c C-k
10:30AWizzArdTimMc: What I do now is: lein swank, then start up emacs, slime-connect, then I load my test buffer, which has the :use. When I then check the metadata of -main I see :private true.
10:30AWizzArdFunnily, if I now open the code file of my core code, and C-c C-k that one, from that moment on -main is no longer private.
10:32AWizzArdTimMc: you could try the same, first load your test code in Emacs, and indirectly load the file which contains the -main, via :use.
10:37jcromartieso the arc challenge...
10:37devnlol
10:38jcromartie:P
10:38AWizzArdjcromartie: what is the arc challenge?
10:38jcromartieAWizzArd: it's "how easily can your language do this" http://paulgraham.com/arcchallenge.html
10:38jcromartieat the end
10:38jcromartiea web form
10:38jcromartiewith anonymous callbacks
10:39clgvAWizzArd: you might have some stale class file lying around. do a "lein clean" and test that again
10:39TimMcAWizzArd: I don't have SLIME on that box.
10:41AWizzArdclgv: I did a „rm -fr target” and tried again. I still get the „-main is not public” error.
10:41clgvAWizzArd: thats weird. this is with clojure 1.5?
10:42AWizzArdBut still a good idea. This could have been it. Unfortunately the error is still there.
10:42AWizzArd1.4
10:43clgvAWizzArd: I tried with clojure 1.4 overhere. my -main is public.
10:44clgvthe namespace has only (:gen-class) without custom declarations
10:51balinthey
10:51balintI'm trying to set up cascalog and have run into an error
10:51balintwhen I do 'lein repo' I get this
10:51balintOct 31, 2012 3:27:22 PM org.apache.http.impl.client.DefaultRequestDirector tryExecute
10:51balintINFO: I/O exception (java.net.SocketException) caught when processing request: Connection reset
10:51balintOct 31, 2012 3:27:22 PM org.apache.http.impl.client.DefaultRequestDirector tryExecute
10:51balintit seems like a remote repo might not be available but I'm not sure
10:52balintI have the latest leiningen installed (2.0.0-preview10) and other projects do work
10:52balintI'm on Java 1.6.0_37 Java HotSpot(TM) 64-Bit Server VM
10:52jakubHbalint: what is "lein repo" supposed to di? I didn't need that to work with cascalog
10:53balintjakubH: sorry, lein reps :)
10:53balintdeps
10:53jakubHlein deps in leiningen 2 doesn't do much/anythig, why are you running it?
10:54balintbecause that's what the cascalog readme tells me to do:
10:54balinthttps://github.com/nathanmarz/cascalog
10:54algernondoesn't it say 'repl' ?
10:55jakubHI see
10:55algernonah, nvm, I'm a few minutes behind.
10:56mailheadersnutcase
10:56jakubHfor me lein deps does nothing ; the help reads:
10:56jakubHUSAGE: lein deps
10:56jakubHForce Leiningen to download the dependencies it needs. This usage is
10:56jakubHdeprecated as it should happen automatically on demand.
10:56jakubHanyway the problem you are experiencing indeed may be a rempte repo down
10:56balintlein install does the same
10:57jakubHI guess you can run lein with some option to print debug info to see which repo hangs
10:57jcromartieso yeah this works https://gist.github.com/3987491
10:58jakubH(or try lein pom; mvn -X dependencies:resolve)
10:59jakubHsorry, http://maven.apache.org/plugins/maven-dependency-plugin/resolve-mojo.html
11:06balintso I should install that maven plugin first to be able to debug
11:06duck1123the maven plugin should install itself when you call it
11:07balintok
11:07duck1123The only reason he listed that is because mvn -X should give you a bit more info about what is going on
11:18AWizzArdCubic: btw, how can I change the key bindings of the nrepl mode?
11:18jakubHright; I would suppose that lein has st like maven's -X but don't know
11:19jakubHbalint I just run lein deps on a fresh set up and it worked
11:20jakubHlein version => Leiningen 2.0.0-preview10 on Java 1.6.0_37 Java HotSpot(TM) 64-Bit Server VM
11:20balintjakubH: hmm, interesting
11:20balintI get this: Could not transfer artifact org.slf4j:slf4j-log4j12:jar:1.4.3 from/to central (http://repo1.maven.org/maven2)
11:20balintwhat's your clojure version?
11:22balintoh, that's also defined in the project.clj file so it's probably project-specific?
11:22duck1123I see that version in the repo. Perhaps you could try a newer version. http://mvnrepository.com/artifact/org.slf4j/slf4j-log4j12
11:23jakubHI just run "lein new my-project" and added [cascalog "1.10.0"]
11:23jakubH to dependencies and the line :profiles { :dev {:dependencies [[org.apache.hadoop/hadoop-core "0.20.2-dev"]]}}
11:27jakubHWhere does that slf4j-log4j12 version come from?? Here it is successfully trying to download Retrieving org/slf4j/slf4j-log4j12/1.6.1/slf4j-log4j12-1.6.1.pom (2k)
11:28jakubHare you creating a new project from scratch as described on the cascalog page or have you added some of your own dependencies there?
11:28balintcreating a new project
11:29balintjust cloning the cascalog repo from github and running lein repl
11:29duck1123If you want to be absolutely sure about your dependencies, you could try using https://github.com/xeqi/lein-pedantic
11:29balint(or now lein pom and mvm -X)
11:29balintthe slf4j comes from log4j, I presume
11:29balintthat's the only logging related lib in project.clj
11:30balinthowever, it's not listed as a dependency here: http://mvnrepository.com/artifact/log4j/log4j/1.2.16
11:30duck1123lein deps :tree or mvn dependency:tree help here
11:31jakubHand it is really strange you cannot find the jar in the repo since it is there as duck says (also here http://search.maven.org/#artifactdetails|org.slf4j|slf4j-log4j12|1.4.3|jar)
11:33pandeiroi'm getting "Error loading project.clj" with lein-cljsbuild 0.2.9 - but my project.clj is in the project root and looks fine... anyone know what could be up?
11:34jakubHbalint here is my lein deps :tree http://paste2.org/p/2408055
11:34pandeirohuh, same problem with lein deps
11:35duck1123pandeiro: mismatched parens?
11:35pandeiroack nvm
11:35pandeiroduck1123: missing a val
11:36duck1123jakubH: try adding an explicit ref to the log4j adapter, see if that helps
11:37AWizzArdS11001001 and TimMc: I have the strong suspicion, that AOT+Leiningen are responsible for that mysterious -main privateness in my test ns.
11:37duck1123I wonder if that runtime scope is messing things up somewhere
11:37balintduck1123: thank you. the problem is I can't even run mvm dependency:tree
11:38balint[ERROR] Failed to execute goal on project cascalog: Could not resolve dependencies for project cascalog:cascalog:jar:1.10.1-SNAPSHOT: Could not transfer artifact org.slf4j:slf4j-log4j12:jar:1.4.3 from/to central (http://repo1.maven.org/maven2): Error transferring file: Connection reset -> [Help 1]
11:38AWizzArdWhen I turn AOT off my -main does not magically turn into a private function.
11:38TimMcFascinating.
11:38mailheadersanyone doing anything useful with clojure?
11:38mailheadersgive me something useful to beta test
11:39mailheadersDon't you understand the importance of entropy?
11:39duck1123balint: and you don't have any funky firewalls, proxies, or overridden repos to contend with?
11:39TimMcllasram: OK, you *may* have convinced me that it's better to use a Java loader stub in lein-otf, mostly because I can't seem to get a Clojure version working. :-P
11:39AWizzArdTimMc: it seems because I AOT my NS in the target/ folder I have a compiled version.
11:40TimMcAWizzArd: I've had bad luck with lein test + AOT in the past.
11:40AWizzArdNow when I C-c C-k (load) the test ns inside emacs it compiles a new version of it, it seems.
11:40balintduck1123: no, I don't
11:40AWizzArdNow in my test NS I only have to evaluate anything that is in my :use’d original NS. No function call required. Just type something into the repl. And magically -main turns private.
11:40balintoverridden repos?
11:40mailheadersWhat is your mission?
11:41AWizzArdSo it seems that evaluating anything from my original NS, which I :use in the test NS, triggers some reloading of files from the disk.
11:41jakubHbalint to mee it also looks as something with your network or setting; try to do it on some server with clean setup or so st
11:41jakubHI have to go, good luck
11:41nDuffmailheaders: If you're interested in looking at Clojure projects, see http://www.clojuresphere.com/; there's a random-order option.
11:41balintjakubH: thanks a lot for your help
11:41balintI'll sort it out
11:41balintduck1123: to you, too
11:41duck1123balint: based on the error, I don't think thats the case, but check ~/.m2/settings.xml (may have name wrong)
11:43balintduck1123: can't find any *.xml there that might be a config file
11:44jcromartiehttps://gist.github.com/3987491 -- jump to the bottom for the Arc Challenge implementation
11:44duck1123balint: Then you're good on that front. Still sounds network related. Can you hit http://repo1.maven.org/maven2/log4j/log4j/1.2.16/log4j-1.2.16.pom
11:44jcromartieit's longer
11:44jcromartiecould get around it with more macros
11:44balintduck1123: yes, I can
11:44mailheadersWhat is Cognition Caps?
11:45nDuffmailheaders: uhh, its github site says exactly what it is.
11:45mailheadersSensitiveDataFilter this is called redacting
11:46duck1123balint: did you try adding [org.slf4j/slf4j-log4j12 "1.4.3" :exclusions [[log4j]]] to your project? (or a higher version)
11:46mailheadersnDuff: what the F are you talking about
11:47mailheadersdid you code any of this nDuff?
11:48mailheadersi don't know what goes on in these autistic coders minds but in english naming conventions matter
11:48nDuff*plonk*
11:48mailheaderswhatever useless things you tell your calculator to do if you want a real human to care it has to use proper english naming conventions
11:49mpanhow is that guy so persistent? I'm beginning to think he's a markov-chain bot
11:49mpansurely a human has better things to do with their morning
11:49duck1123you'd be surprised
11:50mailheadersno i have to dump shit on you because all of your code means nothing just donating entropy to a robot
11:50balintduck1123: mvm is trying to download http://repo1.maven.org/maven2/org/slf4j/slf4j-log4j12/1.4.3/slf4j-log4j12-1.4.3.jar
11:50balintand that's where it fails, can you access it?
11:50CubicI think it's probably a real guy watching 10-20 channels at the same time and writing the same thing to all of them. I think it's a bit too good to be a bot.
11:51lynaghktechnomancy: okay if I pm re: lein/heroku config issues?
11:51mpanI think his conversation sounds approximately like what a markov chain generates
11:51mailheadersWhen i tell you something that makes sense you idiots just make retard comments about bots all of the time
11:51duck1123balint: works fine for me. Can you access it outside of lein or mvn?
11:51mailheadersyour minds are broke off into lala land
11:51nDuffmpan: Parts do, but parts _did_ seem human-driven. I'm voting for hybrid.
11:51mailheadersbecoming a burdon on my society
11:51mpananyway, after a morning of modeling domain data, I feel I need to cut down on my domain scope
11:51nDuffanyhow, /ignore is a beautiful thing.
11:52jcromartieyay
11:52zerokarmaleftbalint: can you access the jar directly from http://search.maven.org/#artifactdetails%7Corg.slf4j%7Cslf4j-log4j12%7C1.4.3%7Cjar
11:52jcromartieignore is good
11:52mpaninstead of simulating foo, I'm just going to simulate foo intersect bar intersect baz
11:52balintzerokarmaleft: yes, it works that way
11:52mpanfar fewer special cases that way, far shallower nesting of data representation required
11:52zerokarmaleftbalint: in that case, i'd just stuff into the correct place in ~/.m2
11:52balintnot through curl, though
11:53mailheaderstype this into google define: redacting
11:53mailheaders2nd def
11:53mailheadersefficiency
11:53zerokarmalefti've done that on a couple of occasions when lein and mvn can't retrieve them for whatever reason
11:53mailheadersWe, nor no one, needs a three word run on with capitals.
11:54mailheadersTheres nothing beautiful about silliness, are you also going to "print" me a plastic fish with the reprap?
11:59mpanif you know something is truthful or nil, is it considered idiomatic to test with a naked if?
11:59mpane.g. an element is known to be keyword or nil
12:00AdmiralBumbleBeempan: what else would you expect to do?
12:00nDuffmpan: I would do it that way, yes.
12:00mpanan if and a nil? would have been my other guess
12:00mailheadersAdmiralBumbleBee: you made me laugh
12:01TimMcnil-punning is idiomatic, for better or worse :-P
12:01mpanI mean, not that this is necessarily a reasonable comparison, but certain analogous things in php are very dangerous
12:01AdmiralBumbleBeeit is easier to read to use (if (nil? x))
12:02AdmiralBumbleBeeit's also less susceptible to bugs in the future
12:02TimMcAdmiralBumbleBee: I think that's the kind of thing I would have written when I first was starting with Clojure, but now I would just use if.
12:02duck1123I'd like to argue that you usually know what type of data you're dealing with in clojure better than php
12:02AdmiralBumbleBeebut I wouldn't do it :)
12:02mpanbut then again, php goes as far as to pun strings and numbers, so the danger is not necessarily comparable
12:02AdmiralBumbleBeeTimMc: yeah, I agree
12:02balintzerokarmaleft: sorry, but how do you that?
12:02AdmiralBumbleBeeI was just being explicit about some advantages of it
12:02TimMcI recently ran across some ,,, in some -> clauses that I wrote a while back.
12:03balintI only find the jars of the projects themselves in ~/.m2/repository/<projectname>
12:03duck1123balint: download the pom and the jar, and put them in a dir in ~/.m2 according to the group/artifact. Look at the others for examples
12:05duck1123or, you could use mvn install:install-file to have mvn do it for you
12:05AdmiralBumbleBeeI guess using nil? would be somewhat similar to using stuff like if ( 1 == x) in another language
12:06balintduck1123: I did but it still wants to download the jar from the remote repo
12:06duck1123you have to ask yourself: If a false snuck in here, which branch should it take
12:06balintduck1123: thank you anyways
12:06balintI need to go, will get this working
12:07duck1123balint: you could add :offline? true to your project to skip downloading
12:08duck1123or try setting up a mirror like so https://github.com/technomancy/leiningen/blob/master/sample.project.clj#L202
12:15samratwhy doesn't (clojure.string/split "id|name|foo|bar" #"|") work? it does work for #":"
12:15technomancylynaghk: sure
12:16samrat,(clojure.string/split "id|name|foo|bar" #"|")
12:16clojurebot["" "i" "d" "|" "n" ...]
12:16zerokarmaleftbalint: if you're able to d/l the pom and jar, cp them into ~/.m2/repository/org/slf4j-log4j12/1.4.3/
12:17mpan,(clojure.string/split "id|name|foo|bar" #"\|")
12:17clojurebot["id" "name" "foo" "bar"]
12:17zerokarmaleftperiods in group ids turn into additional subdirectories
12:17mpanproper style should probably be
12:17mpan(if I recall)
12:17mpan,(clojure.string/split "id|name|foo|bar" #"\\|")
12:17clojurebot["" "i" "d" "|" "n" ...]
12:18mpanwhoops, ok use the earlier one
12:18mpanthe other one was just me confusing myself
12:18samratmpan: thanks
12:18mpanbasically, | is special, it means "match this OR that"
12:19mpanthere's a large set of characters with special meaning
12:19mpantry http://www.regular-expressions.info/tutorial.html or a similar reference
12:20S11001001,(mapv #(re-pattern (java.util.regex.Pattern/quote %)) ["|" ":"])
12:20clojurebot[#"\Q|\E" #"\Q:\E"]
12:20S11001001or :)
12:22mpanI keep confusing myself when working with multiple levels of escaping
12:22TimMcmpan: Luckily, Clojure's regex literal takes one of those levels away.
12:22mpanTimMc: see, I forget that fact ALL THE TIME
12:23mpanbecause I got used to java regex instantiation
12:23mpanthus my slip-up above
12:24TimMcIf we had heredocs, it would all be peachy.
12:25mpanhow do you envision that would fit in with the reader?
12:25mpanor just a special case of something that isn't an s-expr?
12:26zerokarmaleftduck1123: nice, didn't know about install:install-file
12:27zerokarmaleftalthough the ease of passing maven a laundry list of arguments is roughly the same as navigating .m2
12:27duck1123If I'm running a compojure app as a servlet, what do I need to do to have the context removed? I see the context fn, but should I create a handler fn to set up the context from the request, or is there a better way?
12:28duck1123zerokarmaleft: install:install-file comes in handy when you don't have a pom to work from
12:36mailheaderscognition caps?
12:36gensymvhello is there a good package manager for clojure?
12:36jcromartieduck1123: what do you mean "have the context removed"
12:36mailheaderscycling caps?
12:36jcromartiegensymv: Leiningen
12:36mailheadersWhat are you trying to spread brain damage?
12:36mailheadersWhen riding a bike wear a helmet.
12:37duck1123jcromartie: My servlet is served from /foo I want my route /bar to match the path /foo/bar
12:38gensymvjcromartie, but i have to create the project.clj file my self for that one.
12:38jcromartiegensymv: yes, and no, "lein new" creates a template project with a project.clj file for you
12:38duck1123gensymv: leiningen should be everything you need. leiningen uses maven's package system along with clojars which is a repo for clojure projects
12:38mailheadersmy servlet took a dump on your srvlet
12:39jcromartieduck1123: I think "context" is what you want
12:39jcromartieor do you mean you want to be able to serve it from any context?
12:39mailheadersyou selling cycling caps?
12:40mailheadersWow you are the best thing since the band Hanson
12:40duck1123jcromartie: I want to be able to serve it from any context. I have the current context assoced into the request, I just need to set it up to read that. I was wondering if there was something pre-baked for that task
12:41jcromartieyou'd have to write middleware, should be easy
12:41gensymvduck1123, can it pull packages directly from clojars?
12:41gensymvduck1123, i am searching something like cabal or pip
12:41gensymv*searching for
12:42nightfly_leiningen does what you want...
12:43nightfly_And "lein uberjar" is just plain cool
12:44gensymvcool, but how?kkj
12:44jcromartieduck1123: so you just want to strip the context from the :uri before passing it to your simplified handlers
12:44duck1123gensymv: Once you have a project file set up, you specify the deps you need in the :dependencies section and lein will make sure they're available on the classpath. You don't install packages directly
12:44gensymvah.
12:45duck1123jcromartie: exactly. Should be simple, but seems like I'm not the first to need it
12:45clojurebotGabh mo leithscéal?
12:45jcromartieduck1123: fist I've heard of it but it sounds useful for anybody deploying a Compojure app in a more traditional container
12:47gensymvah i get it. it pulls the packages when i launch the repl/needs to use them.
12:47gensymvthat was the confusion i was having
12:47gensymvthanks.
12:54tgoossenswho has experience with noir?
12:54TimMc~anyone
12:54clojurebotJust 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 ..."
12:55jcromartieI bet Raynes does...
12:55jcromartie:)
12:55tgoossensDoes anyone have experience with Noir. I consider using it for a web project. And I want to know about its stability and performance.
12:55jcromartiebest part of IRC: the library author is usually in a channel somewhere
12:55tgoossensis that better then? :D
12:56tgoossensjcromartie: yeah i noticed that :p
12:56duck1123I don't use noir, but I haven't heard any recent complaints about instability
12:59tgoossensI'm relatively new to clojure (Using it for one month).
12:59tgoossensWondering
12:59tgoossensin java you can make a javadoc for your projects api
12:59CubicWhat are you trying to use it for? I don't think noir is ready to be the next google backend, but there are several websites using it (including, of course, noirs own homepage).
12:59tgoossenshow is it done in clojure? Is there a "standard" way to do it?
13:00technomancytgoossens: you can, but it's not very useful
13:00technomancysince all docstrings are available at runtime in the repl
13:00duck1123codox is pretty nice https://github.com/weavejester/codox
13:00tgoossenstechnomancy: http://webnoir.org/autodoc/1.3.0/noir.core.html#var-custom-handler
13:00duck1123also https://github.com/fogus/marginalia
13:00zerokarmaleftor marginalia if you're into literate style docs
13:00technomancyjust use the repl
13:01tgoossensCubic: It's for a project where I live (Antwerp). If released very probably used by 500 students per school
13:02Cubictgoossens: I doubt you're gonna run into performance or stability problems with 500 users, but don't quote me on that.
13:02tgoossensCubic: I won't :D
13:02TimMctechnomancy: The REPL is great for targeted doc reading, but it's not great for skimming down a list of available oeprations.
13:03tgoossenstechnomancy: i've been reading about "data vs api" and data IS the api in clojure. But you use metadata to document what you expect as argument?
13:04tgoossensHowever. With destructuring I've found it much simpler to know what i can give to the function
13:04tgoossensnotice the world "simple" ;)
13:04technomancyyeah, there's no hard and fast rule; it comes with time
13:05technomancyI recommend starting with compojure for a web project though
13:05tgoossenshmm heard of it never seen.. googling...
13:05tgoossenstechnomancy: can you also say why?
13:06technomancytgoossens: it doesn't make decisions behind your back like noir does and is easier to debug when things behave unexpectedly
13:06tgoossenstechnomancy: hmm descisions like what?
13:06technomancynoir makes it difficult to apply middleware in a composable way
13:06jcromartietgoossens: Noir is based on Compojure
13:07jcromartieNoir creates things you can't control
13:07tgoossensi see
13:07mpanwhat are concrete examples of what noir doesn't let you control?
13:07jcromartiebasically, Noir adds a "friendly" stateful API on top of Compojure, and lets you create "pages" instead of handlers
13:07duck1123use plain compojure+ring till you get the hang of clojure web dev then decide if you need a higher abstraction
13:08tgoossensi like the defpage :p
13:08technomancympan: the one that comes up most often is the difficulty of applying middleware and the fact that routes are tucked away somewhere in an atom
13:08jcromartiedefpage is OK when that's all you need
13:08technomancyrather than being first-class defs
13:08mpanlike because it has state, you have to do stuff in a defined order?
13:08jcromartieand "defpage" is a misnomer
13:09jcromartiebecause it doesn't result in a var you can see
13:09tgoossensmpan: i'm quickly scrolling through api examples. Haven't dived into it yet
13:09jcromartieit sets up a route somewhere else
13:09gensymvso i tried installing core.logic through leiningen, it pulled down jar's from the interwebz but now i cannot open the repl through leiningen
13:10gensymv(it complains about socket errors)
13:10jcromartieyou can only do GET or POST with defpage
13:10jcromartieand you can't do both at the same URL
13:10gensymvany ideas?
13:10tgoossensok.
13:10tgoossensi'll take a look at compojure then :)
13:10jcromartiegensymv: any more specific error?
13:11gensymvi'll pastebin it, wait a sec.
13:11jcromartietgoossens: and please hang around, because I'm sure you'll have questions :)
13:12tgoossensOh I wille. I've been hanging around here already way too much :D . I love the quick help :D
13:12gensymvoh nvm, apparently it wasn't finished with pulling dependencies -- which is weird.
13:12jcromartietgoossens: first step is to add compojure and ring (for ring.adapter.jetty/run-jetty)
13:13jcromartieyou'll want [ring "1.1.6"] to get everything
13:13tgoossensjcromartie: its just. I've so much work at university that I almost cannot find time to 1) play with clojure 2) also relax :D
13:13jcromartietgoossens: I hear ya
13:13tgoossensjcromartie: certainly because at university i'm obligated to do projects in java (only)
13:14mpantgoossens: I also feel like almost all my programming is for university assignments
13:14tgoossensall we learn is java, OOP, designpatterns etc etc
13:14mpanand afterward, I feel too burned out to do much on my own
13:14gensymvthis is what it complains about btw. http://bpaste.net/show/T5cV4u2pf8tUgYu1PJ24/
13:14tgoossensmpan: i know how you feel
13:14jcromartietgoossens: you should ask your profs about Clojure
13:14jcromartieyou can AOT compile a Clojure class and hand in a jar
13:14tgoossensjcromartie: interesting
13:14mpanjcromartie: I have seriously considered that
13:14tgoossensjcromartie: That might work
13:14mpanbut it would be "bending the rules" in an "undersirable" way
13:15jcromartielol
13:15tgoossensjcromartie: only, 1) They want to see the source code. 2) they expect it to be OO 3) this year it is a groupswork so my teammates won't ever agree :p
13:15jcromartieI only took some CS courses at a community college. Intro to programming, OO analysis and design, data structures… it sucked
13:15jcromartieyeah
13:16jcromartieall Java, all the time
13:16tgoossensAt univseristy i think OO is really taught to much like "its the best ever! And if it is not OO, its bad!"
13:16jcromartieand no real explanation
13:16jcromartiejust rote learning
13:16jcromartiethe "hello world" case for Java is pretty bad
13:17ToxicFrogmpan: have you asked the TA/profs? It might be worthwhile to do so.
13:17gensymvso, it apparently finished pulling stuff, but i think i broke something.
13:17tgoossensbut it has only been since september that I came into contact with something else than OO / imperative programming
13:17gensymvhttp://bpaste.net/show/sZVqJ7pJTN7cl7j3O5qE/
13:17mpanToxicFrog: they don't want to grade Clojure... their life is hard enough grading Java
13:17gensymvhelp will be appreciated.
13:17ToxicFrogHell, I got away with doing Compilers with a C/Lua mix and Distributed Systems in Erlang.
13:17ToxicFrogOh :/
13:18mpana certain class goes as far as to say standard Java library only, no external deps
13:18jcromartieI think they should start teaching with Python
13:18tgoossensyes
13:18tgoossensIn fact
13:18tgoossensthey considered teaching python instead of java in the first bachelor yar
13:18tgoossensthey didn't :(
13:18jcromartiegensymv: what does your project.clj look like?
13:18mpanbecause they have ~50 students per grader, every assignment
13:18jcromartiecompare: print "Hello, World!"
13:18mpanand the poor grader has a life
13:18jcromartievs Java: public class Hello { public static void main(String[] argv) { System.out.println("Hello, World!"); } }
13:19tgoossensi know :D
13:19jcromartielike, WTF is all of that?
13:19tgoossensthe first time
13:19ToxicFrogtgoossens: could be worse, we're using C for first year, and there's no consistent protocol for teaching students how to operate the debugger either.
13:19mpansure, but if that was the only complaint, it would be a rather small one
13:19mpanI'm more worried about the complaints that don't go away over time
13:19tgoossensToxicFrog: it can be even worse: I have to write assembly for mips architecture :p
13:19mpansure but that's for a specialized course
13:19mpannot in general, right?
13:19gensymvjcromartie, https://www.refheap.com/paste/6286
13:19nDufftgoossens: That's not so bad at all.
13:19tgoossensi know ;)
13:20ToxicFrogIME most of them don't start understanding programming (as opposed to "how to cobble together a working program in C") until near the end of second year when they're getting exposed to python and java as well.
13:20jcromartiegensymv: you are missing Clojure itself!
13:20nDufftgoossens: MIPS is probably one of the better architectures to work with for that purpose.
13:20tgoossensi know
13:20ToxicFrogWe use the 68k for our asm course.
13:20nDufftgoossens: ...granted, as former maintainer of gxSPIM, I might be a little biased. :)
13:20jcromartiegensymv: in a Leiningen project, the language is a library (pretty cool if you ask me…)
13:20ToxicFrogI've never used MIPS, just 68k and 386.
13:20jcromartiegensymv: add [org.clojure/clojure "1.4.0"]
13:20tgoossensnDuff: and I have nothing against programming in assembler, as long as it is for learning how under the hood it works
13:21nDuff*nodnod*.
13:21tgoossens(kinda)
13:21gensymvjcromartie, lol.
13:21gensymvthanksş
13:22tgoossensi still have 2,5 years to go at univ. And as far as I know. It will all be in sense of OO
13:22nDuff...well -- I've actually heard a pretty compelling argument that SH is a better learning architecture
13:22nDuffbut it hasn't been around nearly as long.
13:22nDuff(the SH manuals are annotated with C to implement each instruction in a simulator).
13:22gensymvjcromartie, that did the trick.
13:22gensymvjcromartie, thanks pal.
13:23gensymvone more question, if i clone the repo and create the project.clj file with the sole dependency of clojure itself, will it directly internalize the library?
13:24jcromartiegensymv: not sure what you mean
13:24jcromartie"internalize"?
13:25gensymvhttps://github.com/clojure/core.logic
13:25tgoossensAnyone used clojure already for android development? Might be interesting i think
13:25technomancytgoossens: it's not anywhere close to ready from what I hear
13:25gensymvif i clone this repo, create a project.clj file and "lein install"
13:25gensymvit will do the same thing right?
13:30tgoossensFunctional programming an sich existed already a loong time ago. Why do you think it hasn't been as popular as OO. It has probably to do with identity, which is a great way for modelling stuff i think. But that argument is invalid now, clojure has identity (in a much cooler way)
13:30cemericktgoossens: I've recently heard people being waved away from scala for android dev because of classloader and JIT issues. Those problems affect Clojure even more.
13:31tgoossenshow come?
13:31mpanhow much of that is bypassable by aot compilation?
13:32mpanI mean, being a different VM is meh :/
13:33tgoossensI also think that. in functional programming. The idea of "pure functions" scare people: "How are we supposed to have interaction with the outside world then?"
13:34cemericktgoossens: My understanding is that even simpler things like protocol dispatch (which is optimized to the 9's by hotspot et al.) are impaired in dalvik
13:34cemerickmpan: AOT is mandatory for anything approaching sane android dev as far as I've heard
13:35dnolencemerick: still hoping people give ClojureScript a shot on Android w/ V8, from the sound of it on Raspberry Pi ClojureScript runs circles around Clojure JVM
13:36cemerickbut that doesn't address points of dynamism like protocols, multimethods, proxies, etc. Scala's runtime has none of those features, so doesn't suffer from the poor JIT.
13:36cemerickhah, sweet
13:36cemerickdnolen: if and when I do mobile, that's the route I'll be taking
13:37mpanI hear a lot of mobile native dev folks complaining about anything involving HTML 5, but then again, they are hardly impartial
13:37cemerickwe can't blame Clojure for its perf on the Pi though; that's more of an architectural issue between V8 vs. JVM.
13:37dnolenJavaScriptCore is quite fast too from what I can tell. Would be happy to see a lighter alternative to PHMs for ClojureScript - that's the slowest datastructure by far. Perhaps cgrand new map type will perform better?
13:38dnolencemerick: yes implementation details ;)
13:38cemerickmpan: Sure, if you've got cash to burn on additional devs for 2±1 platforms. *shrug*
13:39mpanwell, a particularly poignant example was a certain CTO from a certain company whose success depended on convincing their clients to get native apps done for each platform
13:40mpanhe accused me of being an HTML 5 apologist at a job fair and whatnot
13:40mpanI really shouldn't say these things under my own name :(
13:40tgoossensgotta catch a train
13:40tgoossenswe speak again!
13:40mpanhave fun
13:40Baldanders`@tgoosens Well, I think there are some reasonable reasons to want to be sure that you can break out of pure FP without too much inconvenience for certain kinds of things. Even if they can be modeled purely it's not always convenient or practical.
13:41Baldanders`err- well, maybe I will talk with you about it some other time ;).
13:41tgoossens:)
13:41cemerickmpan: If mobile dev were my thing, I'd be HTML5-only just to avoid native platform sharecropping.
13:41tgoossenslong story short:
13:41tgoossensmulti paradigm rules
13:41mpan"sharecropping"? Sorry, I don't follow your metaphor
13:42jcromartieeh, I've tried the HTML5-instead-of-native thing, and it's just not for me
13:42jcromartieI'm sure HTML will get there
13:42jcromartiebut right now native is really far ahead
13:42jcromartielike, really *really* far ahead
13:43jcromartieand it's totally unfair since native can pull in HTML in a view wherever it is useful, while the reverse is not true
13:43mpanphonegap etc try hard to get some semblance of the reverse
13:43cemerickmpan: app store approval + 30% cuts is not a favorable market IMO
13:44jcromartiempan: they are wasting their time, honestly
13:44mpanon top of saturation, I suppose
13:44mpanapp store saturation is scary
13:44jcromartieI was at a mobile conference, and everybody that was presenting about PhoneGap and similar techniques were selling something
13:44jcromartieall of the actual app developers were using and advocating native
13:45mpanof course, native has momentum
13:45lynaghkcemerick, dnolen: we're working on a ClojureScript weather app for iPhone. Pref is a bit lacking---not sure how much is the JS situation and how much is attributable to CLJS.
13:46dnolenlynaghk: via JavaScript
13:46lynaghkdnolen: yeah.
13:46dnolenlynaghk: er, via JavaScriptCore or via WebView?
13:46lynaghkCordova, which I believe is using a WebView.
13:46dnolenlynaghk: yeah, I don't you'll get any JIT love there.
13:48lynaghkdnolen: yeah. We haven't done any perf tuning yet. Do you know offhand if it's possible to mash up JavaScriptCore while using a DOM?
13:49jcromartieJust point me to a 5-star, top-selling Cordova/PhoneGap app.
13:49jcromartie:P
13:53lynaghkjcromartie: maybe. We've done custom apps for enterprise folks using Cordova. Sells one copy, but the net is better than most app store apps =P
13:53cemerickjcromartie: what, you don't have a clojurec app available for download yet? ;-)
13:54devnhowdy all
13:57mpanlynaghk: any public examples of an app using those libraries?
13:57mpanoh whoops
13:57mpan:(
13:57dnolenlynaghk: it always good to get information about the bottlenecks, I did just add SourceMap V3 support to CLJS, perhaps can help w/ profiling if you're using a WebKit view in your app?
14:04NegdayenI played around with clojurescript in android dev using a web view for a bit. For me, the bottleneck were the javascript-java interop calls. Nothing clojurescript can really do about though, ofc.
14:05bonegaNegdayen: Have a look at Phonegap
14:05Baldanders`I have a question about Clojure idioms. Let's say I have a predicate function that just calls another function that can return some truthy value or nil. Is it more idiomatic to use a when, and return the value returned by that function, to use a when and return true from that branch, or to use an if and return true or false?
14:07NegdayenWell, I had considered phonegap--but.. for what I was doing, it wouldn't have really helped I think. I was doing somethign rather crazy and did no expect performant results in the first place--OpenGL rendering. Lol.
14:07technomancyBaldanders`: don't use an if with true/false in its branches
14:07technomancyBaldanders`: if you have to return a boolean, use the boolean function
14:08technomancyIMO it's OK to have a predicate that doesn't necessarily return a boolean, but that's debatable.
14:09Baldanders`OK- so is it better to just return the result of calling that function (in which case the function I am writing exists only to give it a better name) or to return true from a when?
14:09bonegaNegdayen: ah, I thought you were refering to some sort of api-problem, not the performance
14:09alexnixonBaldanders: the clojure library coding standards says "NB predicates return booleans"
14:09Baldanders`oh, I see
14:10technomancyBaldanders`: yeah, opinions vary. I really hate seeing when used for return values though.
14:10technomancyif the function is part of your public API then it's probably worth calling boolean though
14:10Baldanders`OK- I am kind of used to CL, where the nil/false distinction doesn't exist.
14:11technomancyfor internal functions I wouldn't bother; the question mark in the name is enough
14:11NegdayenWell, id o think the performance problem was in the api--marshalling and unmarshalling JSON data across to java OpenGL calls was terribly, terribly slow.
14:11Negdayenas one can imagine. :P
14:11alexnixonsee clojure.core/not-empty for a good example - it returns truthy if a collection is not empty and falsey if it is, but it doesn't return a boolean and so is not a predicate (it doesn't have a ? suffix)
14:12technomancyBaldanders`: nil isn't the problem; the problem is someone could conceivably do something with the a truthy return value.
14:12technomancyI would say it's their fault if they do that; the name clearly indicates it's a predicate, and if they use it as not-a-predicate that's a bug in their
14:12technomancycode
14:12technomancybut opinions vary
14:13NegdayenI was thinking perhaps there might be a way to perform the callins via the NDK and V8 or some other. But, I am not experienced in that area at all. Not sure if that would be a possiblity.
14:14mpanHm, I'm wondering about something from earlier. It's turning out that my data is a bunch of defs in a clj file. Would there be a difference in using it via require vs using it via load-file?
14:15jcromartiempan: why is your data a bunch of defs
14:15mpanbecause I'm lazy and this is the only place I'm going to use it
14:15dnolenNegdayen: that's a pretty interesting ClojureScript use story
14:16mpanso I'd rather avoid jumping through the encoding-as-some-serialization-format hoop
14:16mpanI admit, this isn't quite what I was originally imagining
14:16technomancympan: just put it in a map and use load-file
14:16jcromartieand by "some serialization format" you mean "prn" won't work?
14:17mpanbut semantically? is there any difference with putting it in a map and doing a require?
14:17jcromartieyes there's a big difference
14:17jcromartierequire doesn't return anything
14:17technomancyrequire won't work unless you have a namespace
14:17mpanoh, uh yes I do have a namespace
14:17mpanthere's a ns declaration at the top of the file, rather
14:18jcromartiempan: sounds like you just have a typical clojure code file
14:18mpanexcept this is "application data"
14:18jkkramerput the data in a file in resources/ and then use read or read-string or similar to pull it in
14:18technomancywhat jkkramer said
14:19mpanall right
14:19mpanthank you all
14:24duck1123if you're using useful, useful.config/read-config might be good for you
14:30jweisshuh, i'm just finding out (the hard way) that "thread local bindings" don't quite mean just that. if you spin off a thread within the binding form (eg in a future), that thread sees the same binding as the original thread. I assumed it would see only the root binding.
14:30mpanI've found "useful" but where do I find the docs for it?
14:31AdmiralBumbleBeempan: docstring
14:32mpanah thanks!
14:32duck1123like many clojure projects, just check out the source. :(
14:32AdmiralBumbleBeethe docstrings in useful are very well written IMO
14:32AdmiralBumbleBeeembarrassingly so when you compare to clojure.core
14:33pandeiroanyone get "Invalid number of options" when trying to use cljsbuild's notify-command feature?
14:34hiredmanjweiss: that used to be the case
14:35hiredmanjweiss: post 1.3 bindings get conveyed to futures and agents
14:35gensymvis there a way to make leiningen auto add the locally installed libraries to the classpath (outside the project)
14:35hiredmanit kind of stinks
14:36jweissi guess it's fine, i was writing log files (what I thought was) "per thread"
14:36jweissbut was getting jumbled output and couldn't figure out why
14:36piranhacan I do the same in clojure as 'import some.ns.*' in java? I.e. import every (java) class from namespace?
14:37duck1123gensymv: "lein classpath" will print out the classpath for the project. You can start there, but why are you trying to do this?
14:37nDuffhiredman: ...it does? I've been using bound-fn* unnecessarily, then.
14:38gensymvduck1123, i installed a library by listing it as a dependency of a dummy project, now i cannot use the library in repl outside that project
14:39nDuffgensymv: ...so, existing in the Maven cache isn't generally considered "installed"
14:39nDuffgensymv: ...think of it more as "cached"
14:39gensymvnDuff, hm i can see the corresponding jar file in .m2/repository/BLAR
14:40duck1123without a project, lein repl only has access to the dependencies it needs itself
14:40gensymvah.
14:40Baldanders`@technomancy: sorry for the delayed response- got called away. But that makes sense, and is maybe part of what made me feel a little unclean about just returning the result of calling the function. Thanks.
14:41gensymvis there a way to work around that?
14:41duck1123that's why it's best to always work in the context of a project, even if that project is only for one-off playing. Sooner or later you'll want to add a new dep
14:41nDuffgensymv: ...I _always_ work in projects. You can use pomegranite to install things at runtime, but you need to be in a project to have even that.
14:42gensymvhm, thanks.
14:42piranhaor at least is there any way to import package (as opposed to importing class), so that I won't have to enumerate every class name I need in :import declaration?
14:42jweisspiranha: i'm not aware of any way to require a bunch of ns' at once
14:42jweissoh you are referring to actually importing java classes
14:43piranharight
14:43piranhaI found answer that I can't, but I can't found if I can import package
14:43duck1123There used to be a ns+ macro I had seen, but IIRC it suffered from a bootstrapping problem
14:43piranhaI have like 40 classes...
14:43piranhait won't be fun to list them twice :-))
14:44jweisspiranha: i'm not aware of any way, unless you want to get ugly and use reflection to get a list of classes, and call import on all of them.
14:46piranhajweiss: well... that's not nice :)
14:47piranhajweiss: I thought maybe I can do something like (:require [my.java.package :as pkg]), but it seems to be not working
14:47jweissno, require is for clojure ns's only
14:47duck1123so you're directly referring to 40 classes in your namespace?
14:47piranhaduck1123: well I'm not yet, I'm just writing it
14:47piranhaok, let's get more specific then :)
14:47piranhahttps://github.com/sirthias/pegdown/blob/master/src/main/java/org/pegdown/ToHtmlSerializer.java
14:48piranhahere is a Visitor for some markdown parser
14:48piranhaI need to have specific rendering of markdown (not in html), so I have to write my own
14:48piranhaI thought I'm going to have a function with long (case (type node) ast/RootNode ... ast/OtherNode ...), etc
14:49piranhabut it seems I have to list every class in my :import statement, which looks quite ugly
14:49piranhamaybe approach with case is ugly btw, but I don't know if I can have fast function dispatch on class
14:50jweisswhy not just do a map lookup?
14:50jcromartiepiranha: can you shell out to the Perl script?
14:50piranhajcromartie: nope, I need to have normal ast :-)
14:50jcromartielol
14:51piranhajweiss: like {RootNode process-root OtherNode process-other}?
14:51jweissyeah, assuming those are all functions already
14:52piranhawell, they are not, but I'll write them, heh
14:52piranhathat's an option... anyway, this means I have to list every name in :import
14:52jweissyou could just list the whole package name and not import anything.
14:53jweissin fact, if you used a map you could just leave off the package name and add it to all the keys afterward
14:53jweissbut that is getting a bit fancy
14:53piranhahaha, but that's an option!
14:53TimMcpiranha: If you do an ls on the directory you could get a list of classes and just dump that in your ns block.
14:53piranhaTimMc: right ;)
14:53piranhait's just that editing will require 2 places
14:54duck1123That is one hell of an interface, btw
14:54piranhathough whatever, not a big deal, I shouldn't be changing that often :)
14:54piranhaduck1123: not exactly my dream, heh :-)
14:54piranhabut then, it seems like the best markdown parser for jvm (it's supported, has ast and documented, unlike others)
14:55jkkramera macro could expand a list of class names into appropriate dispatching code
14:56TimMcjkkramer: What, generating an (import ...)?
14:56TimMcOh, nvm, I see.
14:57jkkramerno, just '[RootNode, BulletListNode, …] => macro => whatever form your dispatcher takes (case statements, map, protocol impls, …)
14:57piranhahm, right!
14:57jkkramerthis is lisp, after all
14:57jkkramerwrite some code to write the code for you
14:58jweiss(inc jkkramer)
14:58lazybot⇒ 4
14:58piranhawell, thank you, I have to switch to different mindset, too much javascript is not doing anything good to my brain it seems
15:00Baldanders`I've said it before, but, IMHO, everything would have been a lot better if Netscape had just embedded Scheme in Navigator, instead of coming up with a scheme-inspired language meant for people used to C.
15:00TimMcAnd people would have used it, since they wouldn't have a choice.
15:01Baldanders`exactly ;)
15:01Baldanders`Javascript is every bit as offbeat as Scheme, actually.
15:01jcromartieBaldanders`: Imagine how bad ExpertsExchange would be if it were full of half-wit Scheme coders
15:01Baldanders`or was, at least.
15:01devnAm I a bad person for not wanting to switch to nREPL yet?
15:02nDuffdevn: Not bad, necessarily, but... I was wary, and switched recently, and I'm pretty darned happy.
15:02devnWhat about references? Like "Who calls..."?
15:02devnThat stuff is not implemented, right?
15:02piranhaindeed, I'm using JavaScript not because I like the language, but because of environment. I would write for browsers even if they had Cobol inside %)
15:03Baldanders`Hmm- I'm not sure it's better to have a bunch of half-wits using a half-baked language. Though, to be fair, Javascript is pretty neat in places.
15:03hiredmandevn: we still use swank/slime for our work projects, I've used nrepl for some personal projects, and ux for swank/slime is still better
15:04hiredmanso I can't blaim anyone for sticking with swank/slime
15:04piranhaBaldanders`: can't imagine where it's nicer than any other language I'm using. In places it's sometimes as good as they are, but neat? No, no, it's painful :))
15:06jweissfrom what i've read about nrepl it's improving at an impressive rate. some of the open issues sounded annoying so i haven't switched yet
15:06pandeiroi can't get cljsbuild to include other ns within my src-cljs/ when i specify builds by subdirectory within src-cljs/*
15:07Baldanders`Well, it was my first exposure to protype-based stuff, hich I have since come to quite like for some things (though that has been done better elsewhere.) And it has real closures. And it is fairly lispy, if broken in a lot of ways. I am writing a lot of C these days, and I'd rather be writing js, if it had the charactersitics C has that js lacks.
15:13technomancydevn: who-calls in swank-clojure is pretty broken IIRC
15:14technomancythe main thing that's missing is the debug repl and inspector
15:14technomancyso I still fall back to slime if I have to work with a bunch of Java classes and need to peek at their methods
15:16hiredmanthe way nrepl endlessly creates *nrepl<n>* buffers is really a drag
15:16tickingam I the only one constantly writing (range start Double/POSITIVE_INFINITY) ^^?
15:16hiredman(nrepl.el)
15:16piranhaBaldanders`: ah, ok, sure, I was comparing JS to languages I write in, and that's mostly Python, so it's hard to love it :)
15:17bbloomticking: what do you use it for?
15:18tickingbbloom numbering pages, creating test sequences, indexing stuff ^^
15:19tickingbbloom why create a bound list when I can create an infinite one and just take n ^^
15:19bbloomticking: hm yeah, it's kinda unfortunate that there isn't some function that is as easy to use as .. and ... syntax in other languages
15:19tickingbbloom my point exactly ^^ (range n …) would be super handy ^^
15:20jkkramer,(take 10 (iterate inc 0)) ;a bit shorter
15:20clojurebot(0 1 2 3 4 ...)
15:20Iceland_jack,(take 10 (range))
15:20clojurebot(0 1 2 3 4 ...)
15:20jkkramerright, assuming your start is 0
15:20Iceland_jack,(take 10 (range 4))
15:20clojurebot(0 1 2 3)
15:20bbloomjkkramer: yeah, but range has nice chunking properties, etc
15:20Iceland_jackdamnit, egg on my face
15:21tickingjkkramer right, but its not as nice for somebody not familiar with the code
15:21tickingbbloom yeah chunking is awesome ^^
15:21jkkramersee also: map-indexed
15:22Baldanders`Sure- Python is fairly lispy too, though less so than js, IMHO. I've mainly written Python and C for the last couple of years. But there are a few placews where I think js might be better: Python's scoping rules are very weird, IMHO, an it would be nice to have real closures in Python.
15:22Iceland_jack,(take 10 (map #(+ 4 %) (range))) ; runs
15:22clojurebot(4 5 6 7 8 ...)
15:24tickingIceland_jack yeah problem is readability and performance there ^^
15:24dnolenIceland_jack: that's actually pretty good, since you can preserve chunking
15:24dnolenticking: I don't see how performance is really an issue here
15:25tickingdnolen two additions instead of one
15:25holohi
15:25dnolenticking: I'm sure the cost will be dominated by other things.
15:26dnolenit's not like chunking magically eliminates allocation overheads
15:26tickingdnolen yeah but why would you do chunking (which prevents one fn evaluation per value) just to reintroduce one function evaluation per value
15:26jkkrameryou could also write your own range function… (defn range-from [start] (range start Double/POSITIVE_INFINITY 1))
15:26tickingjkkramer that is basically what (range) does
15:27jkkrameronly if you start from 0
15:27dnolenticking: no, chunking doesn't eliminate fn evaluation - it eliminates allocation overhead, processing on 32 elements at time
15:27tickingjkkramer yeah but I'd probably prefer haskell like style a la 1 …
15:28Iceland_jackticking: how would that fit the Lisp syntax?
15:28tickingIceland_jack what lisp syntax ;) (range 1 …)
15:29tickingIceland_jack lisp is all about macros
15:29Iceland_jackSince when?
15:29tickingIceland_jack DSLs to be more precise
15:29Iceland_jackI stand by my question
15:30jkkramer(def ... Double/POSITIVE_INFINITY)
15:30tickingdnolen which you still reintroduce by calling that function on every element
15:30dnolenticking: no
15:31tickingIceland_jack since it got macros^^ why would you have oatmeal with toenails clipped in it if not for the flexibility ^^
15:31boodle/shell setenv TERM=screen-256color
15:31Iceland_jackI don't think this conversation will be fruitful
15:32dnolenticking: same as reducers. fns invocations on every element don't magically disappear
15:32tickingjkkramer yeah that'd do the trick ^^ but I was wondering how many other people use infinite lists starting at non defaults
15:33ejacksonhow is it the reduce works on java arrays, they are not classes so how is the CollReduce protocol extended to them ?
15:33dnolenticking: which why thinking adding one more arith operation will be a significant cost makes no sense
15:33jkkramerticking: that was tongue in cheek suggestion, don't do that
15:33tickingdnolen yeah what I meant was that with 1.0 seqs every first involved a fn being resolved and now it's only every 32th element
15:34tickingjkkramer I know I won't but I'd be a funny solution nevertheless that emulates that with a minimum line of code ;D
15:34tickingIceland_jack whats lisps flexible syntax for you about then?
15:35Iceland_jackNot interested
15:36dnolenticking: not sure what you mean about "fn being resolved"
15:37tickingdnolen if my understanding of the implementation is correct the lazy-seq macro wraps every subsequent call to the body in a separate fn
15:37tickingwhich gets then called by first
15:39dnolenticking: yes but what does that have to do with a "fn being resolved" in the case of chunked seq? if you mean that the allocation overhead is decreased because you get 32 transformed elements at time w/ chunked seqs ... ok.
15:42tickingdnolen, yeah I'm intrigued by this so I'm currently running some criterion benchs ^^I'd be delighted to be utterly wong :D
15:43amalloyejackson: reduce is extended to c.l.ArraySeq
15:44ejacksonamalloy: thanks. Now what is an ArraySeq (I'm reading the code for it now)
15:44amalloy&(class (seq (into-array [:a :b :c])))
15:44lazybot⇒ clojure.lang.ArraySeq
15:45amalloyit's just an implementation detail of how arrays are seq'd over
15:45ejacksonaaah I see
15:45ejacksonhmm... i was hoping to use reducers with arrays and avoid boxing
15:45ejacksonbut (seq (into-array ...)) will just box it up again
15:45ejacksonor is there something subtle to avoid that ?
15:46dnolenejackson: reducers don't support primitive pipelines yet
15:46ejacksonalas !
15:46ejacksonthanks dnolen, amalloy clears it up for me
15:46amalloyejackson: yeah, it won't work for primitives. it avoids consing up stuff for traversing the array, but for getting stuff out...
15:48holowith '({:check ['email1']} {:check ['email2']}) i want to obtain {:check (email1 email2)} . didn't have any success with apply/reduce + merge-with
15:49ejacksonprimitive type hinting the functions within the reducers does improve performance
15:49amalloyreally? i doubt that
15:49ejackson1 sec, i'll gist it
15:49amalloyi mean, maybe it improves the performance of your arithmetic inside the function, but you'd get that from a hinted let-binding
15:50amalloyand it won't improve the performance of calling, which is where the boxing happens
15:51TimMcholo: ##(let [in [{:check ["foo"]} {:check ["bar"]}]] (apply merge-with (partial apply conj) in))
15:51lazybot⇒ {:check ["foo" "bar"]}
15:51ejacksonamalloy: https://gist.github.com/3989381
15:51amalloyejackson: you have a 1.5 repl handy, right? mind trying out (reduce + (take 1e6 (cycle (concat '(1) [2])))) for me? looking at the code near ArraySeq makes me think it will stackoverflow
15:51ejacksonamalloy: sure, lemme try
15:52ejacksonno overflow
15:52amalloyejackson: right, here you're speeding up the call to Math/round by avoiding reflection, not the call to your function. https://gist.github.com/3989391 ought to be just as fast
15:53ejacksoneven at 1e8 it doesn't overflow
15:54ejacksonamalloy:aaah I see its that call
15:54ejacksonthanks that clarifies it
15:54amalloyTimMc: (= (partial apply conj) (with-slowness into))
15:57piranhacan I somehow view a function source in repl? This function is anonymous, so I can't do (:source (meta #'fn-name)).
15:58amalloyno
15:58ivanserializable-fn?
15:58clojurebotserializable-fn is a hack for preserving source of a compiled function: https://github.com/technomancy/serializable-fn
15:59ejacksonamalloy: thanks again.
16:00TimMcamalloy: haha, fair
16:01duck1123If I have some clojure code that I need to access from a JSP page, what would be the best way to include it? I originally wrote it as a compojure app, but I need it to be run in the context of our JSP template
16:02duck1123I got it working as an iframe, but I'm not happy with that solution
16:02hiredmancall it like however you call java core via jsp
16:03holoTimMc, i don't know why i didn't try this variation: (apply merge-with into (list {:check ['email1']} {:check ['email2']})) but it also works as yours. your (partial apply conj) melt my brain :>
16:04holo##(apply merge-with into (list {:check ['email1']} {:check ['email2']}))
16:04lazybot⇒ {:check [email1' email2']}
16:04TimMcholo: into is better.
16:05holoTimMc, that ' is weird
16:05TimMcholo: You know that ' isn't valid for string quoting in CLojure, right?
16:05TimMc&(class 'foo)
16:05lazybot⇒ clojure.lang.Symbol
16:05hiredman<%= clojure.lang.RT.load("my/ns/name"); ((clojure.lang.IFn)clojure.lang.RT.var("my.ns.name", "a-fun")).invoke("foo"); %> or something
16:05TimMc&(class "foo")
16:05lazybot⇒ java.lang.String
16:05hiredmanI don't know anything about jsp
16:05holoTimMc, ok, that's explained. probably forgot about it. thanks!
16:06devinuswhen was swank deprecated
16:07hiredmanactually, I don't think you need the IFn cast for Vars like that
16:07hiredmanas long as RT.var has a real return type
16:07tickingdnolen https://gist.github.com/3989455 interesting result ^^ I didn't think (iterate inc 4) would be so slow
16:09technomancydevinus: development on it ceased 8-10 months ago, but it was only made official 2-3 months ago
16:09amalloyi can't understand why (reduce + (take 1e6 (cycle (concat '(1) [2])))) doesn't cause a stack overflow with the new reducers stuff. it seems like internal-reduce should get called, and since the type of the underlying seq changes every time (back and forth between Cons and ChunkedCons) it should keep doing a non-tail call to internal-reduce again
16:10callenwhy is oauth so horrible?
16:11tickingdnolen 30% slower is indeed not bad, still overhead but not nearly as bad as I had assumed
16:12dnolenticking: yep
16:13hiredman,(type (cycle (concat '(1) [2])))
16:13clojurebotclojure.lang.LazySeq
16:13hiredman,(type (rest (cycle (concat '(1) [2]))))
16:13clojurebotclojure.lang.LazySeq
16:13hiredman,(type (rest (rest (cycle (concat '(1) [2])))))
16:13clojurebotclojure.lang.LazySeq
16:14hiredmanthe (lazy-seq ...) around the boyd of cycle (at least, maybe concat too?) makes it always a LazySeq
16:16duck1123callen: Have you read this? http://hueniverse.com/2012/07/oauth-2-0-and-the-road-to-hell/
16:17dnolenticking: iterate creates a real lazy seq, no chunking
16:18dnolenticking: so seq allocation overhead for every step
16:19tickingdnolen right, I didn't think that seq allocation is so much more expensive than function application
16:19dnolenticking: like way way way way way way more expensive
16:19tickingdnolen hrhrhr :D
16:19dnolenticking: ;)
16:20amalloyhiredman: only because you're calling rest instead of next
16:20piranhaargh, I have some cyclic dependency in my clojure file
16:20piranhahow do I resolve the problem that functions doesn't seem to be able to refer to each other?
16:20amalloyif you check (type (seq ....)) rather than (type ...), you get the classes changing. and since internal-reduce is checking (class (seq ...)), seems like it should bounce
16:20tickingpiranha you can use a forwards declaration
16:21piranhathanks, will read about it
16:21tickingpiranha sec, code follows ^^
16:21piranhaaha, (declare ...) ? :)
16:21tickingpiranha yeah exactly ^^
16:21piranhaticking: thanks!
16:21tickingpiranha np ^^
16:24goraciohi there
16:25hiredmanamalloy: interesting, if you put a println in the interal reduce impl it just shows Cons as the class all the time
16:25amalloyi must be putting my println in wrong, because i can't get any printlns to show up :P
16:26goracioi wonder if there is something close to cramp.in in clojure ?
16:27mpanwhich bot handles findfn, and what syntax should I be whispering it?
16:28amalloy$findfn 1 2 3
16:28lazybot[clojure.core/bit-or clojure.core/bit-xor clojure.core/+ clojure.core/unchecked-add clojure.core/+' clojure.core/unchecked-add-int]
16:28mpanthanks!
16:30hiredman,(type (seq (next (cycle (concat '(1) [2])))))
16:30clojurebotclojure.lang.ChunkedCons
16:32amalloy&(map class (take 10 (iterate next (cycle (concat '(1) [2])))))
16:32lazybot⇒ (clojure.lang.LazySeq clojure.lang.ChunkedCons clojure.lang.Cons clojure.lang.ChunkedCons clojure.lang.Cons clojure.lang.ChunkedCons clojure.lang.Cons clojure.lang.ChunkedCons clojure.lang.Cons clojure.lang.ChunkedCons)
16:34goracioso any thoughts about that ?
16:35dnolengoracio: sounds like someone needs to build something like it :)
16:36spligakgoracio, have you looked at aleph? may proved to be a foundation for something similar.
16:37spligak*prove, even
16:37rbxbxdnolen did you make it out okay with sandy?
16:37goraciodnolen: definitely :))
16:38dnolenrbxbx: I did, lost internet for a few hours was about it
16:39goraciospligak: thanks will look at it
16:39mpanAre { } literals always array-based maps? Is this potentially a performance issue if I've got a constant medium-sized lookup-table?
16:39rbxbxdnolen fairly non-traumatic. Good to hear :)
16:40jlewisis there a way to check to see if a .clj file is being run as a "script"? a la python's if __name__ == "__main__"
16:42dnolenrbxbx: thankfully yes
16:43tickingjlewis you mean if it is run as a main or called from a library?
16:43tickingjlewis or rather as a library
16:46devinustechnomancy: reinstalling emacs starter-kit, i'm not getting paredit on by default anymore, was that changed?
16:49devinusfeeling less productive already :P
16:50TimMc&(class (read-string (pr-str (into {} (for [x (range 8)] [x x])))))
16:50lazybot⇒ clojure.lang.PersistentArrayMap
16:50TimMc&(class (read-string (pr-str (into {} (for [x (range 9)] [x x])))))
16:50lazybot⇒ clojure.lang.PersistentHashMap
16:51TimMcmpan: It looks like only very small map literals are currently backed by flat arrays.
16:52zackzackzackHow can I extend a object such that I can do (ob :a) or (:a ob) and have it return property a of the object?
16:54rbxbxzackzackzack you'd have to implement the function interface
16:54hiredmanthose are two different things
16:54hiredmanfor (ob :a) ob is being called as a function
16:54hiredmanfor (:a ob) :a is being called as a function
16:54mpanTimMc: thanks!
16:54AimHereIf you create the object with defrecord, isn't the (:a ob) function already in place?
16:54Chousukeyes
16:55hiredmanfor an object to be callable as a function it needs to implement clojure.lang.IFn
16:55Chousukeusing keywords as accessors works for anything associative
16:55dnolenzackzackzack: not if you don't control the type, IFn and ILookup are interfaces in Clojure JVM
16:55zackzackzackSweet
16:55hiredmanwhen keywords like :a are called as a function they look themselves up in the argument via a number of different interfaces
16:55hiredmanthe easiest to implement is ILookup
16:55zackzackzackdnolen: that is what I was looking for I think
16:57zackzackzackLet's say I am extending a java class called Element then
16:57zackzackzackWould it just be
16:57zackzackzack(extend-type Element Ifn (invoke [this keyword] (code code code)))
16:58dnolenzackzackzack: as I said above, you can't do that
16:58dnolenzackzackzack: in Clojure JVM, it's possible in ClojureScript where IFn & ILookup are protocols not interfaces.
16:59zackzackzackHmmm. That puts a crimp in my style for the moment then.
16:59jlewisticking: i suppose - I'm trying to write a small program that will work regardless of whether I execute clj my-program.clj or compile it as usual and execute with java
17:01zackzackzackWhat if Element isn't a class but rather an interface?
17:02dnolenzackzackzack: still won't work. depending on what you want to do you could wrap Element in your own type that provides the interface you want.
17:04tickingjlewis afaik that should be the default, clojure is always compiled unlike python
17:07nDuff...unless you use things like gen-class (which only works with AOT compilation)
17:07tickingnDuff oh yeah right ^^
17:11CheironHi, I have a lib in .ivy2 and I want lein to pick it up. is it possible?
17:14nDuffCheiron: Short answer is "no" -- I use Gradle, not Leiningen, only on account of the lack of Ivy support.
17:14nDuff(and Gradle is really darned miserable in comparison)
17:15Cheirongradle provides the functionality of lein and allow to fetch dependency from .ivy2?
17:15nDuffNot all the functionality of lein, but it _is_ a build tool, and with the Clojuresque plugin, it can be used as a sorta-crappy-halfway substitute.
17:15RaynesYou poor people.
17:17frionyargh nDuff
17:17friowe use ant and ivy here on our java stuff
17:17CheironI see, but can for testing purposes. can I use gradle for my clojure project to fetch a dependency from .ivy2?
17:17friohuge, complex, wrong
17:17frioi feel your pain
17:20nDuffCheiron: Yes, it can be done.
17:22Cheironwhat about this? https://github.com/lrenn/vine
17:23nDuff*shrug*. Last time I looked, it didn't meet my needs -- but I don't remember why that was.
17:30solussdcould someone tell me why this code creates a bound var "groups-collection" in my repl, but not when compiling with 'lein compile'? https://www.refheap.com/paste/e13402dc488d8b458c7528e6b The last function call fails with "clojure.lang.Var$Unbound cannot be cast to clojure.lang.Named"
17:33hiredman,(doc contains?)
17:33clojurebot"([coll key]); Returns true if key is present in the given collection, otherwise returns false. Note that for numerically indexed collections like vectors and Java arrays, this tests if the numeric key is within the range of indexes. 'contains?' operates constant or logarithmic time; it will not perform a linear search for a value. See also 'some'."
17:33hiredmanthat macro is pretty horrible
17:34hiredmana. contains? doesn't work the way you think it does
17:34hiredmanb. single clause ifs
17:34hiredmanc. def's inside an if
17:34hiredmand. evaluates types multiple times
17:35hiredmane. evaluates types as a function call multiple times
17:35hiredmanetc
17:36hiredmanI would be more surprised if anything worked at all ever there
17:38hiredmanI have this absurd idea of printing it out and taking a red pen to it
17:39apwalk_reading a file in clojure, using io/file, io/reader, and line-seq; the first character is a utf-16 byte-order-mark (BOM) \uFEFF. viewing the same file in vim's hex mode, the first char is a utf-8 BOM, EF BB BF.
17:40solussdhiredman: shit.. I dont even think it works that way… I'm just being stupid. thanks, I see the bug
17:40solussdhiredman: and yeah, horrible.. it evolved that way, I'm sure it'll grow out of it. :)
17:41solussdhiredman: though, it is happening at compile-time, so… maybe I dont care if it's inefficient. :D
17:42hiredmanapwalk_: when you create a reader it will assume you want whatever the file.encoding property is unless you tell it otherwise, but I am not sure how that would effect boms
17:42piranhawhat's the right way to insert an element in a vector? I'm doing (apply conj [] (first v) item (rest v)), but this doesn't seem nice to me.
17:43hiredmandon't
17:43dnolenpiranha: vectors don't support efficient insertion. so there's not really a "right" way.
17:43piranhadnolen: ok, I see... well, I have to anyway, so I suppose I'll just use this approach
17:43nDuffpiranha: Look at how Clojure's queues work.
17:44piranhanDuff: ok
17:44apwalk_hiredman: thank you, a promising direction to look.
17:44nDuffpiranha: ...they have a list on one end, and a vector on the other, so you can efficiently modify both sides.
17:44nDuffpiranha: that kind of joint structure might be appropriate for your case.
17:45piranhaheh, well, I have to generate a data structure for a library, so I'm not sure. Anyway, I'll look at them, thanks!
17:45akhudekdo LazySeq's have the same complexity garauntees as lists?
17:45nDuffpiranha: ...I take it you're only ever inserting at the 2nd position, as in your example?
17:45piranhayes
17:45nDuffpiranha: then why not store the item in the 1st position somewhere completely different?
17:45nDuffpiranha: that frees you to use a separate, efficient-head-insertion object for position 1
17:46piranhanDuff: I'm thinking exactly about that right now :-)
17:46piranhawell, I'm thinking more along the lines that I could put nil there and just replace it in future...
17:46piranhaif I need that
17:46nDuffpiranha: What's the point of the head item anyhow?
17:46dnolenakhudek: some small things are different, you can call count on lists efficiently for example.
17:47nDuff(err, the separate, before-the-insertion-point head item)
17:47ibdknoxdnolen: as of this commit (https://github.com/clojure/clojurescript/commit/aea65a69384b05b0b79b94fdd9daee936ab68d5e) I don't get any useful return value when defining functions in cljs - is there some trick I'm missing?
17:47ibdknoxdnolen: I just get back nil now
17:47piranhanDuff: hm, well, I'm generating data for clj-pdf, and format is [:element {:styles :here} items items items]
17:47piranhaand I have to update styles after having some element
17:48nDuffpiranha: ...so that's not an insert at all, then. You can update an indexed item in a vector quite efficiently.
17:48piranhanDuff: right, I just didn't have style there at all (it's optional)
17:48dnolenibdknox: yeah sorry about that. that commit is going to get reverted.
17:48akhudekdnolen: first, next, and conj should all be O(1) though, is that correct? Sometimes I wish there were a clojure complexity cheat sheet!
17:48piranhaafter reading responses I decided that I'll just put empty map everywhere :))
17:48dnolenakhudek: someone made one I think
17:48nDuffpiranha: *nod*; that's what I'd do too.
17:49ibdknoxdnolen: ah, okidoke :)
17:49piranhathanks!
17:49ibdknoxdnolen: exciting things coming next week ;)
17:49amalloyakhudek: there's no meaningful answer to that for first/next on a lazyseq
17:49dnolenibdknox: there's been some changes to the analyzer that broke the compiler, will get the fix in by Friday and ping stuart for a release.
17:49amalloy&(time (first (lazy-seq [1 2 3])))
17:49lazybot⇒ "Elapsed time: 4.749026 msecs" 1
17:50amalloy&(time (first (lazy-seq (Thread/sleep 1000) [1 2 3])))
17:50lazybot⇒ "Elapsed time: 1024.083699 msecs" 1
17:50ibdknoxdnolen: great thanks! In fun news, Light Table is now *entirely* cljs :)
17:50dnolenibdknox: whoa really? Like Node.js on the backend?
17:51ibdknoxdnolen: yessir
17:51dnolenibdknox: craziness
17:51akhudekamalloy: of course, that makes sense as the implementation could be anything. I suppose I'm more interested in what happens with seqs produced by map
17:52ibdknoxdnolen: this next update is probably the biggest one we'll ever do. From here on out things can be much more incremental. I completely rewrote it on top of node embedded in chromium
17:52dnolenibdknox: wow
17:52amalloyakhudek: same response applies. (map #(do (Thread/sleep 1000) %) coll) is slow, other functions might be fast
17:52ibdknoxdnolen: it looks totally different now too and should be much more useful to everyone :)
17:53akhudekhm, ok, thanks.
17:56goraciodefsocket anyone :) ?
17:58dnolenakhudek: conj is O(1) for lazy seqs since you don't have to examine the lazy seq
17:58dnolenibdknox: exciting!
17:59ivanibdknox: can you just run the whole thing inside chrome with no node, using web file APIs?
18:00amalloy&(time (conj (map #(do (Thread/sleep 1000) %) (range 5)) 1))
18:00lazybot⇒ "Elapsed time: 5025.124192 msecs" (1 0 1 2 3 4)
18:00ibdknoxivan: no, though the layer that interacts with node is small enough for us to replace if we want it to be hostable in the future
18:00ivanI see
18:00amalloydnolen: for no particular reason that i can see, conj on lazy-seq calls .seq()
18:00ibdknoxivan: gotta get it useful first :)
18:01ibdknoxit's to the point now where I do all my work in it, I don't really open vim unless I manage to hork the environment doing something stupid :)
18:02dnolenamalloy: yeah we avoid that in CLJS if we have an ISeq
18:03dnolenibdknox: so building with Chromium has been positive?
18:04ibdknoxafter a lot of stumbling around I found a project that is carrying the work forward by Intel, oddly enough. The transition to this setup has been hugely beneficial.
18:04Raynesibdknox: Oh man, I'm excited.
18:04dnolenibdknox: what project?
18:04ibdknoxit'll be a real app on all the platforms, it allowed me to organize the internals much more intelligently, and removed the JVM dependency
18:05ibdknoxdnolen: https://github.com/rogerwang/node-webkit
18:05ibdknoxRaynes: new branding, the t-shirt designs, a new website, and a completely new LT :)
18:05dnolenibdknox: so a JS API for plugins?
18:05RaynesI REQUIRE THESE THINGS IMMEDIATELY
18:06ibdknoxdnolen: I need to wrap the CLJS stuff, but yep
18:06ibdknoxdnolen: with full access to node too
18:07ibdknoxdnolen: I also made some really neat discoveries on how to make an infinitely customizable runtime-self-modifiable system in a reasonable way
18:07TimMcinfinitely customizable in a reasonable way = controlled monkey patching, or what?
18:08goracioibdknox: so when update will be available ?
18:08ibdknoxnext week
18:08mpanoh nice
18:09ibdknoxTimMc: it draws from the component-entity-system model of game development
18:09ibdknoxTimMc: functionality is contained in behaviors that are given to objects
18:09dnolenibdknox: that's cool, look forward to a technical post about that.
18:09TimMcI don't know about that, so I'll wait for the blog post. :-P
18:10dnolenibdknox: I suspect there's a lot of stuff to learn from LT about building UIs w/ a FP lang
18:10dnolenibdknox: and I'm assuming a fairly simple way to build extensions with CLJS if that's desired?
18:10ibdknoxdnolen: potentially - there's still a lot for me to learn
18:11ibdknoxdnolen: yeah it's trivial to add things to LT
18:11dnolensweet!
18:12ibdknoxlearned a lot about the limits of things like jquery too lol
18:12ibdknoxI had to ditch it
18:12mpanwhat did you use instead?
18:12ibdknoxit was leaking unbelievable amounts of memory
18:12dnolenibdknox: heh
18:13ibdknoxI only have to support chromium right now, so I wrote a little jquery replacement (turns out I've been a very primitive jquery user, so this amounted to around 100 lines of cljs)
18:13brehautibdknox: one of my friends works on jscore; he has not so complementary things to say about jquery's memory usage :P
18:13ibdknoxbrehaut: I shit you not, in 1.5 min I could get it to leak 35mb
18:13ibdknoxit just wasn't meant to do what I was doing with it
18:13brehauti am entirely unsurprised
18:14ibdknoxthe problem is that it caches things rather unintelligently
18:14ibdknoxso while nodes were getting cleaned up, if an event was bound anywhere on a parent *all* children ended up cached
18:14ibdknoxunless you use jquery to remove them, they last forever
18:15ibdknoxI looked at a heap to find out after 20 minutes I had 200k nodes in memory :p
18:15dnolenibdknox: oof, via event delegation right?
18:15ibdknoxI wasn't even doing delegation :( It was normal old binding
18:16dnolenibdknox: hmm interesting. in anycase, nothing like getting rid of massive dependency w/ a hundred lines of code you actually understand.
18:17ibdknoxyeah, I wasted a day trying to figure out wtf was going on inside jquery
18:17ibdknoxthat code is a mess
18:17brehauthaha
18:17brehautthats the understatement of the day
18:17brehautim slightly horrified at the amount of code that exists in jquery to support a terrible flat namespace
18:18brehautand then try to fix the stupid that that brings
18:18ibdknoxI went from unbounded memory growth to a constant 7-15mb of total memory usage
18:18brehautnice!
18:19ibdknoxdnolen: at the conj I'd be curious to hear what it would take to make the CLJS compiler work completely on node
18:22ibdknoxfor kicks and giggles, here's the entirety of the dom lib I'm using: https://www.refheap.com/paste/6297
18:22ibdknoxbut that's all cheating, since I have the latest chromium only :)
18:23dnolenibdknox: a medium. need a CLJS LineNumberingPushbackReader, a macroexpander. Then some perf issues which may be surmountable w/ some fast path code / better datastructure - multimethod performance, PHM performance
18:23dnolena medium project I mean.
18:24dnolenoh and symbols that support metadata
18:25Bronsadnolen: https://github.com/Bronsa/blind/blob/master/src/blind/reader.clj#L11-96
18:25ibdknoxthe symbols thing you could cheat by doing some sort of lookup
18:26ibdknoxoo, look at athat
18:26ibdknoxlol
18:26dnolenBronsa: ah right, yeah I saw that. Should port that to CLJS :)
18:26Bronsashould just be a matter of s/unsynchronized-mutable/mutable
18:26ibdknoxdropping the java dep would be huge for me
18:27Bronsaoh, and replacing string method calls
18:27dnolencould really use Feature Expressions
18:31ibdknoxhiredman: wiki?
18:31spligakI have a handful of functions that all take the same first argument. Looking to provide a helper function to act as a context which would provide the initial argument automatically.
18:31hiredmanibdknox: dev.clojure.org/display/design/Feature+Expressions
18:31spligakAny particular construct I should look at?
18:32spligakDigging into macros a bit, but I feel this may be a solved problem.
18:32hiredmandnolen: idea what the path from the wiki to jira to master for feature expressions is?
18:33hiredmanany
18:33simonadameithi
18:34dnolenhiredman: continuing to bug Clojure/core? :) Stuart Halloway seems interested so that's a good sign. Perhaps collectively push to get it into 1.6.0
18:34simonadameiti have trouble understanding the state of clojure.contrib
18:34simonadameithow do i use something from contrib?
18:34hiredman~where did contrib go?
18:34clojurebotwell... it's a long story: http://dev.clojure.org/display/design/Where+Did+Clojure.Contrib+Go
18:35simonadameithiredman: thanks
18:36dnolenhiredman: if anything Clojure/core should be very interested in it as their building a lot of CLJS projects these days - sharing code between Clojure / CLJS is ridiculous
18:38hiredmanyou mean "relevance, who has a бизнес relationship (employee, partner, consulting) with a large portion of clojure/core is building a lot of cljs projects these days" ?
18:38dnolenhiredman: right
18:41caspercIs there any way to find out if a record implements a given method?
18:45nDuffcasperc: see satisfies?
18:45nDuff(for the protocol the method is part of)
18:46dnolenbe warned that satisfies? is insanely slow on types that don't acutally satisfy the protocol.
18:46dnolenin Clojure, not CLJS
18:46dnolensorry I mean instances of types
18:47caspercah thanks, that might be it
18:47nDuffcasperc: What's the use case? Might make more sense to provide a default implementation for Object that returns nil or such.
18:48ibdknoxwhat would people be most interested in hearing about for my talk at the Conj?
18:49dnolennDuff: an Object implementation is the way to provide a default.
18:49caspercI just want to avoid an exception when calling a method which might not be implemented, but come to think of it I might want to split it up into more protocols to avoid this problem
18:49dnolencasperc: good idea
18:50simonadameitis there a way to reevaluate the classpath in a running lein repl?
18:50simonadameiti added a new dependency and dont want to close my repl
18:50dnolenibdknox: I'm curious about the CLJS architecture, but it might be good to talk about how compelling it would be to have a self hosted CLJS too.
18:50technomancysimonadameit: you can do it if you have pomegranate loaded, but it's not well-supported
18:51dnolenibdknox: for me self-hosting isn't about running complete Clojure environment in the browser, rather a way to get Clojure running self-hosted in environments where JVM is just too big / heavy
18:52magius_pendragonhey everyone, I've just recently started playing with clojure. I read through the tutorial and have been working through tutorials for jmonkeyengine. On the latest one though, I'm getting a class not found error on the namespace. The first line of the file is the ns macro, with the name of the namespace... the file is named after the last bit, and the namespace appears in my project.clj file. Any ideas what I'm missing?
18:52ibdknoxdnolen: yeah I don't care about eval in this case
18:52lynaghkibdknox: I'd be interested in hearing about architectural patterns you've used to scale up a cljs codebase
18:52ibdknoxdnolen: I mean that would be nice, but whatever
18:52dnolenlynaghk: +1
18:53ibdknoxdnolen: but the idea that I could compile my cljs from this node process means I wouldn't need crazy interprocess communication just to modify the thing
18:53technomancymagius_pendragon: namespaces usually don't match artifact names from project.clj
18:53ibdknoxlynaghk: interestingly I think I've created a cljs app platform by accident :)
18:54magius_pendragontechnomancy: Erm, maybe I didn't describe it right? The namespace matches the :main directive in the project file
18:55lynaghkibdknox: yeah, I've done that two or three times myself =P
18:55magius_pendragontechnomancy: I've been using the same project for various tutorials, each of which has it's own main. I've just been swapping out which one I passed to :main. It worked for the first 2, but the third one's messing up.
18:55technomancymagius_pendragon: just ignore :main for now while you try to get it working in the repl
18:55hiredmanmagius_pendragon: dashes or underscores in the namespace name?
18:56magius_pendragonhiredman: dashes
18:56hiredmanmagius_pendragon: and dashes in the file name?
18:56magius_pendragonhiredman: yes
18:56hiredman~filename
18:56clojurebotyour filename should match your namespace declaration, but with - channged to _ e.g. (ns foo.bar-baz) => foo/bar_baz.clj
18:57magius_pendragonhiredman: that accidently matches :p
18:57hiredman~accident
18:57clojurebotExcuse me?
18:58technomancy~the ns macro
18:58clojurebot(def transpose (partial apply map vector))
18:58technomancyboo
18:58technomancymagius_pendragon: probably worth reading this too: http://blog.8thlight.com/colin-jones/2010/12/05/clojure-libs-and-namespaces-require-use-import-and-ns.html
18:58simonadameittechnomancy: thanks
18:59magius_pendragonlol to clarify: When I started, I named the project hello_jme3 not thinking about the - vs _. The ns currently in question is hello-jme3.assets, and in src/hello_jme3 there's a file called assets.clj
18:59magius_pendragonand I'm getting a class not found on hello-jme3.assets
19:01hiredmanmagius_pendragon: well there you go
19:01magius_pendragonhiredman: ?
19:01hiredmanhello_jme3.assets will be the class name (asusming you are gen-classing)
19:02magius_pendragon... it's worked for all the other ones? and didn't the bot just say to replace - with _ in filenames?
19:03hiredmanmagius_pendragon: hard is really hard to say without more info (a pastebin of your code)
19:03magius_pendragonyeah, was just about to do that
19:04hiredmanmagius_pendragon: you don't get a class with the name of your namespace unless you ask for one
19:05hiredmangive the class not found exception, it seems like you are expecting to have such a class somewhere
19:05hiredmangiven
19:06magius_pendragonsource file: http://paste.lisp.org/display/133470 project.clj: http://paste.lisp.org/display/133471
19:07hiredmanshould be -main not main-
19:07wei_what's the best way to get a timestamp in clojurescript? new Date().getTime()?
19:07hiredmancan you pastebin the exact exception you are getting?
19:07mpanWhat's a strategy for writing something that would ordinarily be recursive (not necessarily tail position, could be multiple sub-calls) but would exceed allowable stack depth?
19:08hiredmanmy guess is it isn't actually about the class being missing, but about the class not having a main method
19:08magius_pendragonhiredman: that fixed that issue, and threw another one.
19:09magius_pendragonso yeah, pay more attention to that next time
19:09wei_to answer my above question, (.getTime (js/Date.)) seems to work.
19:09magius_pendragonmpan: can always make it tail recursive. Don't know if that's standard though.
19:09hiredmanyou really should also always include (:gen-class) in the ns form for the :main namespace if you are launching via java
19:10mpanmagius_pendragon: short of playing a human compiler?
19:10magius_pendragonhiredman: umm... I'm launching via lein run. Is that launching via java?
19:10hiredmanmagius_pendragon: no, so no reason there
19:10magius_pendragonmpan: I just started learning yesterday ;) was just the first thing that came to mind. Will shut now :)
19:10lynaghkIs it possible to have ring/compojure reject POSTs larger than a certain size?
19:11mpanmagius_pendragon: your suggestion is a good on (in the sense of effectiveness) but not one I would enjoy (in the sense of human burden)
19:11mpangood one*
19:11magius_pendragonmpan: yeah, figured as much. It's a pain
19:11hiredmanmpan: it sort of depends what you are doing, if it is tree shaped you can turn it in to a lazy seq and then walk the lazy seq
19:11mpanuh, ok concrete example: depth first search of a graph
19:12mpanyou could impose a tree-shape over it, I suppose
19:12hiredmanoh yeah, definitely
19:12magius_pendragonmpan: acyclic?
19:12mpansuppose not
19:12magius_pendragonmpan: graph is only a tree if it's acyclic. But in either case, you can actually throw away the stack in DFS if you don't mind possibly infinite searches on cyclic graphs
19:13mpanuh, I meant to say, for the general graph, you just need to hit all the nodes so you could traverse an acyclic overlay
19:13hiredmanwhat you do is make the search return a lazy seq
19:14hiredmanso if you are at node X with children a b c, the result of searching X is (concat (search a) (search b) (search c))
19:14Apage43if it's a tree, and you're going depth first tree-seq already has you covered
19:14mpanhiredman: that feels like manual stack-keeping :/
19:15magius_pendragonmpan: hiredman's solution isn't, though I was about to propose manual stack :p
19:15mpanit isn't, but -- and I'm not sure how to explain -- it has that feel as if it was
19:15hiredmanmpan: actually it is manual list monading
19:16mpanI guess the property of recursion that I like and would like to maintain is: it allows you to reason extremely locally and defer the rest
19:17mpanwhich the lazy seq way is, but then I'm not sure what about it I feel uncomfortable with
19:17magius_pendragonmpan: you could do CPS instead
19:17magius_pendragonif that feels more recursive to you
19:17mpanthat would be the answer I'm scared of
19:17magius_pendragonlol
19:18mpanI only began to understand it the other day and I'm so uncomfortable around it
19:18hiredmanI have a very naive datalog https://github.com/hiredman/datalog/blob/master/src/datalog/core.clj which does search like this, it is also how (in a more sophisticated incarnation) core.logic does searching
19:19mpannot sure search was quite the right example though
19:20magius_pendragonsearch is a fine example if it's what you're working on...
19:20magius_pendragonless good if it isn't
19:20mpanno I mean in the sense of
19:20mpanmaybe I said the wrong example
19:20mpanthere's a certain property of problems I'm trying to capture like
19:20mpanyou don't know now where you need to go later
19:21mpanmaybe somewhere midway, you change to one of some number of strategies, depending on what you see there
19:21hiredmansure
19:21mpanor is that a good candidate for transforming into a tail-recursive "iteration" with explicit state passing?
19:22magius_pendragonmpan: depends on the strategies
19:22hiredmansounds a lot like core.logic
19:22mpanlooking that up at the moment
19:23hiredman(or datalog)
19:23hiredmanI don't mean it sounds like a problem you would solve with core.logic, it sounds like the implementation of core.logic
19:23magius_pendragonmpan: if your strategy is really simple (like dfs) manual state-passing or manual tail-call via cps is not terrible. hiredman's solution works well either way, since it just generates the DFS traversal, and then you iterate over that and pick out whatever you need.
19:24hiredmanhttp://www.clojure.net/2012/03/26/Messin-with-core.logic/ might be a good read
19:24magius_pendragonhiredman: though, come to think of it, lazy list approach might break down in the case of infinite loops, since you'd never get to the rest of the list...
19:25magius_pendragonthough, that's more of a problem with DFS than it is with the lazy list approach
19:25hiredman"Combining these three components in the proper way you get an engine that searches a space shaped like a tree."
19:25mpanuh, maybe an example of the sort of problem I'm asking about is
19:25mpanimagine you wanted to find an element of pascal's triangle but memoization didn't exist
19:25hiredmanmagius_pendragon: there are different ways to deal with that
19:25magius_pendragonhiredman: yeah, such as don't use DFS :P
19:26hiredmanmpan: I seem to recall there just being a nice formula you can use
19:26hiredmanforget searching anything
19:26magius_pendragonmpan: yeah, pascals triangle is just the binomial coefficient formulae
19:26mpanI'm trying to come up with a small example and admittedly it is contrived
19:26mpanso we would need to pretend all the reasonably efficient shortcuts didn't exist
19:27mpanI'm sorry. I don't know a better example
19:27mpanlike the property I'm trying to capture is: the call-graph branches, and it does so potentially depending on what it sees currently
19:28magius_pendragonooh static analysis
19:28magius_pendragonare you trying to build the call graph dynamically, or do you already ahve it?
19:28hiredmanmpan: a branch is just an (if ...), you can put them whereever you like
19:29magius_pendragonoh wow, totally reading the wrong way into that
19:29magius_pendragonoops
19:29mpansorry, I meant to say: the program is recursive in such a way that, if you examined its call graph, it branches profusely and makes local decisions
19:30magius_pendragonmpan: actually reminds me more of A* at the moment than anything else
19:30mpanlike, the function has some number of cases, most of which are compound expressions of multiple recursive calls
19:30magius_pendragonhm
19:30mpanmagius_pendragon: yea, I think that's an example
19:30magius_pendragonnot anymore
19:31magius_pendragonmpan: A* uses a heuristic to get around compond expressions of recursive calls :p
19:31mpanhiredman: what I meant to say about the branching is just that, prior to examining a node, you don't know which set of recursive calls you need
19:32hiredmanmpan: sure, no problem
19:32hiredmanyou search function does case analysis on each node and can do whatever
19:32hiredmanyour
19:33magius_pendragonhiredman: if he's not doing search, that just became a lot trickier to do
19:33mpanimperatively, there would be some per-node accumulation
19:33hiredmanmagius_pendragon: not really, either way you traverse nodes
19:34mpanso you don't know what "search b" should do until you're fully done with "search a", and in that sense perhaps it isn't really search
19:34mpanand "search b" in the imperative version has the results/intermediates of "search a"
19:34magius_pendragonhiredman: how's mutual recursion handled in clojure? or isn't it?
19:34hiredmanmpan: right, so that is impossible to do lazily then, but not significantly different
19:35hiredmanmagius_pendragon: depends what you want
19:35mpanmagius_pendragon: the tail position case you can use trampolines
19:35magius_pendragonhiredman: well, I was just thinking mpan's case started sounding like mutual recursion
19:35hiredmanit is
19:36magius_pendragoncuz i've run into that sort of setup doing an interpreter
19:36hiredmanand my datalog impl I pasted does that too
19:36mpanthat's a really interesting way to think about it
19:36magius_pendragonmpan: which?
19:36mpanyea, I think it definitely can be re-expressed as mutual recursion
19:37mpanor, well, extending mutual recursion to multiple calls
19:37magius_pendragonmpan: you're the one whos aid search a needed search b :p
19:37hiredman(let [ar (search a) br (search b ar) cr (search c ar br)] (concat ar br cr))
19:37mpanI fear I'm misusing terminology again :(
19:38magius_pendragonmpan: well, I think I follow you, so if you're misuing terms we're both lost
19:38mpanwow, some day a future employer is going to run across these logs, and I am going to be so embarrassed
19:40mpanI'm trying to construct a small-enough example
19:42mpanhttps://www.refheap.com/paste/6302
19:42mpanI think that's a small example of the sort of program I'm wondering about
19:43mpansuppose the call stack would overflow evaluating it like that
19:43magius_pendragonmpan: well, that example's broken
19:43magius_pendragonsince (f x) will call (f x) if (q? x)
19:43magius_pendragonand infinitely recurse
19:44magius_pendragonon the same element
19:44mpansorry I broke it in multiple places
19:44mpanhttps://www.refheap.com/paste/6303 fixed, I hope
19:48mpanthe things I wanted to make the example have were: multiple control paths depending on state and multiple recursive calls in a given path
19:49mpanand in some sense, x is the (potentially arbitrary) accumulator of info about what has been seen so far
19:50mpanbut also x contains the (potentially arbitrary) info about what's left to "work" with, for whatever "work" something of this form might need to do
19:56dnolenmpan: as hiredman said, does sounds a bit like a logic programming framework - something prolog / datalog like seems well suited for this kind approach to solving problems.
19:57mpanThose are quite new to me. I will look into them.
19:58mpanThank you guys so much for bearing with me while I figured out the properties of what I was trying to express! Thank you all so much for your help!
19:59magius_pendragonI'm out, thanks hiredman
20:05tomojconsider a macro which accepts a fn body. is it possible to correctly resolve all symbols in the body with respect to the namespace in which the macro is called?
20:05tomojwithout macroexpand-all and a special form walker
20:06hyPiRion,`(~'+ 1 2)
20:07clojurebot(+ 1 2)
20:07hyPiRionOr do you want to inject a specific body?
20:07hyPiRionLike, the macro takes in a body, and spits out a result.
20:10tomojhttps://www.refheap.com/paste/beafe1fe33732526f5616f3f7
20:11meredyddHey, could someone suggest why I'm getting "Attempting to call unbound fn" errors when I AOT compile my code
20:11meredyddbut it's OK if I start it pointing at the .clj on the command-line?
20:11nDuffmeredydd: Have a reproducer?
20:12meredyddSadly not yet, nduff
20:12meredyddWanted to check whether it was a known issue before I start bisecting away my entire damn codebase.
20:13hyPiRiontomoj: Humm
20:13tomojI have a macro that defines a datomic db fn, automatically pulling in the current ns's requires/imports. but if you want to call a fn in the current ns, you have to fully qualify
20:13hyPiRion,((let [bar :foo] (bound-fn [] bar)))
20:13clojurebot:foo
20:13amalloyyou're probably attempting to call clojure functions from java without initializing the clojure runtime, meredydd
20:14hyPiRionWait, that's not correct.
20:14hiredmantomoj: I have a macro impl of syntax quote that does something like that
20:14tomojoh, sweet
20:14tomojfor query as well?
20:14tomojer, dunno if you're using it for datomic
20:14hiredmanhttps://github.com/hiredman/syntax-quote/blob/master/src/syntax_quote/core.clj
20:19tomojseems like you have to gensym to avoid resolution?
20:19tomojwhich makes sense, not sure what I want is even possible
20:21tomoj&'./foo
20:21lazybot⇒ ./foo
20:24hiredmantomoj: you could do something more complicated in the same general shape
20:24meredyddamalloy, nope - that's got a call trace straight back from the .clj file specified by lein's :main parameter
20:25hiredmantomoj: e.g. if resolve doesn't return anything from the current ns, assume it is a local
20:25tomojyeah, for example I think it would be nice to take that and make it not resolve variables in datomic queries
20:25meredyddI am, however, belatedly realising that 'lein clean; lein run' might be a good first step. It's taking a while.
20:26hiredmanor something more syntax aware that knows where rvalues appear
20:27hiredmanwhich quickly moves in to static analysis
20:27tomojyeah :(
20:32meredyddOh, interesting.
20:32meredyddOK, new problem.
20:33meredyddI forward-refer variables from another namespace
20:33hiredmandon't do that
20:34meredydd(ns my-namespace) ... (ns other-namespace) (def some-var) (ns back-to-my-ns) (refer 'other-namespace : only 'some-var)
20:34meredyddAll right, what's the Approved Way To Do It?
20:34amalloydefine namespaces that aren't circular
20:34hiredmandon't do that
20:35meredyddHelpful, hiredman.
20:35meredyddamalloy, what's the recommended pattern when you want a circular call graph?
20:36meredyddDo I need to have static start-up code throw fn pointers into the ns? Cause that just feels nasty.
20:37amalloyyou can either put them in the same namespace, with a declare or a letfn, or you can add some layer of indirection
20:37amalloyeg to have a->b->a, you can add an extra "what to call" arg to b, and have a pass itself
20:37hiredmanyou can have any shape call graph you want, but namespaces are a tree
20:38meredyddIck.
20:40tomojI guess it would be cool if there were an analogue to ::foo for symbols
20:40meredyddtomoj, isn't that what ` does?
20:40tomojnot really
20:41tomojI don't want it quoted, just resolved
20:42amalloytomoj: i think ::foo already causes enough problems, doesn't it? by coupling the reading of forms with their evaluation
20:43hiredmanamalloy: huh?
20:43tomojyeah I can see that
20:43hiredmantomoj: what is different about how :: works for keywords and ` works for symbols?
20:44amalloyhiredman: you can't read the string ::foo into a keyword reliably (ie, always get the same result). relatedly, ::foo/bar has caused actual problems for static analyzers that try to read your code; they can't read it without evaluating it
20:44tomoj&(map read-string ["::+" "`+"])
20:44lazybot⇒ (:sandbox7657/+ (quote clojure.core/+))
20:45hiredmanamalloy: that is not truee ::foo/bar can be read without evaluating ::foo/bar, but you need to know the read environment as setup by the ns form to resolve it properly
20:45tomoj&(read-string "::foo/bar")
20:45lazybotjava.lang.RuntimeException: Invalid token: ::foo/bar
20:46amalloyhiredman: perhaps i was unclear. you're right that, to read x, you don't need to eval x. but you might need to eval y (the ns form) first
20:46hiredmantomoj: I see, current ns vs. resolve
20:46tomojwell, that's not important to me
20:46tomojjust that there's a quote on the right
20:46tomoj(there might as well be one on the left since for keywords it doesn't matter, but..)
20:46amalloyso you can't read all of a project's code without evaling at least some of it
20:47tomojI don't actually think it's a good idea to add something to the reader to address my problem :)
20:47hiredmanamalloy: unless you have have an analyzer for ns forms, and they only manipulate namespaces via ns forms
20:47amalloysure. obviously there's nothing magic about eval, and you could write all the pieces of it you need to
20:48leonardoborgeshey guys! :) anyone using quil?
20:48amalloybut every other readable clojure construct (i think? barring reader tags anyway) can be read from a string without knowing anything else about the program
20:48hiredmanthat is part of the reason ns exists, and why it should be used in preference to putting in-ns, require, use, etc where ever
20:49hiredmanns is forms are easier to deal with statically without walking over all the code and evaluating it
20:49leonardoborgesI got a handler in :mouse-clicked that calls (no-loop) if an atom called 'running' is true. If it's false, it tries to call (start-loop). Problem is, once (no-loop) is called, the mouse handler never gets triggered again.
20:49hiredmana nice declarative style
20:52amalloyactually didn't reader tags get a default reader recently?
20:53tomojyep :)
20:53bbloomamalloy: yeah http://dev.clojure.org/jira/browse/CLJ-927
20:59meredyddI'm still getting my head around the namespace-DAG thing. Could someone give me a hand by explaining how, for example, one would go about implementing an MVC-type application with an interactive view (eg Swing)?
20:59meredyddThe view needs to pull levers on the controller (eg on button-push), and the controller needs to pull levers on the view (eg new data to display)
21:00meredydd(and by "would" I mean "should, idiomatically")
21:00Apage43Extract the levers
21:01meredyddAnd do what with them, Apage43 ?
21:02meredyddHave an atom in, say, the view, that holds a map of levers for the controller?
21:02Apage43put them together in a third, unrelated place
21:03Apage43you have your view, and your controller, and a third guy "app definition" that says, here's my view, here's my controller, let me pull out some stuff from each and stick 'em in the right places on the other
21:03meredyddright
21:03Apage43things being callbacks or something of the sort
21:03meredyddBut what form should that "sticking them in" take?
21:03meredyddAtoms? Mutating top-level values of vars?
21:03Apage43well for a thing that's displaying data, an atom isn't bad
21:04meredyddI feel like there's something I'm not getting here...
21:04meredyddAn atom to hold the function?
21:04Apage43the data.
21:04meredyddThat's not the problem.
21:05Apage43you can ask atoms to call a fn when they change
21:05meredyddalthough actually, that could be sticky too
21:06meredydda) The view is going to want to perform actions that aren't entirely expressible by changing the value of an atom
21:06meredyddb) How do you inject the atoms in the first place?
21:06meredyddEven if using atoms is OK, the "app definition" still has to tell the controller "modify this atom" and the view "display this atom"
21:06meredyddafter they've loaded
21:07meredyddwhich means modifying some state inside them, yes?
21:07meredyddHow do you represent *that* state (which isn't really state, except during start-up) neatly?
21:07Apage43you could pass the atom to the view and controller's "constructors"
21:07meredyddYes, and what do those "constructors" do?
21:08Apage43I don't know
21:08meredyddDamn, because that's what I don't know either.
21:08Apage43I mean, they're your doohickeys.
21:08meredyddyes, yes
21:09meredyddBut fundamentally, they've just been given the atom they need to push new values to.
21:09meredyddWhere do they put it?
21:09meredyddSsay I'm the controller, and the app-initialiser has just called my constructor, with the atom I should update to call the view.
21:10meredyddsorry. With the atom I should update in order to update the view.
21:10meredyddWhat do I do with it? Do I change the top-level value of a var (ew)?
21:10meredyddDo I have an atom to store the atom (ew)?
21:10Apage43well what is the thing your constructor is making
21:10meredyddThis is the part I'm not getting.
21:10Apage43I mean, say it's a button
21:10meredyddWell, it's a "view".
21:11Apage43well you were talking about controllers just now
21:11meredyddOh, sorry, yes.
21:11Apage43(fn make-button-thingy [counter-atom] (proxy [ButtonClass] [] (onClicked [] (swap! counter-atom inc))))
21:12Apage43I don't remember swing
21:12meredyddeh, that's all right.
21:12Apage43so that's a pretend guy
21:12meredyddI get what you're saying.
21:14meredyddFundamentally, it sounds like what you're saying is "write all your code that might need to use another component inside a constructor function that's wired together by a third party"
21:14meredyddAccurate summary? Or not getting it?
21:15bbloommeredydd: GUIs are an area where all the viable toolkits are fundamentally object oriented
21:15Apage43Yeah, I think so. More generally the idea is that the things that are actually "components" should really need to know about each other, at least, concretely, and that you build a system by composing them.
21:16Apage43s/really need to/not really need to
21:16Apage43I accidentally a word
21:16bbloommeredydd: you just kinda need to suck it up and deal with state, unless you've got time to invest into an open research problem of alternate GUI approachs
21:17amalloybbloom: i don't think that's the question he's asking at all. also, functional reactive GUIs?
21:17meredyddApage43, Yeah, I get that ideal
21:17bbloomamalloy: they are discussing where to put their mutable state... sadly, the answer is "everywhere"
21:18meredyddApage43: and it's a nice ideal, but one that, as I understand it, doesn't play nice with (eg) MVC, or anything where components have a peer relationship
21:18amalloyno they're not. they're discussing how to get two things to talk to each other circularly
21:18gilliepitworking through a partial args problem, looking for a sanity check on this: https://gist.github.com/3990998 -- I feel like I might be able to break this down into a macro, but is this at all the right approach?
21:18amalloythey've sidetracked a little into deciding they need a hundred atoms, which i think is wrong, but it's not the central point
21:18bbloomheh
21:19meredyddamalloy, Oh please, save me from the "hundred atoms", because I really don't want that to be the answer.
21:20Frozenlo`How could I get only "json" from this?: (re-find #"\.(.+)$" "word.json") --> [".json" "json"]
21:20meredyddThe atom thing was really a distraction, anyway. I'm actually having that problem with functions
21:21Frozenlo`I want to get the extansion, not the dot with it.
21:21meredyddEg the email interface to this system needs to be called by the controller (when things happen that need email notifications) and call the controller (when new emails come in and require an action)
21:21WuHoUnitedis there any god way in clojure to indicate that a parameter to a function MUST implement a protocol? Is the best option to use preconditions, or does the idea in general run counter to clojure
21:22gfredericksdocstring for documentation
21:22amalloymeredydd: for one thing that's not really true; the model could be a function that returns a blocking lazy sequence of changes, and the controller blocks waiting for it
21:22meredyddFrozenlo`: (let [[_ extension] (re-matches #".*\.(.+)" "word.json")] extension) should do it
21:22gfrederickspreconditions if you want checks
21:23WuHoUnitedtype hints aren't actually enforced right?
21:23meredyddamalloy, Fair enough, although this is an event-driven system so this will require some abuse of the events to turn them into "wake up a thread" events, and that would introduce a sequential bottleneck, and and and...
21:24tomojevent-driven seems pretty hopeless in clojure right now
21:24Frozenlo`meredydd: I find it weird... there's no way to make a regexp and select only a part of it?
21:25meredyddamalloy, I'm not above things like taking incoming events and putting them into a queue that will wake up a listener. If that will produce a good design, I'm interested.
21:25meredydd(And I can see how that looks more functional on the other end - although it rapidly becomes imperative again when it spits an email-shaped event out the other side, but I can live with that.)
21:25amalloyi'm not really an expert in events or mvc, in clojure or any language
21:26amalloybut for example you can (defn controller [state] (fn [model] ...)) (defn model [state] (fn [controller] ...))
21:26meredyddFrozenlo`, There is - these functions effectively return multiple values, and you can pick out the bits you want.
21:28meredyddamalloy, yep. That's the approach I was trying to summarise when I said "write all your code that might need to use another component inside a constructor function that's wired together by a third party"
21:30meredyddAnd it looks like that might be the way to go. Still feels like a lot of effort, but might be livable with.
21:47bbloomit's been a while since i wrote some ruby and ran into a damn-near-un-debuggable usage of method_missing or const_missing
21:48bbloomnow i'm reading through some weird javascript that uses getters and setters with the get and set keywords
21:48bbloomholy hell is it impossible to debug this thing!
21:48bbloomfunctions that look like mutable fields! i want to cry
22:00gfredericksbbloom: oh I was so disturbed when I heard those were added
22:00gfredericksclojurescript came just in time
22:07mattmossI guess this isn't as bad as I thought, but... https://gist.github.com/3991188
22:07mattmossWondering if there is a more succinct way to express that.
22:12tomoj&(keep (fn [[a b]] (if (even? b) a)) (map vector [1 2 3] [4 5 6]))
22:12lazybot⇒ (1 3)
22:12tomojit's too bad keep doesn't have variable arity
22:13tomojthen it could be (keep #(if (even? %2) %1) [1 2 3] [4 5 6])
22:13amalloyunless one of the elements of a is nil :P
22:14amalloyanyway, another solution: (for [[a b] (map list as bs) :when b] a)
22:15tomojoya
22:16mattmossWell, in my case, a will never have nil, but good concern in general.
22:18mattmoss&(for [[a b] (map list '(1 2 3) '(:a :b :c)) :when (even? a)] b)
22:18lazybot⇒ (:b)
22:25mattmoss&(map #(when %1 %2) (map even? (range 5)) (:a :b :c :d :e))
22:25lazybotjava.lang.IllegalArgumentException: Wrong number of args passed to keyword: :a
22:25mattmoss&(map #(when %1 %2) (map even? (range 5)) '(:a :b :c :d :e))
22:25lazybot⇒ (:a nil :c nil :e)
22:26mattmoss&(keep #(when %1 %2) (map even? (range 5)) '(:a :b :c :d :e))
22:26lazybotclojure.lang.ArityException: Wrong number of args (3) passed to: core$keep
22:26mattmossoh, ah, variable arity thing