#clojure logs

2012-06-22

01:47SrPxCan I use a clojure program as a clojurescript program without any modification?
01:48bbloomSrPx: sometimes
01:48bbloomSrPx: clojurescript is not a strict subset of clojure
01:48bbloomSrPx: for example, clojurescript does not have it's own macro system, it uses clojure's
01:48SrPxhm
01:48bbloommostly up to date: https://github.com/clojure/clojurescript/wiki/Differences-from-Clojure
01:49SrPxgood, thanks
02:37Shambles_What is the significance of this "core" I see appended everywhere? I originally thought it was just for things built into Clojure, but Leiningen projects create files with that suffix automatically, and I see them in some other projects.
02:38amalloyShambles_: single-segment namespaces are not allowed (or, at any rate, are a very poor idea) for reasons that are somewhat complicated; "core" most of the time means "i couldn't think of a clever second segment"
02:38borkdudecore, main, default, etc
02:38Shambles_amalloy: I see. That helps me understand.
02:39amalloyit's often the main "entry point" or exposed-api namespace of an application/library, as well
02:39Shambles_I would have expected something like "main".
02:39borkdudeamalloy the directory structure <-> namespace naming, is that something dictated by clojure or leiningen?
02:40amalloythat implies executibility, Shambles_
02:40amalloyborkdude: clojure (and also java, sorta)
02:40amalloy(require 'x.y.z) looks on the classpath for a file named z.clj located in /x/y
02:41Shambles_amalloy: I see.
03:18tsdhWhy won't the second sequence comprehension terminate in http://pastebin.com/aDHY3XEK ?
03:19tsdhThe placement of the :while test shouldn't make a difference here, right?
03:24hiredmantsdh: for every x you are iterating over y and z, and y and y are infinite
03:24hiredmanerr
03:24hiredmany and z
03:25tsdhhiredman: No, (range 10) ends at 9.
03:25hiredmanoh, right
03:26hiredmanthe it is the placement of the :while
03:27tsdhYes, but it shouldn't make a difference here, does it?
03:27hiredmanfor every element of infinite sequence bound to x, create a sequence whose element is bound to y, …
03:27hiredmanvs.
03:27hiredmanfor every element of infinite sequence bound to x, while x is less then 10, create a sequence whose element is bound to y, …
03:28hiredmanthe creates a infinite sequence of y's before the while kicks in
03:30tsdhHm, well, I somehow agree. But creating an infinite seq is nothing that would block with lazyness.
03:32tsdhI mean, the :while/:when should be tested in every iteration anywap.
03:51amalloytsdh: that :while is only tested when "choosing" a new y
03:51amalloyand only terminates the inner-most (immediately preceding) iteration, in this case the ys
03:52amalloyso xs continue to grow without bound, and zillions of ys are created, each finding that the x you started with is invalid. so that y is discarded, and a new x is tried
03:53tsdhamalloy: Ah, ok, that makes sense. I've thought :while would terminate the complete for.
03:53amalloyi've thought that too, but no
03:54tsdhBut does that make sense? I mean, there's nothing more for can compute if any seq is exhausted.
03:54amalloynonsense
03:54winkanyone on EC2? Could it be that I lost an Elastic IP because it wasn't associated for 24h?
03:55amalloy&(for [xs [[1 2 3] [] [4 5 6]], x xs] x)
03:55lazybot⇒ (1 2 3 4 5 6)
03:55tsdhamalloy: Oh, yes, sure.
04:02bartjis there any way I can associate a function/protocol to a defrecord ?
04:04tsdhbartj: (defrecord Foo [x y] BarProtocol (bar [this] ...)) ?
04:04tsdhbartj: Or what do you mean with "associate"?
04:04bartjI mean like in Java classes/interfaces
04:05bartjI *know* that this is not a functional way to think...
04:06bartjI would like to write a couple of functions that work on a defrecord
04:06tsdhThen define a protocol with the desired signatures, and provide implementation in your (defrecord ...) form.
04:08bartjtsdh, I thought defrecord only allowed attributes
04:09tsdhNo, check (this silly) example: http://clojuredocs.org/clojure_core/clojure.core/defrecord#example_748
04:11bartjtsdh, cool, thanks!
04:11tsdhbartj: You're welcome. And happy "drinky-drinky" ;-)
04:12bartjone last thing
04:13bartjhow is it possible for a defrecord to contain a vector of a other defrecord ?
04:14bartjexample maybe a zoo containing multiple animals
04:14tsdhSure
04:14bartj(defrecord Zoo [Animal])
04:14bartjwould be like a single animal in the Zoo :)
04:15tsdhbartj: Only implied by the name. (->Zoo [:tiger :snake :pengin]) is a zoo with three animals (happening to be keywords)
04:17amalloybartj: if you want to write a couple functions that work on a defrecord, then...write a couple functions that operate on a defrecord. there's no need to have them be a "part" of that record type with a protocol, interface, or whatever
04:18amalloy(defn count-animals [zoo] (count (:animals zoo)))
04:18the-kennyAre namespace-qualified keywords broken in ClojureScript?
04:18the-kenny(Those starting with :: in the code)
04:19tsdhamalloy, bartj: Unless you are going to have a record per species and the functions act differently depending on an animal's type.
04:19tsdhs/record /record type /
04:19bartjamalloy, ok
04:20amalloy*shrug* polymorphism is a separate concern, which you can address with multimethods or, indeed, protocols. but if he just wants some functions, that's why rich gave us defn
04:20bartjbut, like tsdh says, the functions act differently based on the animal's type
04:21bartjso I thought it would be best to couple the defprotocol to the defrecord
04:24amalloythere's nothing wrong with that. but starting with maps and multimethods is an easier, more flexible way to get polymorphism; defrecords are often used (even by me) as just a way to pretend you're still doing OOP
04:25bartjok, thank you amalloy and tsdh for your inputs, much valued
04:25amalloy(defn zebra [num-stripes] {:type :zebra, :stripes num-stripes}) (defmulti coolness-factor :type) (defmethod coolness-factor :zebra [zebra] (:num-stripes zebra))
07:50clangeI'm trying to read in binary data from a file using Gloss:
07:50clange(def buffer (byte-array 8)) (.read (input-stream "/home/clange/workspace/first-clj/data/fid") buffer) (decode-all fid-codec buffer)
07:50clangeThe result is vastly negative, but I presume from known data, it should be around zero.
07:51clangeHow can I handle different endianness w/ Gloss (or any other means)?
07:51cshellyou shouldn't use def there, but rather let
07:52cshellie. (let [buffer (byte-array 8)] (.read ....))
07:52cshelldoesn't the jvm handle endianness for you?
07:55clangeOh, I see w/ 'let' ...
07:56clangeI wouldn't think jvm _could_ handle endianness, because I just have an array of bytes whose endianness was defined by the author of the file writing software.
07:57clangeAnd now I define codec w/ gloss ... oh, just a moment! I forgot to send the codec-defining gloss line:
07:58clangedefcodec fid-codec :int32)
07:58clangeBut how could gloos or the jvm know about the endianness of the data read?
07:58clanges/gloos/gloss/
07:58cshellMy understanding is that that is a hardware thing
08:00cshellah if you're using a byte array then probably not - but if you had a file of integers or strings, you wouldn't worry about endianness
08:00clangeRight. And that's why I have to be able to change endianness in decoding data from a file, in case it was produced on a diffently endian hardware (or: "system" in general)
08:01clangeI do have a file of bytes, where each four bytes comprise one integer ...
08:03cshellnot sure, but i've never had to worry about byte order when reading in a file - maybe I've only worked with the same endian machines, but they've been a variety from sun, linux, ms
08:07borkdudewhat reasons do hardware designers have to choose big endian over little endian or the other way around - why not always the same?
08:11cshellunless those defs are outside of a function, you shouldn't be using def, use let instead or it will slow you down
08:12borkdudecshell a common thing that my students did when they first learned clojure
08:13borkdudecshell the expressions clange showed are all outside a function though
08:14clangeYes, they are, since I'm only testing. But they'll surely end up in functions, and then your remarks will be of great use. THX.
08:20borkdudemore coffee!
08:22foxdonutborkdude: what roast? milk, sugar, or black?
08:23foxdonut<-- medium roast, black
08:31borkdudefoxdonut espresso, black, a little sugar
08:35foxdonutborkdude: an espresso man, huh-- nice! do you use a machine, or one of those little things you put on the stovetop that makes the water shoot up through the coffee and into the receptacle?
08:37borkdudefoxdonut I have a machine -- I use these beans btw: http://www.italybymail.com/item_list/coffee/segafreda_espresso_casa_beans.html
08:38borkdudefoxdonut they are not as expensive here as on that website though
08:42ro_stsorry to interrupt an important conversation, but what's the correct way to read values out of the env?
08:42ro_stSystem.getProperty?
08:42foxdonutro_st: :-)
08:43foxdonutborkdude: I've seen those.. are you in Italy/
08:43ro_stalso, whoever made it so i can seamlessly read the contents of .jar files in emacs needs a -ing medal
08:43borkdudero_st yes, I believe
08:43ro_stand some of borkdude's coffee
08:43borkdudefor example (System/getProperty "user.dir")
08:44borkdudefoxdonut no I'm in The Netherlands
08:45foxdonutborkdude: ah ok, cool
08:45ro_stso if i have an env var of MY_SUPER_DB_URL i can read out "MY_SUPER_DB_URL" ?
08:46foxdonutro_st: is this another one of your crackhead experiments? ;)
08:47ro_stoh dear
08:47borkdudero_st hmm good question, or was it System/getenv..
08:48ro_sthave i already gained a reputation?
08:48borkdudero_st I think I read something about getenv being deprecated, but now I'm confused
08:48borkdudero_st this is why I need more coffee
08:51foxdonutro_st: it's all good, I have the same reputation in other channels..
08:51ro_st-grin-
08:52foxdonutnothing wrong with trying stuff out.. that's what nice about software, you can tinker and experiment with little risk of actual physical damage..
08:52Shambles_Yesterday someone mentioned that it was a bad idea to have a un-dotted ... I guess it would be a class path or something (e.g. myproject.core is dotted). I've gotten curious as to why that is a bad thing.
08:52borkdudero_st I think getenv is the one
08:53borkdudero_st I tried this: - in bash: export FOO=123 - in lein repl: (System/getenv "FOO") ;;=> "123"
08:55_nmmn, (System.getenv "SHELL")
08:55clojurebot#<CompilerException java.lang.RuntimeException: java.lang.ClassNotFoundException: System.getenv, compiling:(NO_SOURCE_PATH:0)>
08:55_nmmn, (System/getenv "SHELL")
08:55clojurebot#<AccessControlException java.security.AccessControlException: access denied ("java.lang.RuntimePermission" "getenv.SHELL")>
08:55_nmmnhehe =]
08:55borkdude,(System/getProperty "java.version")
08:55clojurebot#<AccessControlException java.security.AccessControlException: access denied ("java.util.PropertyPermission" "java.version" "read")>
08:55borkdudeno can do ;)
08:55_nmmnwell it was worth a try ;]
08:57ro_stthanks borkdude
08:58foxdonutborkdude, ro_st: getenv is not deprecated, but the Javadocs say getProperty is preferred because system properties are less global, have less side effects, and less subtleties in semantics than environment variables.
08:59borkdudefoxdonut I now read they were once deprecated, but undeprecated in Java 1.5
08:59foxdonutborkdude: ah ok, just to make sure we're confused!
08:59ro_stwhat should i use to read heroku env props? getenv?
08:59borkdudefoxdonut I have gap in Java history though, last used it around 2003 or so, and I only reached back into the Java world because of Clojure
09:00ro_sti'm going to use getenv. to hell with caution. -grin-
09:00borkdudero_st I think you should ask technomancy to make sure
09:03foxdonutborkdude: I see.. what were you using in between?
09:03Shambles_borkdude: You asked why there were variations in byte order. It's because some operations are faster with one byte order than another. For example, it's faster to do bignum operations on little-endian. It's faster to do numeric comparison and networking (IP networking uses big-endian byte order, so on big-endian hardware there's no need to swap bytes around) on big-endian.
09:03borkdudefoxdonut Common Lisp, C# and SAS (don't ask about that last one)
09:04foxdonutSAS? oh.. never mind. :D
09:05borkdudefoxdonut also a bit of playing in F#, etc
09:05foxdonutborkdude: I have always been in the Java world and yearning for functional programming..
09:06borkdudeShambles_ ah tnx for the explanation
09:06_nmmnhaha borkdude i have similar "situation" with java, havent developed anything on it since 2004 or so
09:06foxdonut_nmmn: .net in the meantime?
09:08_nmmnnah, trying to move to erlang a bit, would like to get more time for clojure thou :/
09:10borkdudegotta go
09:22Shambles_Others have probably seen this Clojure video, but I found it entertaining: http://www.youtube.com/watch?v=7XUWpze_A_s It might be something worth showing people who wonder "what the point" is.
09:25Fossinifty
09:31Shambles_Fossi: The advantage granted by the ease of redefining stuff on the fly, and spawning the REPL in most IDE's, and not having to wait for a big compile phase, come through in that. I love the 'sticky' bug in the video.
09:33Fossiwell, it's a little more than that
09:33clgvShambles_: that's the lighttable birth project, so to say ;)
09:34Fossii totally adore the "stop current state" key
09:34Fossiin your usual mutable game engine that wouldn't be possible
09:39dgrnbrgwhat is more() used for in the seq API? i understand first, next, and cons, but it seems like more == next
09:40cshell,(doc more)
09:40clojurebotIt's greek to me.
09:40dgrnbrgit's a method on the java api
09:40cshellah
09:40dgrnbrgsince ISeq is an interface
09:40dgrnbrgit has 4 methods, but i don't know what more is for
09:41cshellis it just leveranged by next or rest?
09:41csheller, leveraged even
09:41cshelli don't have my code up but does more take an int argument?
09:42dgrnbrgah, i see--it looks like it returns empty seq instead of nil
09:42cshellif so, maybe it's for getting the nth next
09:44dgrnbrgwell, i just remembered seqable
09:44dgrnbrgwhich is a much easier api
09:44dgrnbrgfor me, at the moment :)
09:47dnolendgrnbrg: cshell: more is leveraged by rest.
09:47dgrnbrgdnolen: what's the difference between next and rest?
09:48dgrnbrgthey seem so similar
09:48dnolendgrnbrg: next will return nil if there's nothing left, rest will return the empty list.
09:49dgrnbrgthat seems like a trivial difference--what's the motivation for them both?
10:03_nmmnhm was wondering if its ok if default test suite does not pass 100%?
10:03_nmmnsorry wrong room :/
10:05Shambles_I'm watching the Light Table video and starting to wonder if this means dataflow programming will see a comeback soon.
10:06dgrnbrgShambles_: it's the only way to program modern hardware, you know?
10:09Shambles_dgrnbrg: Well, I dunno about that. Concurrency got 'figured out' quite a while ago (just most programmers didn't get the memo), and the things that seem to work well are dataflow and message passing. At least that. Then there's the option of not using mutable data so a 'race condition' doesn't really matter. I do think it's kind of sad that Lucid just basically died out.
10:11wastrelwhat's lucid
10:12Shambles_wastrel: Lucid was a rather nice (i.e. readable, and fairly easy to explain/understand) dataflow programming language.
10:12clgvwastrel: http://en.wikipedia.org/wiki/Lucid_%28programming_language%29
10:14wastrelthx
10:14wastreladded to my to-read list
10:14ldopadgrnbrg: i *think* next has to actually evaluate it's return value to determine if it's empty and return nil, whereas rest is fully lazy
10:15dgrnbrgldopa: i see
10:16RickInGA,(rest [1])
10:16clojurebot()
10:16dgrnbrg,(next [1])
10:16clojurebotnil
10:17RickInGA,(if (rest [1]) 'true 'false)
10:17clojurebottrue
10:17RickInGA,(if (next [1]) 'true 'false)
10:17clojurebotfalse
10:24dnolendgrnbrg: ldopa: that's correct.
10:24Shambles_wastrel: If you're really interested you might want to download this. The physical book is nearly impossible to find now: http://plaice.web.cse.unsw.edu.au/~plaice/archive/WWW/1985/B-AP85-LucidDataflow.pdf
10:24wastrelim not that interested :]
10:25wastrelif i had infinite time ... :]
10:25wastrelbut thanks
10:26Shambles_Okay.
10:26dnolenShambles_: definitely worthy of more investigation. One of Alan Kay's fave langs.
10:28ldopa,(do (rest (repeatedly #(prn :foo))) nil)
10:28clojurebot:foo
10:28ldopa,(do (next (repeatedly #(prn :foo))) nil)
10:28clojurebot:foo
10:28clojurebot:foo
10:29mytrileHey, guys. How can I make list of 1000 elements all 0, then replace 10 of them with 1 and then filter those 10 ?
10:30gfredericksmytrile: the way you explain it it makes no sense
10:30Shambles_dnolen: It's almost forgotten outside spreadsheets. It has applications in hooking up GUI components (the Cells system for Common Lisp), simulations (things like the fluid simulation in Terraria), and, in tree (no loop dependencies) arrangements, heavy automatic optimization (SAC programming language for supercomputers). Other than SAC everything is pretty 'special case' though. :/
10:30gfredericks1) "filter out" or "filter all but"?
10:31gfredericks2) if that's all you wanted to do you could just start with 990 0's or 10 1's
10:31mytrilegfredericks: https://gist.github.com/971051827fd54ce6248b
10:31mytrileI want to see what this code will look in Clojure
10:32gfredericksmytrile: well (repeat 1000 0) gives you 1000 0's
10:32gfredericksyou don't normally update data structures in place though, so there's not an exact analogue in idiomatic clojure
10:33gfredericksbut we can do this with a vector
10:33gfredericks,(let [idx (take 10 (repeatedly (rand-int 1000)))] idx)
10:33clojurebot#<ExecutionException java.util.concurrent.ExecutionException: java.lang.ClassCastException: java.lang.Integer cannot be cast to clojure.lang.IFn>
10:33gfredericks,(let [idx (take 10 (repeatedly #(rand-int 1000)))] idx)
10:33clojurebot(548 88 866 248 802 ...)
10:33gfredericksso that gives us the indices
10:34dnolenShambles_: I thought some of the ideas were preseved in Mozart/OZ?
10:34gfredericks,(let [idx (take 10 (repeatedly #(rand-int 1000))), data (vec (repeat 1000 0)), updated (reduce #(assoc %1 %2 1) data idx)] (filter #{1} updated))
10:35clojurebot(1 1 1 1 1 ...)
10:35gfredericksmytrile: ^ there you go
10:35mytrilegfredericks: thanks :)
10:36gfredericksmytrile: it uses a vector instead of a list, which is much better for random updates
10:36mytrilegfredericks: I've read that vectors are optimized for random access
10:37gfredericksrandom access/updates, and adding/removing from the end
10:37Shambles_dnolen: There's dataflow variables in it. I think Mozart/Oz is no longer maintained though.
11:10solussd_hmm, nailed down a weird "bug". If I call a macro (e.g. in another namespace) from within a (noir) defpage and its expansion refers to a namespace that isn't 'require'd in the current namespace (but is 'require'd in the namespace that the macro is defined in), and I'm using skip-aot: true in my project.clj, I will get a java.lang.ClassNotFoundException for functions in the macro expansion.
11:11gfrederickssolussd_: the macroexpansion gets evaluated in the namespace that you call the macro from
11:12gfrederickssolussd_: so that sounds like expected behavior
11:12solussd_gfredericks: I understand, but the macroexpansion contains the fully qualified namespace, yet the namespace doesn't get loaded. That is incorrect behavior
11:12solussd_plus, loading the namespace that the macro is in should load that namespaces dependencies
11:13gfredericksoh hm
11:13solussd_and it only happens in my defpage. :) everything works like a charm in my tests. :/
11:13gfrederickssolussd_: so outside a defpage it's not an issue?
11:14solussd_gfredericks: afaict, yes.
11:14solussd_I can "fix" the problem by 'require'ing all namespaces in the macro's expansion in the namespace that the macro is being expanded in
11:15solussd_this is probably something I should create an example project of demonstrating
11:16solussd_wonder if it is a symptom of some laziness on the part of defpage's expansion(s)?
11:16TimMcsolussd_: That would be a bug, yeah. However, there's a related known problem: Macroexpansions that use private vars in the macro's ns.
11:17gfredericksTimMc: that's unintentional?
11:17solussd_TimMc: what's wrong with that?
11:18solussd_does it just not work?
11:18TimMcYeah, just doesn't work.
11:19solussd_yeah, that's unexpected
11:19TimMcSome other lisps handle that case properly -- I think Racket does.
11:19gfrederickssolussd_: in the same way that calling the private var directly would not work
11:19solussd_well, maybe not, considering how vars are qualified in the expansion
11:19solussd_right
11:19TimMcI haven't run into this personally, but it's definitely a bug.
11:20TimMcWell... mis-design.
11:20gfredericksI've run into it a number of times
11:20gfredericksso I started convincing myself it must be right
11:20solussd_TimMc: "this" being my bug, or the private var bug?
11:22solussd_guess you can just intern all private symbols in your macroexpansion in your macro. :)
11:28ivanheh, this confused me for a minute until I remembered laziness was going on:
11:28ivanuser=> (with-open [reader (clojure.java.io/reader "/etc/passwd")] (let [lines (line-seq reader)] lines))
11:28ivanIOException Stream closed java.io.BufferedReader.ensureOpen (BufferedReader.java:115)
11:29bordatoueis there a way to get object inputstream reader
11:29bordatoueclojure way
11:31bordatouel
11:31bordatoue;*ns*
11:32bordatouecould anyone please help me with my query. I need to find out the most suitable way to get access to objectinputstream to deserialise java object or is there any other fn that does deserialisation or should i just use java API
11:34solussd_might take a look in the clojure.java.io namespace
11:34bordatouesolussd i did that
11:34bordatouesolussd: couldn't find anything that would deal with objectinputstream
11:35solussd_hmm.. guess use the java api then.. maybe wrap it all in a "with-open"
11:36ynnivI'm having issues with java.jdbc and catching SQLExceptions
11:37bordatouesolussd: there is a reader that returns bufferedreader
11:37ynnivtransaction* claims to aid this by rethrowing RuntimeExceptions as their SQLExceptions causes, but this doesn't appear to be the reality
11:42TimMcsolussd: "this" == private var bug
11:56bordatoueis there any command to load all the jar files in a directory
12:01bordatouehello, how to load a set of external .jar files in clojure
12:02dbushenkoidiomatic way is in using leiningen and adding the jars to your local maven repository
12:02bordatouedbushenko: thanks, do you know anyway i coulod load it from the repl
12:03nDuffbordatoue: ...if you're _not_ doing it the idiomatic way... well, make sure they're in your classpath when you start the JVM. But "use leiningen" is definitely the easy solution.
12:03bordatouenDuff: is it possible to dynamically load it from the repl
12:03dbushenkobordatoue, you can't load them from the repl if they aren't on your classpath
12:03dbushenkoand if they are, then the task is solved
12:03hiredmanhttps://github.com/hiredman/clojurebot/blob/master/src/clojurebot/plugin.clj
12:03nDuffbordatoue: pomegranate is the usual tool used for dynamic classloader updates; it doesn't just add things, it downloads them for you too.
12:03dbushenkothe easiest way is to use leiningen for that
12:04S11001001bordatoue: why do you want to do it the hard way?
12:04nDuffbordatoue: ...I mean, you _can_ build your own classloader with the jars you want added in and attach them to the thread...
12:04nDuffbordatoue: ...but you're just making your life harder trying to do it that way.
12:04bordatoueS11001001: ah not keen on doing it in the hard way, just wanted to see clojure's capablities
12:05nDuffbordatoue: *nod*. Basically comes down to "same things you can do with the JVM directly"
12:05bordatoueS11001001: basically I thought i could use a repl to debug java program
12:05S11001001you can, that has nothing to do with adding jars w/o restart
12:05S11001001but if you want some craziness
12:05S11001001https://github.com/cemerick/pomegranate
12:06S11001001***not for normal usage in normal programs***
12:06nDuff...now, if you want _fun_, you can try to make pomegranate and nREPL play well with OSGi :P
12:06bordatoueS11001001: well, java program i need to debug depends on these jars, so i need to get reference to these jars dynamically
12:06S11001001bordatoue: because the java program picks up the jars dynamically?
12:06nDuffbordatoue: ...err, why dynamically? Why not have them already there when you launch the JVM?
12:06nDuffbordatoue: ...not saying you _can't_, again, just that it's extra work.
12:07bordatoueokay, let me try by adding class path
12:07hiredmanyou can, in fact, use urlclassloaders to load code out of jars over http (right out of maven repos)
12:07hiredmanif you are so inclined
12:08bordatouehiredman: urlclassloader, i will take a look
12:08hiredmanI'd suggest looking at the url I pasted
12:08bordatouei can't see any url you pasted
12:09hiredmanit was several minutes ago
12:09bordatouehiredman: found it , sorry
12:12cemericknDuff: *snort* @ "the usual tool used for dynamic classloader updates"
12:12cemerickI hope it's not a usual sort of thing for most people. ;-)
12:15xeqiI find myself dealing with it in several projects
12:15technomancyiiiinteresting: https://twitter.com/xpaulbettsx/status/216003572163297280
12:17nDuffcemerick: Heh.
12:18nDuff...anyone have thoughts on what would be a decent place to discuss changes in building jars with Clojure source in them to make things more OSGi-friendly? I have a fork of clojure.osgi with relevant changes at https://github.com/charles-dyfis-net/clojure.osgi/commit/c355e1f4e05147cf7f99c5579dca4e5c80bddb79, but actually _creating_ bundles that take advantage of this is thus far something only I do.
12:19cemerickxeqi: Gawd, I'm so sorry. :-|
12:26N8Dawghi, all. I'm a bit stuck, i'm trying to debug some non-trivial clojure code
12:26N8Dawgwhat good debuggers are there?
12:26N8Dawgi'm looking at swank-cdt but i can't work out how to step into anonymous functions
12:27N8Dawgor put breakpoints on them
12:31jedmtnman1if I want to return two keys from each map in a list, is there a function I should be looking at specifically at? like 'get-in' but not for nested data?
12:32bhenryhow can i make leincljsbuild work with the latest release of clojurescript?
12:32jedmtnman1sorry, not two keys, but to vals by key lookup ^
12:34xeqi&((juxt :a :b) {:a 1 :b 2})
12:34lazybot⇒ [1 2]
12:36jedmtnman1xeqi: ty
12:37Bronsa,(vals {'a 1 'b 2})
12:37clojurebot(1 2)
12:37xeqi&(select-keys {:a 1 :b 2} [:a :b])
12:37lazybot⇒ {:b 2, :a 1}
12:37xeqijedmtnman1: migt be btter ^
12:37xeqi&(select-keys {:a 1 :b 2 :c 3 :d 4} [:a :b])
12:37lazybot⇒ {:b 2, :a 1}
12:38jedmtnman1xeqi: select-keys might be what i was thinking of, but juxt might work better in this context. ty again Bronsa too
12:39amalloy&(map {:a 1 :b 2} [:a :b])
12:39lazybot⇒ (1 2)
12:39gfredericksamalloy: but that doesn't use juxt
12:45gfredericksit does have the advantage of working for more than just keywords though
12:45amalloyit also exercises all three of clojure's brace types
12:53charliekilo /join #datomic
13:05dnolenbhenry: bug emezeske
13:05bhenrydnolen: i'm bugging him on his github repo. i just am impatient.
13:06dnolenbhenry: did you try specifying the CLJS version explicitly in your :dependencies?
13:07bhenryyes. it appears there are breaking changes? i'm not really sure, but i tried both of his suggestions here with the same results: https://github.com/emezeske/lein-cljsbuild/issues/101
13:08dnolenbhenry: oh yeah, warning flag he was using got moves to the analyzer namespace. easy fix of course.
13:11foxdonutdnolen: you are currently the main developer of ClojureScript, is that correct?
13:12dnolenfoxdonut: not the "main" developer. I do actively review/apply patches as well occasionally optimize things.
13:13foxdonutdnolen: I see.. so who is/are the "main" developer(s) then? RH?
13:14dnolenfoxdonut: http://github.com/clojure/clojurescript/graphs/contributors
13:15foxdonutdnolen: thanks for the info, and thanks for your contributions!
13:17dnolenfoxdonut: np
13:36taterbaseCould someone recommend a good beginner book on clojure?
13:36technomancytaterbase: clojurebook.com for sure
13:36borkdude+1 on clojurebook.com
13:37borkdudeI call it the Clojure book with batteries included ;-)
13:37taterbase"batteries included" <- that's what I like to hear, thank you :)
13:43borkdudecemerick can I ask a question about clojurebook.com btw?
13:45cemerickshoot
13:46borkdudewhat coordinate system is used for the hex grid game of life on page 144
13:54cemerickborkdude: it's still cartesian (you can see the [x y] coordinates being defined for each vertex)
13:55cemerickThe only difference between a rectangular and hexagonal maze is the shape of the cells centered on the vertices
13:57borkdudecemerick this is about the game of life, not a maze
13:57borkdudecemerick I'm slightly confused, because there are several ways to do this: http://keekerdc.com/2011/03/hexagon-grids-coordinate-systems-and-distance-calculations/
13:57borkdudecemerick maybe you can show on that page which one is used?
13:58cemerickheh, I may be too — it's been about 9 months since I had that example loaded in my head :-)
14:09borkdudesometimes when I define a function that does something to a JFrame in Mac OSX a "clojure.main" menu item appears
14:09borkdudethis is strange, because I haven't even called the function, just defined it
14:11cemerickborkdude: so, after a quick glance: the coordinate system is still just two-dimensional. Because only immediate adjacency needs to be determined (not arbitrary distance), the third dimension introduced in the link you have isn't necessary.
14:12borkdudecemerick yes, but even with only two dimensions you can do the numbering in different ways: straighten the axes or not
14:13borkdudecemerick it seems that straightening the axes is the cleaner way - but I tried both ways and tried to reproduce the examples from clojurebook, but couldn't figure it out - it might be my foolish brain
14:14Guest98851Hello, I have a Problem to set up Clojur eREPL on Mac OSX 10.5 I cant use arrow cursor to navigate the CLI, any pointers?
14:14technomancyGuest98851: need to either install rlwrap or upgrade to lein 2.x
14:14Guest98851I downloaded clojure 1.4 jar
14:15Guest98851so thats not included there , it works in windows, hm
14:15technomancyoh, ok. that's probably not what you want, but I can see how you would make that mistake
14:15technomancybest to start at http://leiningen.org
14:15borkdudenice to see something that works in windows but doesn't in OSX for once ;)
14:16Guest98851do i really need leiniging JUST to get a REPL?
14:16ivanno, you can use rlwrap as mentioned
14:16technomancydepends on whether you want a good repl or not
14:16borkdudeGuest98851 +1 on leiningen, it is the most flexible way to get a repl running for your projects
14:16Guest98851how do i set up rlwrap?
14:17ivanrlwrap java ...
14:17Guest98851I dont want projects, yet just a REPLok
14:17ivanI'm sure all 3 package managers on OS X have it
14:17borkdudeGuest98851 also for a standalone repl I can recommend it, do it all the time
14:17nDuffGuest59394: You'll shortly want that REPL to have some libraries loaded, unless you're programming in a vacuum
14:17nDuffGuest98851: ...so having a project defined (taking all of one leiningen command to do) is well worthwhile.
14:18technomancyI recommend not programming in a vacuum; it's very confined and difficult to see the keyboard
14:18jodaroand dusty
14:20michaelr525programming in a vacum can get your tits squashed
14:20Guest98851I just want to tinker no need for librarys
14:20borkdudeless bit rot though
14:21borkdudeGuest98851 take our advice, just use leiningen even for something simple like a REPL, you will be happy.
14:21technomancyweird dejavu from yesterday
14:21technomancyclojurebot: installing clojure?
14:21clojurebotClojure isn't like most languages in that it doesn't need to be installed; it's just a library. Once you have a JVM, you can set up a project with something like Leiningen (http://j.mp/leiningen), which will pull Clojure in for you.
14:24Guest98851I wonder what I would do if I had it to setup on a machine without internet :/
14:26michaelr525i think you can run something like: java -cp clojure.jar clojure.main
14:26TimMcGuest98851: Be in pain.
14:26TimMcEven if you didn't have lein, you'd still have to fetch dependencies to test or run anything.
14:27cemerickMuch all of modern computing assumes a network connection, for better or worse.
14:27brainproxyGuest98851: getting starte w/ lein is a no brainer, the .sh script bootstraps leiningen automatically
14:27cemerickbah, s/all/
14:28michaelr525actually i've started with just clojure.jar and was happy with it until i discovered lein later
14:28brainproxyGuest98851: then you just do `lein repl`, and you'll hice a nice repl to tinker around with, inc. some helpful keyboard shortcuts
14:28brainproxyyou'll *have
14:28Guest98851thats what i get
14:28Guest98851http://pastebin.com/0jKky8Xb
14:29etoschAnyone have issues using recur in a cond-match clause with matchure?
14:29Guest98851actually I DID run the clojure REPL i just cant use arrow keys which makes it unable to use :/
14:30Guest98851I guess there must be something to it since the scala guys where also mumbling how painfull it is to deliver a multi OS CLI
14:31etoschI have a clause that structured like this: [[false true] [something-false something-true] retvaue, but in the following clause after its match I have a call to recur
14:31borkdudebash: command not found.. hmm
14:31etoschwhen I run just (cond-match [[false true] [false true]] 'asdf) in the repl, I get 'asdf
14:31borkdudeGuest98851 try ./lein instead
14:32technomancyGuest98851: the `java` command-line launcher is a joke
14:32technomancyas far as I can tell, the jdk developers try to pretend unix doesn't exist
14:32etoschand when I remove the line from the clauses in cond-match my function compiles fine
14:32dnolenetosch: I think matchure may generate intermediate fns to prevent code size explosion - breaking usage of recur.
14:32borkdudeinteresting things happen when I type ". lein", my terminal even disappears :)
14:33Guest98851noname:Documents mich$ . /lein gives: -bash: /lein: No such file or directory
14:33etoschdnolen: so is it not closing over something?
14:33borkdudeGuest98851 omit the space
14:33Guest98851sorry thats it
14:33Guest98851its working now
14:33etoschdnolen: The error is very weird - it's saying that I'm providing too many arguments to recur
14:34borkdudeGuest98851 if you put the script on the PATH, you don't have to type ./lein , that is much easier
14:34dnolenetosch: core.match avoids this, but is very alpha status and has some issues (AOT, mostly around maps and using multiple types in the same column).
14:34dnolenetosch: matchure is broken, you can't use recur.
14:34Guest98851borkdude: yes but i dont want it on my path
14:34dnolenetosch: there's nothing you can do to make it work as it expected far as I know.
14:34borkdudeGuest98851 it's up to you..
14:35Guest98851so now this: http://pastebin.com/MB7nTVbL
14:35Guest98851I am on an old mac osx 10.5...
14:35etoschdnolen: hrm, I'll give core.match a try
14:36wkellyGuest98851: export HTTP_CLIENT="curl --insecure -f -L -o"
14:36dnolenetosch: expect to encounter a different set of issues there (as I mentioned) ... patches welcome.
14:37etoschdnolen: alrighty, i shall commence with caution
14:37Guest98851:wkelly do I have to type this?
14:37wkellyGuest98851: yup! just type it in the same shell you are running lein from
14:37wkellythen run the command again
14:39technomancynext version of lein will have a better error message explaining that
14:39technomancyoh, never mind; you got the error message
14:40borkdudetechnomancy is this only on "older" systems?
14:40technomancyborkdude: yeah, ancient libopenssl
14:40Guest98851wkelly: tried both suggested commands : insecure and no certificate, both dont work...
14:42Guest98851is there a swing UI for the REPL?
14:42Guest98851really i just want arrow key navigation and command history, thats all...
14:42borkdudeGuest98851 if you can paste the error msg, we can find out maybe what doesn't work
14:43wkellyborkdude: it is pasted
14:43borkdudeGuest98851 I'm sorry things don't go as smooth as promised… ;-)
14:43technomancyyou should see if you can get a newer libssl
14:43Guest98851np its my OS fault obviously
14:43technomancyI'd be nervous running something that old
14:44borkdudehow old is old?
14:44technomancybut still, exporting HTTP_CLIENT should work
14:44technomancy2005-ish I think?
14:44technomancymacosecks is never EOL'd =(
14:46Guest98851so im using: http://incanter.org/downloads/ incanter now but is only on 1.2
14:46Guest98851does such a GUI REPL exist with 1.4?
14:49Guest98851well anyway thx for your help I can do now some basic stuff with cloure 1.2
14:50nDuff...err, can't you just tell leiningen to pull Incanter in for your Clojure runtime of choice?
14:50borkdudenDuff he went back to the past
14:51borkdudethese people visiting here from the past and future are confusing sometimes
14:52technomancynDuff: really old openssl can't bootstrap leiningen's self-install because it doesn't trust github's SSL cert =\
14:52technomancyand for some reason he couldn't disable curl's cert checks
14:54nDuff...err, isn't that curl -k?
14:54nDuff*shrug*.
14:55technomancymore or less
14:57wkellyGuest59394: can you run mkdir -p $HOME/.lein/self-installs/
14:57wkellyGuest59394: and then wget https://github.com/downloads/technomancy/leiningen/leiningen-2.0.0-preview6-standalone.jar --no-check-certificate -O $HOME/.lein/self-installs/leiningen-2.0.0-preview6-standalone.jar
14:57borkdudemaybe for bootstrapping an interactive question could be put it: are you sure you want to do this?
14:57wkellywithout the line wrap
14:57technomancywkelly: wrong guest, I think
14:58wkellyhaha
14:58wkellyso it is!
14:58arrdemgood catch
14:58technomancythe magic of nick highlighting =)
14:58wkellyoh well
14:58mmarczykdnolen: ping
14:58dnolenmmarczyk: pong
14:58mmarczykdnolen: hi! so, where do you think we're at with :import ?
14:59dnolenmmarczyk: been a bit busy - I didn't know if you were coming up with another patch.
14:59xeqiborkdude: curious, what are you trying to use the hex coordinates for?
14:59borkdudexeqi just trying to understand the example from clojurebook
15:00mmarczykdnolen: sure. I think the original goog.provide patch should work fine
15:01dnolenmmarczyk: it's also preferable that there's only one patch on the ticket. can we remove the others?
15:01xeqieverything is kept in rect coords, so the underlieing hex coords aren't ever used
15:01dnolenmmarczyk: so the working patch works at the REPL and relies on GClosure for errors?
15:01dnolenunder compilation?
15:02mmarczykdnolen: the working patch only emits goog.provide calls when compiling files
15:02mmarczykdnolen: no goog.provide at the REPL
15:02borkdudexeqi I think a picture would clarify this all for me
15:02dnolenmmarczyk: k let's remove the other patches from that ticket.
15:03xeqiheh, wish I had a peice of graph paper
15:03mmarczykdnolen: ns forms receive special handling from the repl, I believe -- in particular, goog.provide is not called
15:04mmarczykdnolen: hm, in this case I think the basic patch introducing :import for GClosure classes is so simple it can't be wrong
15:05mmarczykdnolen: whereas I think the approach to cljs records/types should work too, but may still be refined so the implementation is prettier
15:05mmarczykdnolen: hence the two patches
15:05mmarczykdnolen: but sure, I can squash them, give me a minute :-)
15:07dnolenmmarczyk: I would prefer a single patch that handles deftype/record
15:07borkdudexeqi is it this system? http://keekerdc.com/2011/03/hexagon-grids-coordinate-systems-and-distance-calculations/hexgridsquiggly/
15:09dnolenmmarczyk: if the patch needs some refinement, then by all means refine :)
15:09mmarczykdnolen: :-)
15:11xeqino, not every rect coord maps to a hex coord
15:14ynnivwow… does map wrap any non RuntimeException in a RuntimeException?
15:18borkdudexeqi I see it now…
15:18oskarth__how do I call clojure functions from clojurescript?
15:19dnolenoskarth__: what do you mean?
15:19oskarth__dnolen: I mean using a clojure library and calling it from clojurescript, like clojure and java fns
15:20xeqiborkdude: heh, an I had just put together http://postimage.org/image/pqnu8vbjn/ with some random online image editor
15:20mmarczykdnolen: squashed patch attached
15:21dnolenoskarth__: are you talking about client/server communication?
15:21dnolenmmarczyk: thx
15:21borkdudexeqi so the axes are straightened, only differently
15:21mmarczykdnolen: the *emitted-provides* thing might be misnamed, since I'm not emitting them for ns forms (that would be useless at this time)... no idea for a better name, unfortunately
15:21borkdudexeqi no,nm, but I get it now
15:22borkdudexeqi tnx!
15:22oskarth__dnolen: in a way yes, but we want a certain js thing to change when a file has been updated on the filesys
15:22dnolenoskarth__: need more details ... what are you trying to do?
15:23cgagtechnomancy: is deployment mullet your term? that's great
15:23oskarth__dnolen: we do a POST which starts to generate an image in quil, but we want to watch the file-system for changes so we know when to update the image div
15:23oskarth__dnolen: previously we tried to do it with java threads, but the request comes back before the image is generated then
15:24oskarth__does that make sense?
15:25jweissis there a recommended way to print readably so taht there are no embedded objects like #< clojure.lang.AFunction$1@7b3825bf> ? I know i can write a defmethod, but that will change it system-wide.
15:25xeqiborkdude: for extra fun, consider 1,0 as your starting rect coordinate
15:25oskarth__it's quite possible we don't understand how the thread is working with the web server and are thus trying to do thing in a unidiomatic way
15:26dnolenoskarth__: yes, depending on how robust of a solution you want - you could poll, you could use WebSockets. Perhaps GClosure browser channel, etc.
15:26xeqiand how that compares to 0,0
15:26oskarth__dnolen: right now we are using polling, thought about switching to web sockets but want to get this working ok first
15:26borkdudexeqi just to make sure: (hex-neighbours [0 0]) -> ([-2 0] [-2 2] [-1 -1] [-1 3] [0 0] [0 2])
15:26dnolenoskarth__: the problem is sounds like that the request completes, and the file is getting updated on a different thread.
15:26oskarth__exactly
15:27oskarth__so we thought of having a dir-change watcher
15:27borkdudexeqi probably there is just a tiny difference in rotation here
15:27oskarth__dnolen: does that sound like a bad idea to you?
15:27xeqiborkdude: https://www.refheap.com/paste/3292
15:28xeqiconsider pulling https://github.com/clojurebook/ClojureProgramming
15:28dnolenoskarth__: so if you're making something simple for demo purposes you could just return something (a token) that the client can then poll for.
15:28dnolenoskarth__: if you're doing something fancy you'll want some kind of bidirectional channel. Lots of JS uploaders rely on Flash for this.
15:29borkdudexeqi ok.. tnx for your help, I'm off now
15:29oskarth__dnolen: hm ok, but how would the js know when the file has been created if it's started in another thread?
15:30dnolenoskarth__: it starts polling with the token.
15:30oskarth__aha I think see now
15:31oskarth__dnolen: thanks
15:31dnolenoskarth__: again not something I really recommend for anything real. If I recall correctly, Aleph has WebSocket support and integrating it with Noir / Compojure / Ring shouldn't be hard.
15:32oskarth__dnolen: yeah, we were thinking about doing something like aleph or netty if we were to continue working with it
15:37Chiron_Hi, should I do something special when importing and using a "generic" type such as com.netflix.astyanax.AstyanaxContext<Entity> ?
15:40Chiron_and how to import a static class defined within another class?
15:40xeqiChiron_: leave the generic type signature off
15:41xeqiand use $ between the names
15:43Chiron_something like (import [com.netflix.astyanax AstyanaxContext.Builder]) ?
15:43Chiron_(import [com.netflix.astyanax AstyanaxContext$Builder])
15:44xeqiI think that'll work
15:46xeqi&Thread$UncaughtExceptionHandler
15:46lazybot⇒ java.lang.Thread$UncaughtExceptionHandler
15:56Chiron_How to access an Enum? NodeDiscoveryType/None ?
15:57mattmossYa.
15:57Chiron_are doto and -> are replaceable when working with Java objects?
15:58mattmossNot entirely.
15:58mattmoss-> will return the last evaluation as its result
15:58brainproxybe wary of this mattmoss character, he's a little tricky
15:58mattmoss(doto (java-obj) ... ...) will return the java-obj
15:59Chiron_Oh
15:59mattmossOtherwise, I *think* -> and doto are fairly similar... at least for calling a chain of java ops.
16:00Chiron_I c. thanks!
16:00Chiron_clojurebot: Haskell!
16:00clojurebot"you have to see features like that in the context of Haskell's community, which is something like Perl's community in the garden of Eden: detached from all shame or need to do any work." -- ayrnieu
16:00Chiron_wow, one word deserve two lines response
16:00brainproxyChiron_: in a doto chain, any number of the steps may involve methods which don't themselves return the object that the methods are operating on
16:01mattmossAh yes, good point, bp. I had forgotten that.
16:01brainproxybut doto makes sure that each step along the way operates on the object you're passing in
16:02brainproxy-> is a way of composing functions together, where the return value of one step is an argument in the next step
16:02brainproxywhich argument position depends on whether you use -> or ->>
16:03Chiron_that is imformative
16:04Chiron_btw, would you please explain to me clojurebot response to "haskell" ?
16:04brainproxy,haskell
16:04clojurebot#<CompilerException java.lang.RuntimeException: Unable to resolve symbol: haskell in this context, compiling:(NO_SOURCE_PATH:0)>
16:04muhooanyone run datomic on heroku yet?
16:04brainproxy,"haskell"
16:04clojurebot"haskell"
16:05brainproxynvm, I see above, the "garden of Eden..." text
16:06Chiron_yes that one
16:06hiredmanit's a quote, someone said it once
16:06hiredmanwhat more is there to explain?
16:07Chiron_didn't understood it, don't bother :)
16:09muhoohm, maybe not, looks like it'll work http://webcache.googleusercontent.com/search?q=cache:87T33B5UsR8J:http://groups.google.com/group/datomic/browse_thread/thread/e3cea68ce2595552%2Bdatomic+heroku&amp;hl=en&amp;ct=clnk
16:15dgrnbrghey clojurians, i'm having some fun in class loader hell. I have a groovy script that's invoked by a magic class loader, and i need to run some clojure code in that class loader too.
16:15dgrnbrgAlso, i cannot add clojure to the claspsath at jvm startup, so i'm creating a urlclassloader and adding clojure to that as a URL resource
16:16dgrnbrgthen, i am creating a new GroovyShell with the URLClassLoader as its class loader, and then i'm setting the clojure.lang.Compiler.LOADER as this.classLoader in the GroovyShell's string, and then i'm trying to run the clojure program
16:17etoschdnolen, I'm having an issue with core.match. Not sure where/how to report on JIRA
16:17dgrnbrgi'm having a problem where it cannot find clojure/core.clj, even though it can find clojure.lang.*
16:18dgrnbrgdoes anyone have any ideas for my class loader hell?
16:19adudgrnbrg: clojure+groovy! good choices
16:20adu(add1 dgrnbrg)
16:23dgrnbrgadu: thanks :)
16:23dgrnbrghave you dealt with class loader hell?
16:25adudgrnbrg: http://www.liferay.com/community/forums/-/message_boards/message/13323232
16:26dgrnbrgi am legacy
16:26dgrnbrgso, so legacy
16:26dgrnbrgi cannot control the command line
16:26dgrnbrgi cannot export CLASSPATH
16:26dgrnbrgeverything has to be dynamically done
16:28dgrnbrgadu: do you know how I can defer resolving the clojure classes until i've had a chance to set up the runtime?
16:28dgrnbrgin groovy, that is
16:28dgrnbrgi do clojure.lang.RT.loadFile
16:28aduwhat's wrong with CLASSPATH?
16:28dgrnbrgbut i haven't added clojure.lang.RT to the class loader yet, so i can't put it as text in the program, b/c the groovy compiler won't accept it
16:29dgrnbrgit's not possible to have it work in my environment :(
16:30aduhow about System.setProperty("java.class.path", "…")?
16:31dgrnbrgcan you do that and have the class loader work?
16:31aduno idea, worth a try
16:32jweissdynamically loading libs doesn't work, so if it was that easily solved, it would work :)
16:32nDuffcreate a new URLClassLoader
16:32nDuffadd URLs to the jars to it
16:32nDuffset as your thread context classloader
16:33Rayneshttp://github.com/flatland/classlojure
16:33dgrnbrgi'm trying to bootstrap clojure in a groovy environment
16:34dgrnbrgso i have a URLClassLoader with all the clojure jars added to it
16:34dgrnbrgis there some way to do something like:
16:35dgrnbrgClass.forName("clojure.lang.Compiler", true, urlClassLoader).LOADER.bindRoot(urlClassLoader); Class.forName("clojure.lang.RT",true,urlClassLoader).loadResourceScript("my-script")?
16:35dgrnbrgbecause Class.forName returns a Class, but I need the Compiler so that I can start my work
16:38etoschdnolen, I'm having an issue with core.match. Not sure where/how to report on JIRA
16:38dnolenetosch: http://dev.clojure.org/jira/browse/MATCH
16:39dnolenetosch: what is the problem you're encountering?
16:41etoschdnolen, not sure how to describe it without examples. Doesn't look like the extant issues match up. Should I open a new issue and paste code?
16:42dnolenetosch: can you give an example first - there several different tickets about various problems - it may already exist.
16:43etoschdnolen: sure. I want to do this: let [x '() y '()]
16:43etosch | (match [(seq x) (seq y)]
16:43etosch | [([_] :seq) nil] 'a
16:43etosch | [_ _] 'b))
16:43etosch(pasting from emacs, sorry
16:43etosch(let [x '() y '()]
16:43etosch (match [(seq x) (seq y)]
16:43etosch [([_] :seq) nil] 'a
16:43etosch [_ _] 'b))
16:43cshell_you can use refheap.com
16:43dnolenetosch: use a paste service, refheap, gist
16:44etoschk, gimme 5
16:44dnolenetosch: you're expecting 'b and getting 'a?
16:44muhoosomewhat OT, but why wouldn't datomic work with heroku's free postgres, only with it's $50/month postgres?
16:44muhoos/it's/its/
16:48etoschdnolen: no, i'm getting a runtime exception
16:48dnolenetosch: what is it?
16:48solussdhow can I get the pre/post conditions from a function?
16:49etoschdnolen: https://www.refheap.com/paste/3294 it says it can't resolved the symbol - it looks like the product of a gensym or something
16:50etoschdnolen, in the "want this" part i actually want x to be nonempty, but its moot currently due to it throwing an excpeiton
16:51Chiron_Korma creates a db object and it looks like afterwords, all other functions have access to the db object without explicitly being passed https://github.com/ibdknox/korma
16:51Chiron_how to achieve something like that?
16:51technomancyChiron_: some would argue that's the biggest flaw of korma
16:51Chiron_really?
16:52Chiron_what would be a better approach? I'm creating something like that
16:52Chiron_not creating, want to create
16:53technomancyit's best to create your API so the base connection object or whatever is accepted as an argument to every function that needs it
16:53dnolenetosch: yeah that's probably a real bug, though :seq matching will probably go the way of the dinosaur ...
16:53technomancythen optionally create an alternate API based on that one that offers a with-* macro that performs the bindings
16:54Chiron_I was thinking about with-*
16:54dnolenetosch: feel free to make a ticket, I have no plans on addressing the ticket anytime soon too busy with other things. If you supply a patch I'll happily apply.
16:55etoschdnolen, okay, thanks for taking a look
16:55akhudektechnomancy: my solution to that problem with korma was to wrap each table in (database entity conn) every time the entity is used.
16:56akhudekthere is some syntactic sugar there so that calls look more like (select (db my-table) (where …..))
16:57technomancycgag: I can't remember where I first heard the term "deployment mullet" but I <3 it
17:03goodieboydoes anyone know what the standard response keys are for ring? Does ring *only* recognize :status, :body and :headers?
17:05steveo_I have a java library i'm interoping with that wants a uri of a resource to load, the thing I need to load is something I have in memory though, anybody know if there is a way to give a URI to a memory location or something so I don't have to spit this to a file just so it can be read again right away?
17:05ystaelis there a 'standard' choice of idiom for (zipmap coll (map f coll)) or (into {} (map #(vector % (f %)) coll)) ?
17:06cshell_steveo_: no, that's a bad api - it should take an inputstream rather than a uri to avoid things like this
17:10steveo_damn, yeah I wish it did
17:12S11001001ystael: juxt
17:12S11001001(into {} (map (juxt identity f) coll))
17:13technomancyas much as I love juxt, I pine for map-keys and map-vals
17:13S11001001eh, map-keys is weird
17:14llasrammaybe?: (reduce #(assoc %1 %2 (f %2)) {} coll)
17:14llasramNo intermediate vectors!
17:14S11001001llasram: that's slower
17:14technomancyI guess keywordize-keys is nearly the only use case for map-keys
17:14llasramS11001001: Is it?
17:14S11001001llasram: into speaks transient internally, that reduce doesn't
17:14dnolenetosch: thx for the ticket. These will get addressed eventually - all part of a bigger project.
17:14llasramS11001001: Ohhh. Hmm.
17:14llasramS11001001: I had not considered that angle
17:15hiredmantechnomancy: I have theory about map-vals
17:15gtrak`ystael: mapmap?
17:15S11001001technomancy: anyway, map-vals wouldn't do that thing
17:15baoistHas anyone had an issue with VimClojure freezing after opening any ".clj" file when the setting "let vimclojure#WantNailgun = 1" is on?
17:16S11001001technomancy: unless you're thinking of a different map-vals than me :)
17:16cshell_How do i define a protocol method named 'find' so that it won't conflict with clojure.core/find?
17:16S11001001oh, well you said keywordize-keys, so we meant the same one
17:16etoschdnolen, cool; i have some suspicions about where the problem might be and i really really really want to use pattern matching for a particular problem, so i'm going to hack at it for a little bit
17:16hiredmanthe need for maps vals arise when you combine two things in to a single thing, those two things are 1. a collection of things 2. an index of those things for fast/easy retrival
17:17technomancyS11001001: I'm thinking of the one in my head that works like the above =)
17:17gtrak`hiredman: is that bad?
17:17hiredmanif you combine those two things in to a single thing, and decide you want to map over the first thing, you think you need map-vals
17:17S11001001I wish keys and vals would yield in different orders occasionally, just to mess with people who assume they have same order
17:17dnolenetosch: cool! core.match is not the most straightforward Clojure library out there ... would like be more explicit how about we implemented the paper one day.
17:17S11001001there is no implementation reason to do this...
17:18S11001001wait, false
17:18hiredmanif you pull the two things a part you get a map for and index, and a vector
17:18hiredmanand we have mapv
17:18technomancyhiredman: so zipmap is simple because it's explicitly about combining those two things and nothing else?
17:18dnolenetosch: feel free to ask any questions you may have about the implementation.
17:19hiredmanzipmap is about building a map out of two seqs
17:19cgagbaoist: i haven't, it's either worked or warned me when the nailgun server isn't started
17:19etoschdnolen, what's the lay of the land on pattern matching in clojure? Are the major libs just core.match and matchure?
17:19dnolenetosch: yes.
17:20cgagthough occationally i'll try to enter an expression in the repl and it'll insert thousands of spaces
17:20baoistcgag: hrmm, out of curiosity what version of vimclojure are you using? I tried with 2.3.3 and 2.3.0
17:20hiredmantechnomancy: so really you should either a. decide you can take the performance/ease hit and search a linear structure (which is easy to map over) or 2. keep two structures a map of keys indices and a vector of values
17:20hiredmankeys => indices
17:20dnolenetosch: core.match implements a clever algorithm from an OCaml paper - but it's also extensible a la Racket. it also handles the recur case.
17:20gtrak`hiredman: that's kind of a pain. Why not just call the complection a proper abstraction?
17:21cgagbaoist: I don't know actually, I set it up according to this https://github.com/daveray/vimclojure-easy, modified to fit in with vim janus
17:21cgagbaoist: looking in the lib folder, it looks like it's 2.3.0
17:21baoistcgag: thanks, I think I'll look into this.
17:22hiredmantechnomancy: I say this in large part as an extended explanation of why I don't think map-vals will ever land in core
17:24technomancyhiredman: yeah, it seems consistent with some of the other design decisions when you put it that way
17:25hiredmanit is also my experience people tend to be wayyyyyyy biased towards {:id1 {:data v2} :id2 {:data v2}} over #{{:id :id1 :data v1} {:id :id2 :data v2}} (or same as a seq)
17:25hiredmanwhere the second form is more extensible, and self descriptive
17:26technomancyit's definitely underrated, especially for large data sets
17:27ipostelnikhiredman, your 2 examples are not the same
17:27ipostelnik{:id1 example1} is very fast
17:27gtrak`this is somewhat similar to the k-v store vs RDB argument, yes?
17:27hiredmanthats my point
17:28hiredmanpeople are heavily biased towards fast indexed access, over ease of extensibility and self description
17:29hiredmanwithout consciously weighing the tradeoffs
17:29ipostelnikwhen I'd wanted map-vals, it was always in scenarios where index access was the 90% case and map-vals was the 10%
17:47Chiron_what is the best way to represent a couple of fixed values? (like enum)
17:49hiredmankeywords
17:49shawnlewisHello. What's an idiomatic way to model a many to many relationship between "classes" in clojure? In say, java, class C1 could have a list of references to class C2. In clojure you might have a vector of maps that represent C1, each map having a vector of C2s as one of its attributes. But in order to update a C2, since you can't update it in place, you'd need to update each C1 that refers to it. I could use a vector of refs from C1s to
17:49shawnlewisHope that makes some semblance of sense
17:50Chiron_I need to mimic something like this: http://netflix.github.com/astyanax/javadoc/com/netflix/astyanax/connectionpool/NodeDiscoveryType.html
17:50hiredmanshawnlewis: pretend you had the whole thing in a sql db and do it that way
17:51hiredmanChiron_: keywords
17:53shawnlewishiredman: so use unique identifiers as references yeah?
17:53hiredmanshawnlewis: dunno, I didn't really read what you said, but it's a good rule of thumb
17:54hiredmanclojure is about manipulating data, so is sql
17:54hiredmanjava is not
17:59gtrak`sounds like what shawnlewis is talking about is a tradeoff like hiredman described?
17:59gtrak`Chiron_: use keywords and maybe make a set for validation?
18:00gtrak`like (def valid-keys #{:k1 :k2 :k3}), I did something like that recently
18:01Chiron_gtrak`: indeed
18:02dnolenChiron_: namespaced keywords work pretty well for that too I think.
18:03gtrak`if you want usage to be statically verifiable I suppose you could use a macro keyword-factory
18:03Chiron_dnolen: I'm creating an open source project, do u suggest to use qualified keywords?
18:03gtrak`my last comment <- probably a terrible idea
18:05dnolenChiron_: if you want something like an enum and other people use them - yes.
18:05dnolen"other people will use them"
18:07Chiron_so is it recommended to use only qualified keywords when creating open source projects (sorry still learning) ?
18:08gtrak`Chiron_: I've seen examples of regular keywords, I don't think it's that big a deal
18:08technomancyChiron_: depends on who is allowed to put things into the map
18:10Chiron_means?
18:10clojurebotforget Clarity of mind means clarity of passion, too; this is Clarity of mind means clarity of passion, too; this
18:11Chiron_clojurebot: what is your uptime?
18:11clojurebotI don't understand.
18:11S11001001Chiron_: I use qualified to mark implementation details and things that have to mix with other things (e.g. global-hierarchy entries), unqualified otherwise
18:11gtrak`technomancy: do you mean allowed as in you can't from the outside or it's just slightly less convenient?
18:11dnolenmmarczyk: ping
18:11mmarczykdnolen: pong
18:12hiredmanclojurebot's uptime is not so good recently (more restarts) I moved it to a t1.micro with some other things, and the oom killer keeps killing stuff
18:12dnolenmmarczyk: looking at the patch, so you don't clear the *emitted-provides*, problematic for watch build processes I'd think.
18:12technomancygtrak`: parse error
18:13nathansoboi was hoping someone could help me with a conceptual question about programming with values... how large a system should i attempt to model as a value. like say i was building a text editor. would i model the state of the screen, the cursor, what's selected, etc all as a single value?
18:13mmarczykdnolen: well, it's only bound for the extent of compile-file*, same like *position*, *data-readers*, ana/*cljs-ns* etc.
18:13mmarczyksame as
18:13Chiron_clojurebot: are you divorced?
18:13clojurebotTitim gan éirí ort.
18:14gtrak`technomancy: you said 'allowed', that implies that something disallows it, but I can do this:
18:14gtrak`&(into {} [[:clojure.core/a-keyword :val]])
18:14lazybot⇒ {:clojure.core/a-keyword :val}
18:14dnolenmmarczyk: oops sorry missed that bit of the patch.
18:14gtrak`just want to make sure I'm not missing something
18:15technomancygtrak`: I'm talking about maps used as inputs
18:16gtrak`oh, I think I get it, thanks
18:16gtrak`old code won't know about your namespace
18:17gtrak`api consumers can read your docs and figure it out
18:18dnolenmmarczyk: so I am somewhat concerned about the behavior of (:import goog.numbers.Long) and the lack of (:import [goog.numbers Long]), what if I make a deftype called Long and I want to import it as well?
18:18mmarczykdnolen: that wouldn't work in Clojure either
18:19mmarczykdnolen: also, how would [goog.numbers Long] help?
18:19hiredmanand you should use parens for grouping inside :import
18:19mmarczykdnolen: also, I love prefix lists, wouldn't mind implementing them for all libspecs :-)
18:19hiredman(makes it indent correctly)
18:20gtrak`nathansobo: if you scroll up a bit in the log we were just talking about nestedness
18:20mmarczykdnolen: haven't done so here for the sake of consistency
18:20dnolenmmarczyk: you are explicit that you want to use the name. but perhaps I misunderstood how it works in Clojure JVM, does import mean you don't have to qualify?
18:20technomancynathansobo: it's a hard problem; I don't think there's a one-size-fits-all answer
18:20mmarczykdnolen: it does
18:20mmarczykdnolen: if you import a class, you can omit the package throughout the namespace
18:21mmarczykdnolen: *and* there is no :import :as :-(
18:21dnolenmmarczyk: huh ... so it's not possible to import two classes of the same name?
18:21hiredmanit maps the symbol to the class object
18:21hiredman,(intern *ns* 'Foo java.lang.String)
18:21clojurebot#<Exception java.lang.Exception: SANBOX DENIED>
18:22hiredmanclojurebot: jerk
18:22clojurebotyou cut me deep, man.
18:22mmarczykdnolen: no, one needs to be referred to using the fully-qualified name
18:22gtrak`nathansobo: I'm currently staring at examples in our own code of vectors of atoms... so it can be done that way... but it seems painful
18:22hiredmanimport works by assocating the symbol of the classname with the class object in the namespace's map
18:23hiredmanso you certainly can do that, it just isn't support by ns or import
18:23mmarczykright
18:23dnolenmmarczyk: hmm ... I think we should start a thread on the dev ML ...
18:24dnolenmmarczyk: I'm already way more excited about :refer in :require than I am about :use in CLJS. so perhaps another opportunity for improvement here.
18:24mmarczykdnolen: :-)
18:24mmarczykdnolen: one thing I wanted to do with the :import patch is tidying up parse 'ns a bit
18:25dnolenmmarczyk: yes it's a monster now :)
18:25mmarczykdnolen: indeed. :-)
18:25mmarczykdnolen: so I think I've taken a step in that direction with spec-parsers
18:26mmarczykdnolen: next step would be to factor out all the local functions
18:26dnolenmmarczyk: speaking of which ... I should clean up emit :invoke ...
18:26dnolenmmarczyk: sounds good
18:26mmarczykdnolen: cool
18:26mmarczykdnolen: so
18:26nathansobothanks guys let me catch up with that dialog
18:26gtrak`when folks write code the *data* way like '#{{:id :id1 :data v1} {:id :id2 :data v2}}' above, do they tend to model things as triples or something?
18:26mmarczykdnolen: I could split out all this into a separate patch and rewrite the :import patch to build on that
18:27mmarczykdnolen: *or* we could say that :import works pretty much as it does in Clojure, minus prefix lists which are not supported in any other libspec, and then start a clojure-dev thread about improvements :-)
18:27dnolenmmarczyk: not necessary. if the refactor is part of the :import patch I'm ok with that - no one else is working on the ns form far as I know.
18:27mmarczykdnolen: ah, true
18:29dnolenmmarczyk: it could be just like Clojure, but I think better to go ahead and start the conversation while you make your desired changes to ns.
18:29gtrak`maybe you do it like sql with pk/fk? It sounds like an interesting thing to think about
18:29mmarczykdnolen: sure, I'll go on tinkering :-)
18:29nathansobogtrak`: vectors of atoms would seem to introduce coordination issues... like in hickey's talk "simplicity made easy" he says that if you have multiple variables representing a single entity, that you introduce coordination problems
18:30gtrak`nathansobo: yes that's a tradeoff
18:31nathansoboi guess if the separate variable facilitate coordination it helps
18:31gtrak`refs somewhat address that, but there's still an issue
18:31nathansobovariables*
18:31dnolennathansobo: gtrak`: in putting refs types into immutable data structures seems to defeat the whole idea.
18:31gtrak`ya
18:31gtrak`I want to understand the *extensible* way :-)
18:32nathansoboone thing i'm having a hard time wrapping my head around is say you're modeling all this state as a value... and you want to capture *changes* to the state and say, draw them to the screen... you need some sort of abstraction for representing events
18:32gtrak`nathansobo: we have that already, refs, atoms and agents have watch-lists
18:33nathansobolike i need a succinct representation that says "this value you're observing changed in this way" so i can turn around use imperatively mess with the DOM
18:33dnolennathansobo: yes, someone needs to work on that. lots of design notes and a half finished library. ClojureScript seesms like it's getting the wheels turning faster on that front.
18:33nathansobookay let me take a look at watch-lists
18:34mmarczykdnolen: I'm hoping to redo the CLJS-246 patch sometime this weekend too
18:34gtrak`nathansobo: http://clojure.github.com/clojure/clojure.core-api.html#clojure.core/add-watch
18:34mmarczykdnolen: also, if nobody beats me to it, I'll be taking the "recursion in PersistentVector" ticket
18:35dnolennathansobo: lots of people pondering this, add-watch is really not enough from what I can tell. kovasb, ibdknox, lynaghk and ohpauleez have various solutions which should be considered.
18:35nathansobogtrak`: okay that looks like a cool way to see *that* the value changed, but i'm still searching for a way to model *how* it changed. maybe i'm thinking about this all wrong. for performance reasons i'd like to avoid treating the state of the entire display (the DOM) as a value
18:36dnolenmmarczyk: excellent!
18:36mmarczykdnolen: the ticket description (CLJS-299) mentions earlier experiments by Laszlo -- got any links?
18:36nathansobodnolen: cool. glad to know i'm not thinking along the wrong lines. any pointers to public exposition of their thoughts?
18:37dnolenmmarczyk: I still like to get the "satisfies? protocol carrying" in.
18:37gtrak`nathansobo: ah, yea.. you'd need some concept of a diff for each type of value, and you can use either time/space to implement it. Don't know if there's a generic way to do that
18:37dnolenmmarczyk: hmm, not handy, might want to ping on the old Laszlo thread on the ML, he seems to be around.
18:38dnolennathansobo: nothing in writing from them - mostly chatting.
18:38mmarczykdnolen: k
18:38gtrak`the smallest example I can think of, if an int changes value, I suppose you may want to kick-off a smoothly moving slider or something?
18:39mmarczykdnolen: yeah, I'd like to see protocol tagging too
18:39gtrak`that would require the slider to have its own state, maybe a view-model
18:39mmarczykdnolen: haven't figured out a clean way to do that though
18:40nathansobogtrak`: yeah that makes sense... like for a given value change i guess i want the old value, the new value, and a domain-specific diff describing the nature of the change. then my view layer can perform imperative updates on the basis off the diff, referencing the old/new values as needed
18:41aperiodicnathansobo: lynaghk has been working along those lines with bind! & unify in the experimental branch of c2: https://github.com/lynaghk/c2/tree/undom
18:41nathansobobasis *of*, not "off"
18:41nathansoboaperiodic: thanks, i'll give it a look
18:42aperiodicnathansobo: there's a simple demo here: https://github.com/lynaghk/c2-demos/tree/master/todoMVC
18:42gtrak`nathansobo: if you haven't read it already maybe check out the fowler UI arch articles http://martinfowler.com/eaaDev/SupervisingPresenter.html
18:42nathansobothanks guys. this is really helpful and i very much appreciate your time
18:43aperiodicbasically, you use them to associate a hiccup-producing expression that derefs some atoms with a DOM node, and when those atoms change, bind! and unify take care of walking the DOM and updating anything that's changed
18:44aperiodici don't know what performance is like with that, though
18:45nathansoboaperiodic: interesting. perhaps the approach could lend insights valuable in something more ad-hoc / domain-specific.
19:00zach_I'm having some trouble upgrading a project to clj 1.4. 1.2.1 seems to be sticking around in the lib/ of the lein project.
19:00technomancyzach_: upgrading to lein 2 might help
19:00technomancy1.x has some corner cases where plugins can interfere
19:00zach_technomancy: That's fine, I have lein2 installed. Is there any barrier to "switching"?
19:01technomancyclojurebot: upgrading to leiningen 2?
19:01clojurebotupgrading to leiningen 2 is easy with this handy upgrade guide: https://github.com/technomancy/leiningen/wiki/Upgrading
19:01technomancyzach_: hopefully not ^^
19:01zach_technomancy: Thanks!
19:01technomancynp
19:02jodaroman i love handy upgrade guides
19:02jlewishi! can I use IPersistentMap from java, reasonably? if not, can you recommend another more java-friendly implementation of persistent maps?
19:07lucianjlewis: there was a project for making clojure's data structures available to java more nicely
19:08S11001001jlewis: check functionaljava; ipm not so great for java as it is unparameterized
19:12zach_technomancy: So, I installed lein-precate, which basically told me to add a min-lein-version, which I did. Unfortunately, it doesn't seem that lein2 deps is rectifying the problem. Am I missing something? (I'm sure I am!)
19:14technomancyzach_: are you sure it's actually a problem?
19:14zach_technomancy: Unfortunately, yeah -- trying to play around with datomic, which seems to be dependent on 1.4.0
19:15zach_I'll start a new project with lein2 from the ground up and see if the problem seems to persist
19:15technomancyand you've confirmed that having old jars in the lib/ directory breaks datomic?
19:16zach_technomancy: Every classpathed repl I run is running clj 1.2.1, and datomic just kinda isn't working, which a couple mailing list threads I've found seems to be a symptom of not running 1.4
19:17technomancyoh, ok; in that case use `lein deps :tree` to see what's pulling in 1.2
19:22zach_technomancy: Sorry it took so long. It was a really dumb problem. I apparently had a lein project that contained a bunch of projects... ugh
19:22zach_technomancy: Got rid of that, solved the 1.2.1 problem, but noir is still pulling 1.3
19:23technomancyyou can add :exclusions; see `lein help sample`
19:24zach_technomancy: Yep, found it. Thank you for your help.
19:24technomancysure
19:24technomancyshould probably add a faq entry for that
19:25technomancyoh, it's there already; oops
19:26zach_technomancy: I just need to learn to read faqs first :). Thanks for your patience anyways.
21:55mindbender1hi All
21:57aduhi
22:21calvadosis there a way to log stdout and stderr with log4j in clojure ? i just searched some about it and found a solution for java but wondering if there is a way in clojure http://stackoverflow.com/questions/1200175/log4j-redirect-stdout-to-dailyrollingfileappender
22:25xeqicalvados: looks like tools.logging has a function to do it
22:32calvadosxeqi: hm let me check it thanks
22:34calvadosoh neat yes it looks like.
22:34calvadosthanks again
22:39Shambles_Yesterday when I asked about the reason for .core to be appended someone said it was because having a undotted path was a bad idea. Would someone explain why, please?
22:55uvtcShambles_, hi. I think it's just to avoid name collisions. If you've got a project named "foo-bar", you start off by putting your code into foo_bar/core.clj, and those functions are in the foo-bar.core namespace.
22:56uvtcIf you then want to add more namespaces (namespacen?) to your project, they can go under the top-level name as well (foo-bar.util, foo-bar.whatever).
22:57uvtcWhen people use your project, everything lives under foo-bar (foo-bar.core, foo-bar.whatever). Nice and neat.
22:58uvtcIn the Perl world they address the issue by making dir names the same as module names. That is, FooBar.pm (the module), and FooBar/Baz.pm (the submodule -- FooBar::Baz).
23:00Shambles_uvtc: So there's no 'root' namespace in a project. All of them start under the project directory name? You can't have a a -main under foo-bar? It has to be foo-bar.<something>?
23:01xeqialso when using aot it would create a java class in the default package, which can cause confusion
23:01uvtcShambles_, I follow the example that Leiningen sets. :)
23:02Shambles_uvtc: Yes. Python works that way, and made sense to me. It also forced you to use namespaces (every file starts a namespace), which has turned out to be a benefit much like forcing people to indent their code properly.
23:03Shambles_I can't puzzle out what "aot" would be.
23:03xeqiahead of time compilation
23:03Shambles_uvtc: I'm just trying to figure out why it 'sets that example'. I don't see any inherent problems with having things defined under the project's namespace.
23:05cgagShambles_, do you mean you want your main file to to just be called foo-bar, rather than core?
23:05mmarczykthat happens even when not doing aot, e.g. (defn foo ...) at the REPL causes a class called user$foo to be created in the default package
23:07mmarczykthat's not to say that it's a good idea; putting stuff in the default package causes serious weirdness to ensue
23:16Shambles_cgag: Well, I suppose what I'd be used to, and expect, is to have a directory named <your project here>, with a file named <your project here>.clg and then subdirectories for the subsystems in my project under that, with matching file names. Each file having a matching namespace.
23:16Shambles_I'd like to know about the serious weirdness.
23:20cgagi think the way it works is the namespace translates to a filename, so if your namespace was just foo-bar, clojure would look for foo_bar.clj in your source directory
23:20cgagso i think you could do that, and have your subdirectories have the namespace subdirectory.filename
23:21Shambles_cgag: Yes.
23:21Shambles_Sorry, that was a reply to something a way back there.
23:22mmarczykyeah, it should mostly work, until it breaks :-)
23:22mmarczykthe most seriously weird issue I personally experienced was with profiling
23:22xeqiis there a way to list the dynamically generated class names?
23:22Shambles_mmarczyk: So if I do what I just described I might see strange things in the profiler?
23:24mmarczykI think the code actually worked, but I couldn't watch some methods of interest... it's a hazy memory though
23:24mmarczykwhat is certainly out of question is Java code being able to import a class from the default package -- that is disallowed by the language spec
23:25mmarczykadmittedly not a big deal for Clojure code most of the time
23:28mmarczykI'll also admit that I'm not sure if the profiling issue could have been solved by a knob in visualvm -- adding ".core" was easier than investigating that
23:28Shambles_mmarczyk: So what I described wouldn't work in Java? Java programs always have a 'extra' name in front? I hope they don't have a <extra>.<useful-name> for every sub-directory (with "extra" being the directory part, and "useful-name" being the file part).
23:29mmarczykthey do, actually
23:30Shambles_mmarczyk: Oh my... I'm going to have to work to blugeon things into a reasonable looking hierarchy then.
23:31mmarczykJava classes tend to be called things like com.google.whatever.Foo or org.apache.commons.Bar
23:32mmarczykClojure projects tend to use a core.clj namespace much like Python uses __init__.py files, except you can't leave out the .core part in a :require
23:33mmarczyklocal conventions
23:34technomancy.core generally stems from a lack of imagination more than anything else
23:35gfrederickstechnomancy: are you calling The Core unimaginative?
23:35mmarczykarguably this lack of imagination is helpful when trying to get a rough idea of what a new project's public api looks like
23:36Shambles_Thanks to everyone for helping me.
23:36technomancygfredericks: absolutely: http://en.wikipedia.org/wiki/The_Core
23:36gfredericksThe definitive science fiction film of the 21st century?
23:37technomancy> Elvis Mitchell, of the New York Times, said, "The brazen silliness of The Core is becalming and inauthentic, like taking a bath in nondairy coffee creamer."
23:37technomancynice metaphor
23:37gfrederickssimile?
23:37technomancyoops
23:38technomancy"On March 30, 2009 it was reported that Dustin Hoffman was leading a campaign to get more real science into science-fiction movies." <- go Hoffman!
23:38gfredericks? who do you talk to about getting that done?
23:38gfredericksbono?
23:38Shambles_I can tell I'm going to have trouble getting used to Java's way of doing things. Fans of most languages would not approve of the 'extra' bit on the namespace, (com.big.non-semantic.wad.here.before.what.you.care.about) especially given the pain involved if you wanted to always use the full path (considered good practice in at least Python, since it makes it clear 'where things come from').
23:38technomancygfredericks: who else?
23:39mmarczykShambles_: some people do use the Java convention, though (using an organization name or sth along these lines to prefix namespace names and no .core namespace; e.g. net.cgrand.enlive-html)
23:39gfredericksShambles_: using the full path is not idiomatic clojure
23:39technomancyShambles_: it's especially fun when the project transfers to a new owner and you have to update all your code that depends on it
23:39gfredericks(:require [com.big.non-semantic.wad.here.before.what.you.care.about :as about])
23:40Shambles_gfredericks: I think I'd have to do it that way for my sanity, even if people did poo-poo me. :P
23:40cgaggfredericks, yeah i think that's how it's usually done in python as well isn't it?
23:40xeqitechnomancy: was sed broken?
23:40gfrederickscgag: I know nothing of python
23:40gfredericksxeqi: I was thinking the same thing
23:40technomancyxeqi: apparently!
23:40mmarczykShambles_: Python does use __init__.py files, so the directory structure of more complex packages is pretty much the same
23:40gfredericks"...two days of downtime due to a massive sed outage..."
23:42Shambles_cgag: You /can/ do that in Python. You can also import everything directly into your namespace, or only certain parts, so it has no prefix at all, but it's generally been found to be more readable if you type the path out, since they're short in Python, and it tends to make it clearer where everything is defined.
23:42mmarczykShambles_: importing the main namespace is shorter, but :require :as is perfectly idiomatic Clojure (I actually think :require specs w/o :as are the minority)
23:42eggsbymm, packages in python you just have on your $PYTHONPATH
23:43mmarczykShambles_: you can also pull in individual names or all names from a namespace into the current namespace with :require :refer or :use (same result, different syntax)
23:43eggsbysite-packages or w/e
23:44Shambles_mmarczyk: The only difference between Java and Python's way of namespace handling is the 'extra' path due to every directory (in the Java way). That's the part that's giving me "heartburn of the brain" at the moment.
23:44Shambles_mmarczyk: Yeah, so that part is like Python.
23:48mmarczykShambles_: well what I'm saying is that any Python "package" (a collection of modules -- I realize this is an overloaded word in Python lingo) complex enough to be split into multiple files will likely have the same structure
23:48mmarczykShambles_: for example the pygments module is defined in a file called pygments/__init__.py
23:49mmarczykShambles_: with ancillary modules called pygments.foo defined in files called pygments/foo.py which live alongside it
23:50Shambles_mmarczyk: Right, but to refer to things I'd type "pygments.thing_I_care_about" not "pygments.__init__.thing_I_care_about".
23:51eggsbyI'm not sure what the correlary is, you don't do that in clojure either.
23:51mmarczykShambles_: sure, and you can do that in Clojure at the cost of a few extra characters (and in fact everybody does it) -- far from a big deal
23:52eggsbyPython just uses the file structure for its module namespacing, clojure explicitly defines it in the ns macro
23:52Shambles_mmarczyk: What I'm thinking about, for example, is wanting to have a "main" file with my "main" procedure to set up a program, and then say a subdirectory for the GUI stuff. Unfortunately the Java way this makes me have to type "project.main.main" and "project.gui.gui", with the stutter due to the directories forcing their way into the namespace path.
23:52Shambles_mmarczyk: I could work around this, except for the 'main' issue, now that I know about it. I'd probably try not to have something with the same name as the directory in subsystem.
23:53mmarczykShambles_: what main issue?
23:53mmarczykShambles_: you need to have one dot in your namespace names to be safe
23:53Shambles_mmarczyk: the "main.main" part instead of just "main".
23:53eggsbyoh, rename the core part of your module 'core'
23:53eggsbyisntead of project/gui/gui.clj use project/gui/core.clj
23:54mmarczykShambles_: so you'd call your main namespace project.main
23:54mmarczykShambles_: and you can totally call the gui namespace project.gui
23:54Shambles_eggsby: Yes, I was trying (and apparently failing) to get my issue across. Basically I don't like directories causing names to be inserted in the namespace path. I'm not used to that.
23:55mmarczykShambles_: just don't use "project" (with no dot) as a namespace name
23:56Shambles_mmarczyk: I'm aware I can call them that, but I won't want to. I don't want functions to have the same name as the directory, since it reads bizarrely. I'll do my best to 'hide' the fact that the directories are being included in the path, to avoid the stutters you'd get with a directory and function having the same name.
23:56eggsbyShambles_: I came from python exclusively to clj, I've enjoyed it a lot
23:56Shambles_mmarczyk: And yeah, I'm sure I could hide the stutter with import notations, but I'd rather not.
23:57mmarczykwhatever floats your boat
23:57mmarczykjust trying to give you all the options.
23:57cgagmoving from python to clj feels to me the way moving from c++ to python did
23:58Shambles_I've found I 'need' Lisp occasionally, but rarely, which is why I'm trying to move to it from Python myself. I ended up with Racket for the programming features (I'm having issues with the I/O though), and Clojure for the fancy I/O. At least that's what I'm trying to settle on.
23:58RaynesMan.
23:58RaynesAll you Python guys should do me a solid.
23:59eggsbyShambles_: I think that defining your namespace per file is cleaner than defining one global module/namepsace per directory w/ __init__.py
23:59RaynesIf you want a fun little project that exercises both your Clojure and python skills, change refheap to not shell out to pygments and instead call it directly via jython.