#clojure logs

2011-08-20

00:00srideg: here's the most voted question with [clojure] tag asked last week, http://stackoverflow.com/questions/7064389/
01:58dabdI did require [incanter.core :as i] but when I try to load a file in the repl it says Could not locate incanter/core__init.class or incanter/core.clj on classpath:
02:01dabdI pulled the deps with lein deps I don't know why it cannot find incanter.core
02:01dabdany ideas?
02:47srid'lein new' generates a basic project layout; are their alternative layouts? eg: a command-line project with opt parser and such.
02:50Pupenosrid: there might be plugins for that, lein-noir for example generates a web app by lein noir new, but it's not really an alternative layout, just another task.
02:51amalloyi don't know about lein, but cake lets you store project templates in ~/.cake, and you can specify which template to use when you new one up
02:51ibdknoxsrid: I've thought about potentially making a general purpose project template plugin
02:51ibdknoxI actually thought someone had
02:51sridsomething like python's pastetemplate
02:51ibdknoxthough I can't remember what it's called now
02:52sridi don't seem to find it in https://github.com/technomancy/leiningen/wiki/Plugins either.
02:54ibdknoxah
02:54ibdknoxhere it is
02:54ibdknoxhttps://github.com/levand/spawn
02:55PupenoIn a lein plugin I'm writing, I'm doing (eval-in-project project `(do (require 'lobos.config) (println lobos.config/db))) but it fails saying that lobos.config can't be found. But it's there, lein repl and (require 'lobos.config) works. What am I missing?
02:56amalloy&`'lobos.config
02:56lazybot⇒ (quote lobos.config)
02:56amalloyk, just testing
02:57sridwhat is the currently fashionable way to get a clojure app running on appengine? there are a quite a few, eg: https://github.com/sethtrain/beget
02:58sridah, i'm beginning to feel eye strain and head ache ... must get some sleep!
02:59ibdknoxsrid: here's the relevant noir post
02:59ibdknoxabout appengine
02:59ibdknoxhttps://groups.google.com/d/topic/clj-noir/5a-3mYzs8dA/discussion
03:01Pupenosrfixed.
03:01Pupenosrid: fixed.
03:02amalloyhah, the hidden dangers of tab completion
03:51MasseRIs anyone of you using slimv? Has the cw command changed for you?
04:09babilenMasseR: I use it for paredit (and vimclojure for the rest) -- The cw command works as expected.
04:16MasseRbabilen: Normally cw deletes a word until space. Now it removes the space too
04:17babilenMasseR: I know, but as I said: It is working as expected here.
04:18MasseRSo you still get the behaviour, but it's something you want?
04:20babilenIf "this behaviour" == "deletes the space" then no. cw behaves as it should and does everywhere else.
04:26MasseROk
04:32PupenoIn a lein plugin I can do (require 'lobos.config) but when I do (println lobos.config/db) I get an error which, as usual, doesn't help at all (Exception in thread "main" java.lang.ClassNotFoundException: lobos.config (NO_SOURCE_FILE:1)). It doesn't mention lobos.clj anywhere in the stack trace, which is the only file in the lein plug in. Any ideas what's going on?
05:33NetpilgrimHi. I'm still in the process of learning the basics. Are there cases where (some_map k) and (some_set e) instead of (get some_map k) and (contains? some_set e) don't work? And which versions are considered more ideomatic/better style?
05:34Netpilgrims/ideomatic/idiomatic/
05:34lazybot<Netpilgrim> Hi. I'm still in the process of learning the basics. Are there cases where (some_map k) and (some_set e) instead of (get some_map k) and (contains? some_set e) don't work? And which versions are considered more idiomatic/better style?
05:35NetpilgrimCool feature. I didn't know the bot would do that. :)
06:05thorwilNetpilgrim: i'm not even aware of (get some_map k), while (some_map k) is common
06:12thorwilNetfeed: oh, and contains? will evaluate to true or false, not deliver an element or nil
06:12Netpilgrimthorwil: OK, thanks. I thought that the shorter variant is probably more widespread but to me as a beginner the longer form looks more readable. It's probably just a matter of getting used to the syntax.
06:13Netpilgrimthorwil: I know that (contains? s e) is not a replacement for (s e) but it works the other way around.
06:15Netpilgrimthorwil: The use of (s e) for conditions also seems consistent with a somewhat similar case I've read somewhere, namely using (seq coll) instead of (not (empty? coll)).
06:16thorwilthe (:k m) and (m :k) is certainly one of the things you have to know, but once you do, it makes for lovely concise code.
06:18Netpilgrimthorwil: The (m :k) variant is probably better because it works with all datatypes as keys?
06:19thorwilNetpilgrim: i actually keep forgetting that both orders do not work for all cases, as most of the times i only have keywords :)
06:20Netpilgrimthorwil: Thanks for your input.
09:34dabdIf you change project.clj by adding a new depency do you have to stop the swank server and run lein swank again or there is another way? lein deps seems to not work because I get class not found error when loading a source file containing a require from the new dependency.
09:41tufflaxI think lein deps, then restart swank should work, if not check spelling :P
13:01schlechtvHow can I make this not fail: (use clojure.contrib.strint) (def tmplt "Here is a silly string with a number ~(int x)") (let [x 5] (<< tmplt))
13:22dnolenso anyone use Erlang bit pattern matching much?
13:32KirinDaveIn erlang?
13:32KirinDaveYes.
13:32KirinDaveIt's frikkin' amazing and Erlang programmers love it.
13:33KirinDaveYou haven't really enjoyed writing streaming byte protocol code until you've done it in Erlang and realized your code actually is fairly descriptive of the binary protocol.
13:33dnolenKirinDave: so I'm think doing the same thing in match would be trivial.
13:34dnolenKirinDave: do you have any public code lying around where you've used it? I've looked over the Erlang syntax but curious to see some real examples.
13:34KirinDaveUhhh….
13:34KirinDaveI actually don't have any public code
13:35KirinDaveIt was custom protocol stuff for powerset.
13:35KirinDaveSorry!
13:41dnolennp, should be fun in Clojure.
13:59robonobohi guys
14:00robonobodoes the fact that some results are seqs and others are vectors in the unittests for http://4clojure.com/problem/39#prob-title seems strange to anyone?
14:05opqdonutyeah, but:
14:05opqdonut,(= [1 2 3] '(1 2 3))
14:05clojurebottrue
14:43belunhello.
14:43belunknow any small well writen open source java projects that i could write in clojure ?
14:43belunas in translate
14:44belun(for fun)
14:44tufflaxwhy don't you solve a new problem instead? :p
14:45belunmust not be bothered with the details
14:45belunof business
14:45belunlogc
14:45tufflaxof business?
14:46belunum... what the app does
14:46belunbusiness logic
14:47jlidnolen: are you working on bit patterns for match?
15:07csquaredhowdy guys — i'm having a real tough time setting a response cookie using compojure
15:07csquareddocs are kind of thin
15:07csquaredcan anyone point me to an example?
15:07csquaredor how i would add a cookie to this line?
15:07csquared(-> (response "You're in!") (status 200))
15:08csquaredi've got the route wrapping it (wrap-cookies)
15:08csquaredfyi i'm a clojure n00b as well : |
15:10mdeboardthink most people are :P
15:10csquaredheh
15:10csquaredyeah i was working with a friend and doing OK with passing back the hash maps
15:10csquaredthen this "->" thing showed up
15:11csquaredi think i just need to get a :cookies key into the reponse
15:11mdeboardthat's actually a really awesome macro ;)
15:11csquarednot knocking it
15:11csquaredit just took things out of my level of understanding atm
15:11csquaredi know its the "threading marco"
15:11mdeboardyeah i'm not real familiar with using HTTP in Clojure,so I can't help :(
15:12csquaredmaybe we can help me understand that line though
15:12csquaredor what its doing?
15:12csquaredor just a link to a doc?
15:12csquaredi've been googling "clojure ->"
15:13csquaredok Other macros re-arrange forms in useful ways, like the -> macro, which recursively inserts each expression as the first argument of the next expression:
15:14tufflaxcsquared u got it now? :p
15:14csquaredso its kinda of like an inject?
15:14csquaredi'm thinking it need an (assoc :cookies …) at the end
15:14tufflax,(-> 2 - str)
15:14clojurebot"-2"
15:15tufflaxsame as (str (- 2))
15:15tufflax,(-> 2 (- 5) (str "!"))
15:15clojurebot"-3!"
15:16csquared,(-> {:body ""})
15:16clojurebot{:body ""}
15:16tufflaxsame as (str (- 2 5) "!")
15:17tufflaxit doesn't do anything with just 1 argument :p
15:17csquared,(-> {:body ""} (assoc :cookies {:name "cookie-value"}))
15:17clojurebot{:cookies {:name "cookie-value"}, :body ""}
15:18csquaredthis looks promising
15:18csquaredalso, clojurebot is aweseom!
15:18tufflaxhehe
15:18csquaredHOLY SHIT IT WORKED!
15:18tufflax,(doc ->)
15:18clojurebot"([x] [x form] [x form & more]); Threads the expr through the forms. Inserts x as the second item in the first form, making a list of it if it is not a list already. If there are more forms, inserts the first form as the second item in second form, etc."
15:18csquaredthanks gentlemen!
15:18csquaredor ladies
15:19tufflaxno problem :)
15:19belunor bots
15:19csquaredlol shouldn't always assume CS people are men...
15:19csquaredhahah
15:19csquaredturing test FTW
15:20csquaredfyi this is what worked:
15:20csquared(-> (response "You're in!") (status 200) (assoc :cookies {:name "value"}))
15:21tufflax,(doc ->>)
15:21clojurebot"([x form] [x form & more]); Threads the expr through the forms. Inserts x as the last item in the first form, making a list of it if it is not a list already. If there are more forms, inserts the first form as the last item in second form, etc."
15:21tufflaxIf you ever need it :p
15:38dnolenjli: yes
16:04sridwhere do people generally host their Clojure web apps?
16:08chousersrid: I've used heroku, looked at CloudBees and heard about ways to use Google's appengine
16:18ibdknoxsrid: EC2
16:18ibdknoxsrid: Heroku and elastic beanstalk are probably the easiest
16:18ibdknoxbeanstalk is significantly cheaper
16:39sridi'll go with appengine for now.
16:40sridwhat would be the rake-like tool for clojure?
16:40sridruby's rake or node's cake
16:43amalloysrid: cake and lein are the main tools for that
16:44sridthere doesn't seem to be a obvious way to define tasks in lein, but there is apparently in cake: http://stackoverflow.com/questions/3906276/whats-the-difference-between-cake-and-leiningen
16:47patchworkIt's easy to add tasks to lein. You create a src/leiningen/command.clj with a function named "command" and you can call it from the command line:
16:47patchwork> lein command
16:47hsbot Not in scope: `lein'Not in scope: `command'
16:47patchworkoops, triggered evaluation
16:47patchworkwhat is this hsbot? I am new to the channel
16:47amalloyhaskell
16:48patchworkah nice!
16:48amalloynobody knows why he hangs out in here
16:48amalloy$heval [1..5]
16:48lazybot⟹ [1,2,3,4,5]
16:48amalloyespecially since lazybot does haskell too
16:49patchworkis there a clojurebot as well?
16:50srid$(+ 2 3)
16:50amalloy,(inc 2)
16:50clojurebot3
16:50amalloy&(inc 2)
16:50lazybot⇒ 3
16:50srid$pyeval raise SystemExit
16:50sridheh
16:51patchworkwe're still here
16:52patchwork,(defn yoyo [a] (* a 3))
16:52clojurebot#<Exception java.lang.Exception: SANBOX DENIED>
16:53patchworkaha
16:53sridpatchwork: can't find docs for writing command.clj in lein docs; is there a sample?
16:55sridwait, should the actual command name be in the filename (command.clj) or in the function name?
16:55patchworksrid: not sure where I found it, but I have a couple of commands in my project
16:56patchworkit should be a command named "command" in a file called command.clj
16:56patchworkor better yet, the function name should have the same name as the file
16:56sridso if I want to have a command called "lein serv" - i should create a function called "serv" in src/leiningen/serv.clj?
16:56patchworkYep
16:57patchworkthat works for me at least
16:58coopernursesrid: yep. note that you can also dispatch on a 2nd argument if you want to support sub-commands from a single lein plugin. e.g. lein ring uberwar
16:58srid$ lein serv 1 ↵
16:58sridException in thread "main" java.lang.Exception: No namespace: leiningen.serv found (NO_SOURCE_FILE:0)
16:58sridoops; sorry for the whitespace.
16:59coopernurseas an example of a working plugin, take a look at: https://github.com/weavejester/lein-ring/blob/master/src/leiningen/ring.clj
16:59coopernursesrid: what dir are you executing lein in? I assume the project dir that contains your 'src' dir?
17:01sridcorrect; the error was due to my forgetting to include a (ns ...) statement.
17:01coopernurseah
17:01patchworkso it worked then?
17:01sridyes, worked for a simple `println` function.
17:03sridthe slow startup time of java apps seems annoying.
17:04coopernurseyeah, jvm startup time is rough on lein. but for regular development you can write code in the REPL
17:06srid,#'foo
17:06clojurebot#<CompilerException java.lang.RuntimeException: Unable to resolve var: foo in this context, compiling:(NO_SOURCE_PATH:0)>
17:07amalloyyou can also start a lein shell, which is supposed to reduce startup time pain
17:07patchworkso, I am having a problem with exceptions using postgres through jdbc
17:07coopernurseamalloy: ah, didn't know that.. good to know
17:07patchworkwhenever something goes wrong with the db call, I get something like this:
17:07amalloylein int
17:07patchworkjava.lang.Exception: Call getNextException to see the cause.
17:08patchworkbut when I try to call (.getNextException e)
17:08patchworkI can't, because it is not a SQLException?
17:09patchworkI feel like the jdbc library is throwing everything up as java.lang.Exception, even if it is a java.sql.SQLException
17:09coopernursepatchwork: try (.getCause e)
17:09patchworkso that I can't find out what the actual problem was
17:09coopernursehaven't tried it, but that should give you the next exception down
17:09patchworkcoopernurse: thanks, I'll try that
17:10patchworkcoopernurse: Aha, so I need to say (.getNextException (.getCause e))
17:10patchworkthe cause is the sqlexception
17:10patchworknot the original one
17:10coopernursepatchwork: ah, there you go
17:11patchworkthank you much
17:11patchworkwrestling with that one for awhile
17:13coopernurseno problem - error message was misleading
17:13sridI can't seem to specify https://github.com/clojure/tools.cli as a dependency in project.clj; `lein deps` cannot find it. is it because, tools.cli was never uploaded to clojars.org?
17:17coopernursesrid: yeah, looks like it's not in clojars
17:18coopernurseyou could try clojure.contrib.command-line instead - http://clojuredocs.org/clojure_contrib/clojure.contrib.command-line/with-command-line
17:18amalloyclojure/core stuff never goes on clojars, does it?
17:20coopernurseamalloy: oops, good point
17:20amalloyto be fair, i checked too
17:21coopernurseI don't see it bundled in 1.2. Perhaps it's a 1.3 addition?
17:23sridwasn' clojure.contrib.command-line replaced with tools.cli?
17:25raekthe official clojure libs are not usually on clojars, but in some other repo
17:30sridhow would I then define tools.cli as a dependency to be fetched via 'lein deps'?
17:32sridfound it http://mvnrepository.com/artifact/org.clojure/tools.cli -- [org.clojure/tools.cli "0.1.0"]
17:36polypus74i haven't looked into this in over six months. any news on the async http front? what would currently be the best way of doing websockets in clojure?
17:37sridamalloy: 'lein shell' doesn't work; shell is not a command.
17:37amalloylein int
17:38amalloypolypus74: aleph has websockets, doesn't it?
17:39polypus74amalloy: i believe it does, was just wondering if there had been any more recent developments. there is a branch of ring with async, but it doesn't look like it's moved much. was hoping for some simple solution i could just drop into a regular ring app. maybe ontop of jetty or even netty
17:40polypus74aleph might just be the way to go though
17:47coopernurseis there any equivalent to (time) that monitors heap usage? I want to do some crude memory profiling of my code.
17:49coopernursenow that I ask that aloud I'm not sure exactly how it would work. perhaps just return heap size delta before/after the inner function executes..
17:49coopernurselooks like I could roll my own using java's Runtime class
17:53sridinteresting, clojure core doesn't include a http client, and I need to use clj-http.
17:54amalloycoopernurse: so long as you don't mind that gc will generally not happen right away, so heap size will continue to go up even if you've discarded all the temporary objects you allocated
17:54coopernurseright
17:54coopernurseperhaps you could run gc manually
17:54coopernursebefore/after
17:55amalloydepends on what you want to measure
17:55amalloyif you care about churn, then don't gc; you can see how much was allocated during the run
17:55amalloyif you care about depletion, then you want to see if the function uses any "permanent" memory
17:58coopernurseright.. and of course, if it does anything non-trivial, gc will get run concurrently, making it hard to measure
18:02amalloyyep. that's what profilers are for
18:04amalloybut getting out something as fine-grained as you want will probably be hard
18:08coopernurseyeah, well, this gives me an excuse to learn how to write a macro, even if it's a useless one :-)
18:09sridapparently clj-http seems to be unmaintained.
18:20memothyHello everyone. I've never used Clojure before, but I'm familiar with java and scheme. I'm just starting to feasibility-test some algorithms for the android platform. REPL sounds appealing for quick and dirty prototyping, but I'd like to make sure that I'm barking up the right tree here.
18:22memothyWith Clojure coupled to the jvm, can I integrate numeric libraries from java trivially, or are some sort of bindings required?
18:26memothyAnd poking around online, I noticed someone complaining that Clojure paused an android device for ~10s before necessary bootstrapping code loaded. While I would ultimately remove Clojure from the final result, after this bootstrap process would benchmarks run on an android device approximate performance in a pure java setting (and maybe even provide worst case performance data)?
18:30memothyI'm just starting to read `the joy of Clojure', but as I said, I'd like to know whether the language is suitable as a prototyping language. I anticipate quick prototypes that use the same libraries that I would later incorporate into a pure java project hosted on the android platform.
18:37coopernursememothy: you can invoke java libs directly from clojure without bindings
18:37coopernurseso it should be suitable for prototyping java apps
18:39coopernurseexample of calling java swing classes from clojure w/o clojure specific bindings: http://clojure.org/jvm_hosted
18:39memothysweet. do you know of any performance data comparing java performance to clojure performance under different numeric (and maybe string) libraries?
18:40coopernursehmm.. I'm aware of this site: http://shootout.alioth.debian.org/
18:41coopernursewhich has general language benchmarks.. java and clojure are represented
18:41coopernursebut I'm not sure if that's what you're after
18:45memothyat a glance the testing schema is confusing ('fastest program versus fastest program'...huh?). but if I'm calling without bindings, then I imagine that performance under Clojure reflects worst case performance under java. that's a sufficient condition at least, right?
18:46polypus74memothy: note links under performance bullet here: http://disclojure.org/2011/08/15/today-in-the-intertweets-aug-15th-ed/
18:48coopernurseyes, it's hard to speak precisely, but clojure compiles your .clj source to jvm bytecode, just like javac would for .java source. so it sort of comes down to your implementations in the two languages
18:48coopernursemy guess is if you profiled the swing example I linked to above and compared it to the same code in java, the resulting byte codes are probably similar
18:49coopernursesince the clojure code is written in a largely imperative style, and is just invoking java classes for the most part
18:49coopernursebut if you compared solutions to a mathematical problem, say a project euler problem
18:50coopernursethen the code you'd write in clojure vs java would likely be really different, so the resulting bytecode would be quite different too
18:51NetpilgrimI'm trying to get the hang of seqs. What is the rationale behind (seq '()) being nil when there are in fact empty seqs like the return value of (rest '())?
18:52memothyso writing solutions within the idioms of each language, performance is a toss-up, but so long as I'm simply filling java data structures and operating on them with java libraries, then I can expect similar performances, yeah?
18:53memothyAnd thanks polypus74 for that I link. I'll probably be exploring that domain in general, as well.
18:54coopernursememothy: I suspect that's right. if you used clojure as a tool to script java libraries, I suspect you'd get pretty similar perf -- but perhaps with some reflection overhead. there are some type hints you can throw in to help the clojure compile avoid reflection
18:55coopernurseyou mentioned android
18:55memothyWell thanks, coop. I'm off to the library. In a month or so I ought to have some results specifically on Clojure as a java prototyping tool.
18:56memothyOh, yeah.
18:56coopernurseI'm not sure how the dalvik vm compares, or how jvm bytecode is translated to run on dalvik
18:56coopernurseso that may introduce some differences, not sure
18:57coopernurseto clarify: the converted bytecode written in clojure should work (folks have written android apps in clojure) but I'm not sure if it changes the perf profile at all
18:58memothyMy motivation for ultimately working with Clojure--I figure if I use the same libraries that I will eventually use in my project, then the coding should be much cleaner (and anything but Octave/MatLab for prototyping).
18:59memothyOf course I'll research it better before I throw away my prototypes and code the project's core, but I already have sufficient motivation to learn Clojure as a prototyping tool.
18:59coopernursememothy: makes sense. it's definitely a fun language to learn
19:00memothyI'm sure I'll eventually find my way back to that ~10s claim, but for now I feel comfortable proceeding.
19:00coopernurseREPL makes experimentation way faster
19:00memothyThanks for the help. I'll probably become a regular around here, so I'll see you around.
19:01coopernursecool, see you
19:36chewbrancaanyone have a recommendation for a reliable http request clojar?
19:37chewbrancaeverytime I come back to clj-http something different has happened, and now the getwoven repo is gone
19:43ibdknoxtechnomancy: ping
20:44sridchewbranca: i wonder if there is even an alternative http lib.
20:45sridi was battling with myself as to writing a gzip decompress code in clojure to decode a gzip encoded http response. my java knowledge seems insufficient.
20:57chewbrancasrid: yeah I dealth with the same thing a few months ago, the getwoven/clj-http had a bug in it breaking gzip responses, and hadn't been updated in quite a while, so I found a fork that fixed the gzip issue but wasn't on clojars, then I saw a few months ago that get-woven brought in the pull requests fixing things, now the repo is gone :/
20:57chewbrancasrid: let me see if I can find that fork that worked, just a sec
20:59sridgetwoven doesn't have a clj-http repo
20:59chewbrancasrid: heh.. yeah that's my point
20:59sridclj-http doesn't seem be maintained; there are a bunch of pull requests here without any update - https://github.com/mmcgrana/clj-http/pulls
20:59chewbrancasrid: getwoven created clj-http, repo is no longer there
21:00srid28 forks, but only 5 people watching?
21:00sridthat's strange, usually more people watch a repo with less forks.
21:02sridC was my first programming language, and whilst learning it (2001) I remember spending whooping two hours just to write a program to print the multiplication table. something like that is happening with me when writing Clojure. :-)
21:03chewbrancasrid: haha clojure is good times, really enjoying working with it
21:15zmarilHow does one go about creating an infinite sequence?
21:19srid,(iterate inc 1)
21:19clojurebot(1 2 3 4 5 ...)
21:22wastrelclojurebot, botsnack
21:22clojurebotThanks! Can I have chocolate next time
21:23joshuahickmanWhere precisely did clojurebot come from?
21:23joshuahickmanI know he can do code eval and such
21:23joshuahickmanAnd it seems every time I visit I see a new thing someone programmed him to do
21:23joshuahickmanWhich is to say, is he open source?
21:24joshuahickmanOn a more clojure related note:
21:25joshuahickman#() syntax macroexpands, it seems, to (fn [%] ...), but does not make a function literal at compile time
21:25joshuahickmanI presume this is for simplicity's sake?
21:26wastreli sure don't know
21:26wastrelre clojurebot
21:26joshuahickmanBecause it confused me right good earlier
21:27joshuahickmanOh, yeah :)
21:27joshuahickmanThat #() confused me earlier, because I did a
21:27joshuahickman(-> 2 #(+ 2 %))
21:27joshuahickmanBasically
21:27wastreli dunno from clojure either :]
21:28joshuahickmanAnd I thought it would work, not unreasonably, imo
21:28sridcould somebody explain why I keep getting "Not in GZIP format" error when gzip decompressing a gzip-encoded HTTP response? here's the code: https://gist.github.com/1159952
21:29sridi'm pretty the implementation of gzcat is ugly. just trying to get something working first.
21:29srid*pretty sure
21:30zmarilsrid: thanks. I was trying to do a prime list and I was trying to think of the right question to ask. It works sort of now: https://gist.github.com/1159955
21:30joshuahickmanI might be looking at old docs, but it seems like that read function might take more arguments
21:38sridclient/get returns String; shouldn't that be Bytes?
21:38sridmaybe that's why the original gzipped bytes are lost.
21:39sridnote my use of (.getBytes string) -- I believe that uses utf16, and unicode makes no sense with bytes.
21:48toast`ah, so you got ascii -> unicode string -> utf16le bytes… yeah, that's not an identity
21:50tufflaxjosh what did you think would be the result of (-> 2 #(+ 2 %))?
21:50tufflaxjoshuahickman
21:50joshuahickman2
21:50joshuahickman*4
21:50joshuahickmanTHAT WAS A TYPE
21:50joshuahickman*TYPO
21:50joshuahickmanWow
21:50joshuahickmanI am not actually stupid
21:50tufflaxlol
21:50joshuahickmanI wish to convey this
21:50tufflaxlol
21:51tufflaxwhy 4? i mean, it doesn't give the previous result as an argument, it simply inserts it into the next form
21:51joshuahickmanYeah, I was anticipating I would get a function literally just like (-> :a {:a 4})
21:52darevayQuestion: there's a saying something like "write code that shows how to solve the problem, not what to do", or something like that. Anyone got a reference or at least, less mangled quote?
21:52joshuahickmanYeah, but when I put a symbol (as in, not a list), it applies that to the previous argument
21:53tufflaxno
21:53joshuahickmanPerhaps I'm not articulating
21:53tufflaxit builds a list and puts it second
21:53joshuahickmanYeah
21:53joshuahickmanIt does this for all non-lists
21:53tufflaxit has nothing to do with arguments, just with putting things in lists
21:54joshuahickmanYeah, I understand that's how it's implemented
21:54joshuahickmanI'm just saying it violated expectations because it looks like a literal syntax
21:54joshuahickmanLike sets and maps
21:54joshuahickmanIt does not look like a macro
21:54joshuahickmanDoes that make sense as a reaction?
21:54joshuahickmanPerhaps I am insane
21:55dnolen,(-> 2 (+ 2))
21:55clojurebot4
21:55tufflaxyou mean #() looks like literal syntax?
21:56joshuahickmanThe example I was actually trying to do was #(.split % "\\.") , but that's neither here nor there
21:56joshuahickmanIt does
21:56joshuahickmanI anticipated it resolving, at compile time, to an object
21:56joshuahickmanAlthough it being a closure might make that tricky
21:56joshuahickmanI was just curious if this is something people had thought about
21:58dnolen,(-> "foo.bar" (.split "\\.") vec)
21:58clojurebot["foo" "bar"]
21:58tufflaxBut -> does not handle objects, it handles syntax. And so, if #(+ 2 %) counted as a list, it would have become #(+ 2 2 %), and if it would #() would expand first then, (fn 2 [%] (+ 2 %)), neither of which is 4
21:59tufflaxbut maybe you got that already :p
21:59joshuahickmanYeah, I noticed it was the second one
21:59joshuahickmanWhich, by the by, has one of the more confusing compile errors until I got it
21:59dnolenjoshuahickman: the problem is not #(), it's ->
21:59tufflaxhehe
22:00joshuahickmanSee, dnolen, it depends on what you think the problem is
22:00joshuahickmanI just changed it to (.split ""), but I was actually hoping the #() syntax acted more like {}
22:00joshuahickmanWhere it is not a list at all
22:01dnolenjoshuahickman: what I mean is, you don't understand -> does. if you do, you know you don't need #()
22:01joshuahickmanAnd then -> makes it into (#() xxx)
22:01joshuahickmanNot in this case, no, but when I saw that I got curious, is all
22:01tufflaxoh now i see what you mean
22:01joshuahickmanI would prefer you not assume I don't know how these things work
22:02tufflaxwhen you said object i though you ment like
22:02tufflax,+
22:02clojurebot#<core$_PLUS_ clojure.core$_PLUS_@1cd022c>
22:02dnolenjoshuahickman: I'm not assuming anything.
22:02tufflaxI misunderstood you josh :p
22:03joshuahickmanYeah, I was just pondering why the #() reader macro is the only one that *doesn't* output an object
22:04joshuahickmanI mean, {} could easy expand to (make-map key val key val)
22:04joshuahickmanBut it doesn't
22:04joshuahickmanThat's all I was thinking
22:04tufflaxI see
22:05tufflaxwell, object is a very vague term here i think :p
22:05joshuahickmanThat's true enough
22:05joshuahickmanI suppose I mean not a list
22:05dnolen,(macroexpand '(-> foo #()))
22:05clojurebot(fn* foo [] ())
22:05joshuahickmanClojure is really my first lisp where there are semantically meaningful non-list compile time constructs, so excuse the vagueries
22:06ibdknoxdnolen: sadly it appears I can't do the cljs-watch stuff as a leiningen plugin
22:06dnolenibdknox: darn.
22:06ibdknoxdnolen: since it would require lein to run as 1.3.0
22:07ibdknoxI did, however, get it as a single shell script
22:09dnolen,(macroexpand '(-> foo (#())))
22:09clojurebot((fn* [] ()) foo)
22:11joshuahickmanyes, precisely
22:11joshuahickman,(macroexpand '(-> :a #{:a}))
22:11clojurebot(#{:a} :a)
22:12joshuahickman,(macroexpand '(-> :a {:a :b}))
22:12clojurebot({:a :b} :a)
22:12dnolen,(-> :a #{:a})
22:12clojurebot:a
22:12joshuahickmanRight
22:12dnolen,(-> :a {:a :b})
22:12clojurebot:b
22:12dnolen,(-> {:a {:b {:c 1}}} :a :b :c)
22:12joshuahickmanBut you see how the macroexpansions I just did behave differently than the one for #()?
22:12clojurebot1
22:13joshuahickmanThe one for #() doesn't wrap in a list because the #() produces a list, not an IFn
22:14dnolen,(macroexpand '(-> 0 (for [x (range 10)] x)))
22:14clojurebot#<ExecutionException java.util.concurrent.ExecutionException: clojure.lang.ArityException: Wrong number of args (3) passed to: core$for>
22:15dnolenit's no different for anything else that would expand.
22:15joshuahickmanYes, but it *should* be different, and it should be different in the same way {}, [], and #{} are
22:16joshuahickmanThis is the purpose of literal syntax
22:16tufflaxwell josh here http://clojure.org/reader the data structures are under "reader forms" while # without { following are under "macro characters", but yeah... :p
22:17tufflaxis*
22:17dnolenjoshuahickman: except #() is not literal syntax. It's sugar. fn is the literal syntax.
22:17joshuahickmanaccording to the link above:
22:17joshuahickmanAnonymous function literal (#())
22:17joshuahickmanBut I see your point
22:18joshuahickmanI mean, the regexes seem to be literals, too
22:19dnolenjoshuahickman: #() is listed under the real list of literals. but yes, that's a bit confusing.
22:19dnolens/is/is not
22:19lazybot<dnolen> joshuahickman: #() is not lis notted under the real lis nott of literals. but yes, that's a bit confusing.
22:19dnolenerg
22:19joshuahickmanBut regexes aren't either
22:19tufflax:p
22:19joshuahickmanyeah
22:19joshuahickmanBut regexes work this way, albeit less usefully for ->, as they aren't IFn, as far as I know
22:20lobotomyhaha, lazybot does s/foo/bar/g when someone says s/foo/bar?
22:20lobotomybug spotted ;p
22:20joshuahickmanHold on a sec, I have to retreat to my code-lab
22:23joshuahickmanyeah, okay
22:23joshuahickman,(macroexpand (-> 2 #"" quote))
22:23clojurebot(#"" 2)
22:23joshuahickmanDeliberately contrived example
22:23joshuahickmanWhich is to say, we should probably figure out how to either clean up the docs
22:24joshuahickmanOr add in this feature to the next version of clojure
22:25joshuahickmanBecause it seems #() is the odd one out here, but not in a way that is documented, predictable, or advantageous
22:25dnolenjoshuahickman: it's probably too minor a point to draw much interest. your one of the few I've seen talk about it much.
22:25joshuahickmanOf course, I imagine this is likely the most inane silly detail
22:25joshuahickmanyeah lol
22:26tufflax'() acts the same way
22:27tufflax,(macroexpand '(-> 1 '(a)))
22:27clojurebot(quote 1 (a))
22:27tufflaxbut, maybe that is not documented the same
22:28joshuahickmanWell, that's interesting behavior
22:28joshuahickmanI mean, I'm not surprised by it
22:28joshuahickmanBut it never occurred to me
22:28joshuahickmanThat one makes sense, though -- you are producing a list
22:28joshuahickmanAnd -> looks for lists
22:29joshuahickmanIt certainly isn't the list you would like
22:29joshuahickmanBut at least the macroexpansion doesn't get muddled, as odd as that opinion sounds
22:29joshuahickmanI mean, the quote has to go somewhere
22:30joshuahickmanAnyhow, I always imagined '() working like @var
22:30joshuahickmanThat is was contracted to be identical to the function call
22:30joshuahickmanSo that's a plus
22:31tufflaxbut it does work like @
22:31tufflax,(macroexpand '(-> 1 @(a)))
22:31clojurebot(clojure.core/deref 1 (a))
22:31tufflax:p
22:31joshuahickmanThat looks the same
22:31joshuahickmanI'm confused
22:32joshuahickmanI mean, it's just deref vs quote
22:32tufflaxbut @(a) looks a bit strange
22:33tufflaxnot something one often sees i suppose
22:33joshuahickmanBut to the lisp reader, it doesn't matter if it is a list or a var, in terms of function or macro application
22:34joshuahickmanI mean, the deliberately contrived examples might be confusing :)
22:34dnolenall which is this too illustrate that -> is syntax transformation applied after other forms have expanded. there be goodness and there be dragons :)
22:34tufflaxyeah
22:34joshuahickmanlol Indeed, sir
22:35joshuahickmanI believe I'll use that to describe macros from now on
22:45tufflaxby the way joshuahickman you said you were trying to use #(.split % "\\.") in the ->, but I guess you realize by now that (.split "\\.") would work
22:45joshuahickmanyeah
22:46joshuahickmanActually, I think at the moment I just did a (let [splitByDot #(.split % "\\\.")] ...)
22:46joshuahickmanBecause I was tired
22:46joshuahickmanBut yeah, this wasn't a technical road-blocking issue
22:46joshuahickmanIt was quite surreal to hunt down that bug, though
22:46tufflaxcamelCase? eww
22:47joshuahickmanOh no! I got brainwashed by my java day job! :(
22:47joshuahickmanI'll use dashes next time
22:47joshuahickman:)
22:47tufflaxhehe
23:12ibdknoxhey folks
23:12ibdknoxif you're doing cljs stuff, you might find this useful: https://github.com/ibdknox/cljs-watch
23:23dnolenibdknox: does it avoid the jvm restart overhead?
23:23ibdknoxyessir
23:23dnolenibdknox: sweet, are you going to submit this to ClojureScript?
23:24ibdknoxI probably need to change it a little first
23:24dnolenibdknox: do it!
23:24ibdknoxbut yes, it probably should be :)
23:24dnolen:)