#clojure log - Aug 08 2011

The Joy of Clojure
Main Clojure site
Google Group
IRC
List of all logged dates

0:00 jsnikeris: amalloy: thanks for your help as usual

4:57 neotyk: Good morning everyone!

4:58 lnostdal-laptop: hello dr. nick!

5:01 ejackson: moring neotyx

5:04 neotyk: guys and galls I made some progress on clojure/clojurescript and websocket sample application, if you would like to see it: http://lab01.kungfoo.pl:8108/

5:09 ejackson: neotyk: i most certainly would... I'm currently trying to figure out how to get cljs to print a string representation of an object

5:10 you'd thing you could just do (str [1 2 3]), but putting that through a setTextContent renders and [object Object] annoying !

5:11 neotyk: ejackson: code is not yet ready to be published, but I demo it this Wednesday, so will publish it then

5:11 ejackson: neotyk: I can't select the text box in Firefox in your app

5:11 but can in safari

5:11 it tells me : No WebSocket supported, get a decent browser.

5:11 hahahaha

5:11 neotyk: ejackson: what version of ff?

5:12 exactly

5:12 ejackson: 5.0.1

5:12 probably some security setitng

5:12 i'm a little paranoid

5:13 neotyk: I use chrome for development and testing

5:13 and from time to time check it on safari

5:14 FF didn't work for me as well, but I have old version

5:14 ejackson: neotyk: is there some difference between (str [1 2 3]) and "[1 2 3]" in CS ? I can render one, but not the other :(

5:15 neotyk: one is vector other one is string

5:15 no, actually both are strings

5:16 ejackson: indeed

5:17 neotyk: so first one is [object Object]

5:17 right?

5:17 clojurebot: Equal Rights for Functional Objects is Baker's paper on equality and why it's impossible to define sensible equality in the presence of mutable data structures: http://home.pipeline.com/hbaker1/ObjectIdentity.html

5:17 ejackson: yeah, but why ? I'm not understanding that

5:18 even (. [1 2 3] (toString)) becomes [object Object]

5:18 bummer

5:18 neotyk: I guess it's js object you are getting

5:20 what if you would do (str (vec [1 2 3]))

5:20 ejackson: let me see

5:20 same

5:20 how irritating !

5:22 neotyk: maybe printing is not yet ported

5:23 ejackson: hmm.....

5:24 must be

5:25 but the whole groovy thing is to be able to pass clojure datastructures back and forth to the server, how is this possible without the printer ?

5:25 hiredman: str has never been about round tripping datastructures

5:25 use prn, pr, pr-str, prn-str and friends

5:26 ejackson: hiredman: aha ! thank you

5:27 neotyk: and read them with read-string

5:28 ejackson: and we have a winner

5:28 I had the read-string down, but he pr-str was the missing piece

6:31 ordnungswidrig: does anybody know of a static blog generator in clojure, like jekyll et al?

7:21 triyo: Hi guys. Is it possible, by any general means, to :require Clojure code in the ClojureScript namespace? Say for instance, I have utility function that directly translate from Clojure to ClojureScript, really power lies in the ability to reuse that function across the application layer boundaries if thinking in an example of Front-end (browser-based) and back-end.

7:22 *really=real

7:22 Anyone any thoughts on this?

7:26 So take for instance a validate component. The `logic` part of the component would be referenced from both the fron-end and the back-end of the application, thus satisfying the DRY principal.

7:26 *validate=validation

7:37 Seems to me like :refer-macros would make this possible as ClojureScript's macros are written in Clojure

7:56 krumholt: hi, can i write a macro that evaluates to no code? i want to write a macro that depending on a condition inserts code or nothing. is that possible?

7:59 triyo: By nothing you mean nil?

8:00 an (if ..) form would give you `something` when condition is met. When condition is not met it would return nil.

8:00 opqdonut: krumholt: sure, just return nil from the macro

8:00 when you want no code

8:01 krumholt: thats what i do right now

8:01 triyo: ,(if (=1 2) "will not evaluate")

8:01 clojurebot: #<CompilerException java.lang.RuntimeException: Unable to resolve symbol: =1 in this context, compiling:(NO_SOURCE_PATH:0)>

8:01 triyo: ,(if (= 1 2) "will not evaluate")

8:01 clojurebot: nil

8:02 krumholt: but nil is not the same as nothing at all

8:02 triyo: what is `nothing`?

8:02 krumholt: whitespace

8:03 triyo: Then return empty string -> ""

8:03 opqdonut: :D

8:03 nil is very much the same as nothing as far as macros are considered

8:03 changing a form to nil is what (comment ...) does, for example

8:03 krumholt: im trying to make an example (+ 1 2 (maybe 3)) and i want maybe to check a condition known at compiletime and then insert 3 or nothing at all

8:04 triyo: nope

8:04 insert 0

8:04 opqdonut: oh, right

8:04 triyo: in your case for that operation type

8:04 krumholt: i could do that but that would only work for numbers

8:04 not for text

8:04 opqdonut: you can't really do that. you need a macro that wraps around the + expression

8:04 and introspects it for occurrences of maybe

8:04 and then maybe deletes them

8:04 krumholt: opqdonut, ah nice thanks. thats actually what i want

8:05 opqdonut: krumholt: you'll might want to use clojure.walk for traversing the expression

8:06 krumholt: i'll look at that thanks again

8:06 opqdonut: btw,

8:07 ,(+ 1 2 #_(+ 5 6))

8:07 clojurebot: 3

8:07 depy: woot!

8:07 ,(+ 1 2)

8:07 clojurebot: 3

8:07 depy: nice! :D

8:07 opqdonut: (of course that's not toggleable)

8:07 triyo: hmm what reader is that?

8:07 #_

8:07 pretty cool

8:07 opqdonut: it's been in clojure since forever

8:08 documented on e.g. http://clojure.org/reader

8:08 triyo: Oh sweet, like a commenting effect on pre-eval

8:08 Yup just saw the docs

8:09 depy: Why is #_ used for? I can't think of any case where to use this... :)

8:09 Just curious..

8:10 triyo: When you want to exclude a form from being evaluated under certain conditions I'd say

8:10 opqdonut: commenting stuff out

8:10 when (comment ...) isn't applicable

8:10 and you don't want to munge the line structure to make ;; possible

8:11 triyo: that'd suite krumholt requirement with the maybe construct quite nicely.

8:11 in the macro def

8:11 depy: couldn't u solve this by using "if" ?

8:12 triyo: No, as it retunes nil

8:12 (+ 1 2 (maybe 6))

8:12 opqdonut: triyo: but you can't emit a #_ from a macro, since #_ is a reader feature

8:12 and anyway, I'm guessing krumholt wants to programmatically change whether stuff is included or not

8:13 of course he could just write out all the different cases in a cond, but that cond might be huge

8:13 triyo: yup, my guess too, I see what you mean

8:14 I must say though, to achieve that with a type system like that of Haskell is insanely simple without the use of macro system.

8:14 opqdonut: well, no

8:15 that's actually one of the things you can't do easily in a non-lisp language

8:15 omit parts of expressions

8:15 triyo: its not really an omission as such.

8:16 Its pure compile time polymorphism

8:16 you define what `maybe` instance for specific type means

8:16 opqdonut: for a special case like monoids (emitting a type-dependent "0") the haskell solution is quite neat

8:16 triyo: for in case if integer, it may mean zero

8:16 :)

8:16 thats what I mean,

8:17 opqdonut: well it does take some trying to get to a situation where omitting is necessary even in clojure

8:18 most variable-argument-length functions handle nil as absence of a parameter

8:18 triyo: yup, and that is one of the neatest things in my opinion in Clojure.

8:19 ,(map #(* % 2) nil)

8:19 clojurebot: ()

8:20 triyo: imagine if we had to instead write conditional nil checks on each of those calls?

8:21 where this notion fails though is on java interop though.

8:22 resulting in NPEs

8:23 wold be cool if you could say (.getFile should-be-url), where should-be-url is actuall a null pointer reference.

8:23 just first impression, I;m sure its not simple as that

8:34 leonid: nil is just an empty list

8:34 triyo: yup

8:35 lisp in general as far as I remember

8:37 I remember seeing it in the Micro-manual for LISP written by John McCarthy in 1978 in this paper -> https://docs.google.com/fileview?id=0B0ZnV_0C-Q7IOTRkNzVjZjMtMWE1NC00YzQ3LTgzMWEtM2UwY2I1YzdmNmM5&hl=en

8:38 The variables T and NIL are permanently assigned the values T and NIL, and NIL is the name of the null list ().

8:41 opqdonut: except in clojure () (the empty list) is not nil but the empty sequence is nil

8:47 leo2007: To use clojure well, does one have to know Java (some basics)?

8:47 triyo: ,(if '() "yes, nil" "no, not nil")

8:47 clojurebot: "yes, nil"

8:48 opqdonut: i think you got those the wrong way around

8:48 triyo: oops :)

8:48 yup

8:48 leonid: ,(nil? '())

8:48 clojurebot: false

8:48 leonid: ,(= nil '())

8:48 clojurebot: false

8:48 triyo: that better.

8:49 so what does the def for nil look like?

8:49 leonid: ,(nil? (seq []))

8:49 clojurebot: true

8:50 leonid: still confused about lists and sequences

8:51 raek: leo2007: imho, you should at least know about the way java programs are structured (packages, classes, fields, methods, nested classes, et.c.) and how you access these with the interop syntax

8:52 so that you can read the javadoc for a java library and write clojure code that uses that library

8:52 leo2007: raek: thanks.

8:53 dnolen: leo2007: I barely know any of those things and I've been using Clojure for 3 years :P but then I don't rely on that kind of interop much.

8:53 raek: but you also need to know about a few java classes, mainly the I/O ones

8:53 leo2007: dnolen: good to know ;)

8:53 triyo: Additionally, you want to know how to interpret the java stack traces that clojure produces up on exceptions

8:53 leo2007: I think I'll pick up some Java.

8:54 Menthy: LauJensen: is the SQL IN operator supposed to be working in ClojureQL 1.0 ? Looking at sources I was expecting (select (table :authors) (in :name ["John" "Luke" "Mark" "Matthew" ])) to work..

8:54 dnolen: leo2007: if you intend to use Java libs a lot, yeah you gotta learn some Java. But there's a lot of interesting work to do w/o Java libs.

8:54 raek: so it can be a good idea to look around in the java.io and java.net packages

8:55 leo2007: OK. I think I will.

8:56 * raek should finnish his Essential Java Classes for the Clojure Programmer blog post draft

8:59 leo2007: raek: I'd like to get a notice when you finish.

9:09 after running ant in clojure, I see two jars: clojure-1.3.0-master-SNAPSHOT.jar and clojure.jar

9:09 are they the same?

9:19 Menthy: leo2007: Usually in IDE's clojure.jar is a built in clojure version used as default by the clojure plugin of your IDE. I doubt they're the same.

9:21 vinzent_: hm, can somebody explain me what's the essense of the noir? it looks like its defpage is the same as compojure's GET\POST etc macros, defpartial is hiccup's defhtml... am I missing something?

9:31 leo2007: in short, what exactly is Leiningen?

9:32 vinzent_: the build tool for clojure

9:33 Menthy: leo2007: Leiningen is a dependency management and build tool. It's used to download libraries & the libraries they depend on, and to build clojure projects (generate executable jars)

9:34 Leiningen itself leans heavily on similar java tools called Maven (for dependencies) & ant (for building)

9:35 leo2007: Anyway, so in order to run swank-clojure, it has to be added to a project?

9:38 ejackson: anybody got a second to review a blog post on AJAX queries in Clojurescript for me ?

9:38 Menthy: leo2007: depends if you want to run it in your project, or if you want to use it in your editor/IDE to develop projects. If the latter, what is your current or intended development setup ? (OS, editor/ide) ?

9:39 leo2007: osx, emacs,

9:44 ejackson: oh well.... i hope I guessed correctly. I'm sure I'll be swiftly punished if not :)

9:44 ordnungswidrig: ejackson: i'd review it

9:45 ejackson: http://boss-level.com/?p=119

9:45 thank you ordnungswidrig

9:46 ordnungswidrig: ejackson: after deriving functional test cases from requirements all day, I need a break to reanimate my brain

9:46 solussd: how do I turn the string "{'a' 2}" into a clojure map?

9:46 ejackson: ordnungswidrig: oh dear lord, that sounds horrific.

9:46 ordnungswidrig: ejackson: test cases for *gulp* manual execution

9:48 Menthy: leo2007: not much experience with emacs, I'm new to clojure coming from the Java side as opposed to lisp. Took me a fair bit to find a workable IDE/REPL without having to resort to Emacs

9:48 triyo: I have a strange behavior when including (:require-macros [myns.mymac :as mymac]) in my CLJS script. I get an error at runtime that `mymac` is undefined.

9:49 Menthy: solussd: (println (read-string "{\"a\" 2}"))

9:50 triyo: Is there something specific that one needs to do to call the macro in the referenced macro module I wish to use?

9:52 solussd: Menthy, the string is of the form "{'a' 2}" and read-string turns it into {a 2}. Is there a way to preserve the single-quoted a?

9:53 erm, or a double quoted "a"

9:53 vinzent_: solussd, replace all ' -> " in the string :)

9:53 solussd: i want strings mapped to integers

9:54 but then when I try to turn it into a map I lose the double quotes.

9:54 (using read-string)

9:54 Menthy: solussd: ,(read-string "{\"a\" 2}")

9:54 solussd: ,(read-string "{\"a\" 2}")

9:54 clojurebot: {"a" 2}

9:55 solussd: my repl must not be feeling well

9:55 ah.. my bad. thanks!

9:56 Menthy: solussd: Probably pprinting the string contents only. yw

9:59 crazyFox: Menthy: so which IDE/REPL do u use now?

10:00 Menthy: crazyfox: IntelliJ Idea & LaClojure + Leiningen plugins

10:00 crazyFox: ah. never looked at that so far...

10:00 Menthy: crazyfox: There were some problems with that combination and environment variables not being put into REPL, but they've been fixed now

10:03 leo2007: Menthy: I can understand that ;)

10:03 Menthy: crazyfox: Tried Netbeans & Enclojure , Eclipse & CounterClockWise and IntelliJ IDEA (community edition) & LaClojure, and found the latest the easiest to work with when using Leiningen

10:03 triyo: I disabled my mouse and learned Emacs + slime + swank-clojure 3 years ago.

10:03 There where not any IDEs bck then

10:04 for clojure dev.

10:04 7 more years of emacs and I'll be a novice ;)

10:04 leo2007: I am already using slime. So would like to configure it to cover clojure too.

10:05 crazyFox: i am hesitant to start with emacs. it just seems soo big to me

10:05 triyo: If you dev on a Mac, there is a cheat. Run Aquamacs to easy in to Emacs

10:06 leo2007: triyo: how to start a standalone clojure swank server ?

10:06 triyo: lein swank, if you run leinigen

10:06 Menthy: Same here, just checking out clojure is pretty mindbending up till now, let alone having to use a completely new editor & hotkeys

10:07 crazyFox: triyo: i dont posess a Mac. Unfortunately shall i say?

10:08 triyo: crazyFox: yup, sorry to hear that ;)

10:08 leo2007: triyo: I have the script lein.

10:09 crazyFox: im going to try out clooj today. see how it feels...

10:09 triyo: Aquamacs runs Emacs under the hood. So you can do all you can do in Emacs with an addition to key bindings for Mac. So for instance.. cmd-key + s will save the file as expected instead of doing ctrl+x, ctrl+s to save.

10:10 leo2007: ok so in your project.clj file add -> :dev-dependencies [[swank-clojure "1.4.0-SNAPSHOT"]]

10:10 and then from command line run `lein swank`

10:11 leo2007: I run lein and it downloaded this file leiningen-1.6.1-standalone.jar

10:11 triyo: after few second it will launch the server listening on default port 4005

10:11 did you follow the installation instruction in https://github.com/technomancy/leiningen/blob/master/README.md?

10:13 the readme has everything you need to know to install leiningen and get started

10:13 leo2007: triyo: it didn't mention the leiningen-1.6.1-standalone.jar thing

10:14 triyo: Ok maybe I'm missing a part of the dialog. Why do you need the standalone jar?

10:14 leo2007: triyo: it keeps downloading itself

10:15 triyo: So you followed the installation instructions as the per the readme?

10:15 leo2007: every time I launch `lein' it says Downloading Leiningen now...

10:16 triyo: hmm

10:16 leo2007: triyo: not much to follow, it is just a short paragraph.

10:16 triyo: So you run `lein self-install`

10:16 ?

10:17 leo2007: sure.

10:17 vinzent_: maybe some problem with permissions?

10:17 Menthy: When you run "lein self-install" it downloads the jar and places it in a user dir. However, if you haven't got HTTP_PROXY and HTTPS_PROXY setup, it can't download the jar but creates an empty jar file in that directory

10:18 (at least that happened to me on Windows)

10:18 triyo: There should be a .m2/ dir in your home dir

10:18 leo2007: why do I need to set up proxy?

10:18 there is .m2

10:18 triyo: with the downloaded files in relevant sub dirs

10:18 Menthy: If you're behind a proxy, that is.

10:19 leo2007: getting this error: http://paste.pound-python.org/show/10717

10:20 triyo: Hmm can't find the clojure.jar on classpath I'd guess based on the msg

10:22 leo2007: triyo: so the installation is too brief for someone who doesn't know java.

10:23 triyo: leo2007: well the problem here is that this is not suppose to happen.

10:23 leo2007: I have clojure/ and swank-clojure/ in the same directory

10:23 both are git repos cloned from github

10:23 triyo: Leiningen doesn't need clojure in place when installing itself. It probably downloads clojure first and then bootstrap it, but for some reason fails to locate it on classpath

10:25 I'm no leiningen expert thought. Man to chat to is technomancy

10:25 He is usually on this list

10:25 `chat`

10:26 *though

10:30 leo2007: triyo: thanks though. I guess I'll have to wait for technomancy to show up.

10:32 triyo: sorry I couldn't help any further.

10:55 raek: leo2007: which lein version are you using? stable or snapshot?

10:56 leo2007: raek: how to check if it is stable or devel?

10:56 raek: leo2007: what was the URL of the script that you downloaded?

10:57 leo2007: LEIN_VERSION="1.6.1"

10:58 raek: i.e. did you download https://github.com/technomancy/leiningen/raw/stable/bin/lein or https://github.com/technomancy/leiningen/blob/master/bin/lein ?

10:59 * leo2007 checks

11:00 raek: leo2007: does your internet connection have a "captive portal" or something else that might intercept HTTP requests?

11:01 leo2007: raek: possible I am in China where many sites are blocked by the government.

11:01 raek: you could try removing everything in .m2 and run "lein self-install" again

11:01 leo2007: raek: it is the stable version.

11:01 raek: ok, good.

11:02 leo2007: I am trying that.

11:02 raek: btw, you don't need to clone any git repos unless you are making changes in code

11:03 leo2007: rake: I run lien self-install and it finishes.

11:03 I can find a file leiningen-1.6.1-standalone.jar in the dir the script is invoked.

11:04 nothing in .lein or .m2

11:04 raek: weird

11:04 leo2007: it is

11:04 I use rcirc on GNU Emacs 23.3.50.1 (Mac OS X 10.6.8)

11:04 raek: maybe you have an old version of wget installed

11:04 leo2007: no

11:04 raek: leo2007: which OS are you using?

11:04 leo2007: I have no wget just curl from osx

11:05 osx

11:05 gtrak`: hmm, I'm trying to log something to the swank repl (using c.c.logging) during C-c C-, testing, but nothing shows up on the repl except the stacktrace from the test. What could I be missing?

11:05 raek: leo2007: I've heard that some version of curl on OS X causes problems

11:06 leo2007: that is weird indeed.

11:06 raek: is it possible to start swank without lein?

11:07 I am happy to leave lein for later time.

11:07 raek: leo2007: see this thread: http://www.mail-archive.com/clojure@googlegroups.com/msg38722.html

11:08 leo2007: a blocked url here.

11:08 vinzent_: leo2007, maybe you'll be kucky with cake? it's a leiningen analogue

11:09 raek: leo2007: I would suggest fixing curl instead of skipping lein, since the latter will make lots of clojure development stuff uneccesarily complicated

11:09 leo2007: raek: but the curl in OSX works just fine for many other things in the past few years.

11:10 raek: leo2007: what about this one: http://groups.google.com/group/clojure/browse_thread/thread/8884666f2913f725/534799708df0e8dc?lnk=gst#534799708df0e8dc

11:11 but maybe this is an unrelated problem

11:11 leo2007: raek: leiningen is successfully downloaded: -rw-r--r-- 1 leo staff 8.9M 8 Aug 23:04 leiningen-1.6.1-standalone.jar

11:11 raek: leo2007: so you don't get any .m2 directory in your home directory?

11:12 leo2007: raek: not from lein, I got one from running mvn

11:12 .m2 is about 27M here

11:13 raek: leo2007: oh, sorry. the file should be installed in .lein/self-installs/

11:13 gtrak`: ah, nevermind, I found a way by throwing an exception with the string I need to see

11:13 raek: does it exist there?

11:14 leo2007: there is that dir but it is empty.

11:15 raek: leo2007: could you try to move the .jar-file there?

11:15 leo2007: done

11:16 raek: leo2007: the file should be downloaded to that place. can you open a leiningen issue for this? https://github.com/technomancy/leiningen/issues/new

11:16 leo2007: raek: seems to be running now.

11:17 raek: just write that the leiningen jar file gets downloaded to the current directory rather than .lein/self-installs/ and what OS and version of curl you use

11:17 this is obviously a bug, and it would be great if it was reported so that it's not forgotten

11:18 leo2007: raek: done.

11:18 PPPaul: hello

11:19 i have a list of keywords and i want to use them as arguments to defstruct. suggestions?

11:19 leo2007: raek: thanks very much. Now I am connecting to swank.

11:19 PPPaul: should i use apply-macro?

11:19 raek: PPPaul: you have to write a macro that expands to the defstruct call you want

11:19 PPPaul: i am

11:20 my macro is getting confusing

11:20 raek: apply-macro should never be used, really

11:20 PPPaul: (defmacro def-csv-importer2 [table-name]

11:20 `(do

11:20 (defstruct ~(symbol (str table-name "-struct")) ~(symbol (str table-name "-fields" )))))

11:21 the 'table-names-field' is a list

11:21 leo2007: not quite, it connects to my Common Lisp.

11:21 raek: leo2007: how do you connect from emacs? M-x slime-connect?

11:21 PPPaul: apply is the function that i want, but maybe there is a better way to do it with macros

11:21 leo2007: raek: yeah,

11:22 raek: if you start a swank server on port 4005, and then conenct to that port with slime-connect, then you should not get Common Lisp

11:23 dnolen: PPPaul: you do know that defstruct is deprecated right?

11:23 PPPaul: oh

11:23 suggestions then? should i use a record?

11:23 leo2007: raek: this time, it connects to the right one.

11:23 dnolen: PPPaul: why do you want to use defstruct?

11:23 raek: PPPaul: the list of fields must be available at macro expansion time

11:23 PPPaul: cus i used it before for something similar

11:24 dnolen: PPPaul: it's recommended to use plain maps unless you see some specific advantage.

11:24 PPPaul: the list is made by the macro, or by anther macro... it's available

11:26 i'm using a struct because my data is well defined

11:26 raek: PPPaul: the macro must access that list and generate a defstruct form with the elements as arguments

11:26 PPPaul: i know that, i just don't know how to do that

11:26 i tried ~@(symbol... and got an error

11:27 vinzent_: dnolen, is it deprecated, really? it'd be nice to use it when you need just a map, but have to create similar maps in some places

11:27 PPPaul: which is why i thought i should use apply-macro

11:27 maybe i should look up record

11:27 dnolen: PPPaul: even if your data is well defined, you can probably still use a map.

11:27 vinzent_: (so you dont have to write {} and keys every time)

11:27 PPPaul: defstruct is a map

11:27 dnolen: PPPaul: just trying to sort what you think is the advantage in terms of functionality.

11:27 PPPaul: i don't think there is any

11:27 raek: PPPaul: (defmacro def-csv-importer2 [table-name] (let [args (deref (resolve (symbol (str table-name "-fields" ))))] (list* `defstruct (symbol (str table-name "-struct")) args)))

11:28 PPPaul: cept having less code

11:28 thanks

11:28 oooooh

11:28 i see

11:28 raek: but I don't know if I would recommend this approach...

11:28 PPPaul: i haven't used (list*.... before

11:28 raek: it feels very hackish

11:28 PPPaul: hmmm

11:29 raek: perhaps this would be cleaner if the macro could call the function that generates the field names instead of accesing a specially named var

11:29 PPPaul: i'm going to look up a different approach, since defstruct is deprecated

11:29 dnolen: vinzent_: it is deprecated. You can use defrecord now, but defrecord is more tedious to work with than just plain maps. Which is good. It encourages using defrecord only when you really need it.

11:30 PPPaul: i guess i want my macro to do too much

11:30 raek: plain maps are fine most of the time

11:30 PPPaul: i'm doing this as a way to learn macros

11:30 oh

11:30 what about deftype?

11:31 raek: it defines a new type, but it doesn't work as a map like a record does

11:31 PPPaul: ok

11:31 vinzent_: dnolen, yes, that's why I thought I can use defstruct for such purpose

11:31 raek: defrecord for new language features, defrecord for data

11:31 vinzent_: raek, yeah, it's just helps sometime to type less :)

11:31 PPPaul: so defrecord is a big difference from defstruct?

11:32 raek: yes, it participates in the whoe protocols thing

11:32 dnolen: vinzent_: PPPaul: if you're going to use defrecord as defstruct was intended, it's good for that.

11:32 it only gets annoying when you start extending to protocols and interfaces.

11:33 raek: and each record field is a jvm class field, so the data is represented fairly compact

11:34 leo2007: raek: this elisp error seems slime upstream has changed something that causes this error: http://paste.pound-python.org/show/10721

11:34 I am running slime 2011-07-03

11:36 raek: leo2007: from Known Issues of the Leiningen readme: "Also the official CVS version of SLIME is not supported; it often breaks compatibility with Clojure."

11:37 leo2007: raek: i see.

11:37 raek: slime does not have stabe releases, only snapshots

11:37 iirc

11:38 leo2007: but swank-clojure ships with a "matching" version of slime. this is the version that is used if you use the "clojure-jack-in" approach

11:39 dunno if there is a convenient way of keeping your CL setup while using slime with clojure

11:40 when you run M-x clojure-jack-in it evals the bundled slime.el file. maybe that will override your CL slime for that emacs session so that it works for clojure.

11:41 ordnungswidrig: It there something like drop-until?

11:41 leo2007: raek: yeah, it would a headache for common lisp.

11:42 raek: it wonder why is that difficult to keep in sync with slime CVS, the protocol hasn't changed much.

11:42 ordnungswidrig: such that (drop-until #(> % 25) [10 20 30]) gives [20 30]

11:42 raek: could be worth a try to leave your CL slime setup as it is and use the clojure-jack-in approach to see if that works

11:43 ejackson: ordnungswidrig: a perverted drop-while ?

11:43 ordnungswidrig: ejackson: I need the item before the first item that drop-while would give me

11:43 ejackson: aaah

11:48 ordnungswidrig: ,(let [[a b] (split-with #(>= 50 %) [10 20 30 35 40 50 60])] (concat [(last a)] b) )

11:48 clojurebot: (50 60)

11:48 ordnungswidrig: a little pervert but does the job

11:49 leo2007: raek: thanks.

11:49 raek: leo2007: did it work?

11:51 leo2007: raek: no but I can fix it later.

11:53 edw: Is there some established way to "symbolify" a map's (string) keys, or should I write up something de novo?

11:53 leo2007: most of my slime setup for other languages is gone.

11:53 after swank-clojure loading its own slime.el

11:54 edw: Er, actually I'm interesting in keywordifying keys, not symbolifying them...

11:54 ejackson: ordnungswidrig: :)

11:58 raek: edw: http://clojuredocs.org/clojure_core/clojure.walk/keywordize-keys

11:59 edw: Thanks!

12:22 PPPaul: i'm trying to create records using lists from a file. i try this but it doesn't work (i've tried some variations too) (apply store-rec. [nil nil nil nil nil nil nil nil nil nil nil nil])

12:23 hiredman: sotre-rec. is not a fn

12:23 PPPaul: i figured

12:24 what should i use instead?

12:24 ns.store-rec?

12:24 actually, i tried that and it didn't work

12:24 vinzent_: PPPaul, you can't, it's a special form

12:25 hiredman: vinzent_: no it isn't

12:25 PPPaul: so, how do i programmatically create records?

12:26 do i need to make a macro for doing that?

12:26 vinzent_: hiredman, then, mm... reader macros? Foo. -> (new Foo)? or what?

12:27 hiredman: vinzent_: only for (store-rec. ...) (... store-rec. ...) is nothing

12:27 PPPaul: so (new store-rec [nil nil....])?

12:27 vinzent_: ah, that's what i meant

12:28 PPPaul: i get a ctor error

12:29 (new store-rec [nil nil nil nil nil nil nil nil nil nil nil nil]) -> No matching ctor found for class

12:29 vinzent_: PPPaul, i think you have to write wrapper function (in 1.2), (apply (fn [arg1 arg2] (Rec. arg1 arg2)) [...])

12:29 PPPaul: lol

12:30 that seems like a huge pain

12:30 is that fixed in 1.3?

12:31 cus if it is i'll use that instead

12:31 coopernurse: hi folks. can anyone suggest a sql db migration library? ideally one I can invoke from lein. I tried drift but got some puzzling ClassNotFound errors running the lein create-migration task. lobos looks good, but doesn't seem to be runnable from lein.

12:32 vinzent_: I've heard there is map->Foo and ->Foo fns in 1.3

12:32 PPPaul, also maybe there is something in java reflection api that'll help you

12:32 PPPaul: reflection api.... gah

12:32 dnolen: PPPaul: writing a wrapper function takes almost no code, you often want to have default fields, easier to just define your own ctor fn.

12:32 PPPaul: i don't want to touch java or interop right now

12:33 i am doing something super simple, i would rather it be pure clojure

12:33 this seems like basic functionality

12:34 vinzent_: coopernurse, you can write a lein task yourself, it shouldn't be too difficult

12:35 coopernurse: vinzent_: ok, I'll google that. I assume I can just write a .clj file in my project and somehow tell lein about it?

12:35 found it in the faq. "You can also include one-off tasks in your src/leiningen/ directory if they're not worth spinning off;" I will try that

12:36 triyo: It seems that only way to require a Clojure code in from the ClojureScript namespace is via :require-macros. Anyone know if this is true and if so, why macros and not standard functions too?

12:37 vinzent_: coopernurse, btw, if you'll write general-purpose lein task for lobos, i'd love to use it :)

12:37 coopernurse: vinzent_: heh, ok. looks like lobos doesn't have any notion of state -- so one would have to write something that stores which migrations have been applied. or am I missing something?

12:38 drift seems to be closer to what I'm after

12:38 PPPaul: has anyone here used records in clojure 1.3?

12:38 coopernurse: so it may be faster for me to try to troubleshoot the ClassNotFoundExceptions I'm getting

12:40 hiredman: PPPaul: look, you want to do something like (Foo. bar baz) where bar and baz are names the binding of which are delayed till runtime

12:40 how do you do that?

12:40 vinzent_: coopernurse, it seems that currently lobos has only utilities to operate on tables - and that's all. let me google drift, haven't seem it...

12:40 coopernurse: vinzent_: https://github.com/macourtney/drift

12:41 vinzent_: thanks

12:41 PPPaul: yeah, how do i do that?

12:41 even the Foo. is created at runtime from a file def

12:41 that part is done via macros

12:42 vinzent_: PPPaul, macros are all about compile time

12:42 hiredman: in fact dnolen told you how to do it

12:42 PPPaul: i'm trying to get a function to read in a map and create a list of records from it

12:42 hiredman: (fn [bar baz] (Foo. bar baz))

12:42 PPPaul: the wrapper function seems really weird

12:43 hiredman: well, you want a fn right?

12:43 apply takes a fn

12:43 PPPaul: i'm not giving 'Foo.' in my function

12:43 i'm given 'Foo'

12:44 dnolen: PPPaul: all these shenanigans could be avoid if you just used plain maps and fns ;)

12:44 hiredman: so you will need the macro that generates Foo to generate a make-foo fn and use that

12:44 PPPaul: (defn csv-file-to-record [csv-file record]

12:44 (->> (parse-csv-file csv-file)

12:44 (map #(apply (record)%),,,)))

12:44 hiredman: no

12:45 coopernurse: vinzent_: I'd be curious if you get the same error I did when trying drift out of the box

12:45 PPPaul: i think i'm not going to use records if i have to jump through hoops to do something simple like creating a new one without knowing it's name

12:46 coopernurse: I opened a github ticket with what I'm seeing.. pretty basic

12:47 vinzent_: coopernurse, ok, let me try that...

12:47 coopernurse: vinzent_: cool, thanks

12:47 PPPaul: i'm wondering that if i use clojure 1.3 i don't have to do all this BS with records (as in they are more complete)?

12:48 technomancy: why not stick with maps?

12:48 PPPaul: i was using maps

12:48 then someone told me defstruct was deprecated

12:48 so i switched

12:48 now i'm fucked

12:48 lol

12:49 why would records even exist if they don't work in such a common use-case?

12:49 technomancy: maps aren't defstructs

12:49 PPPaul: well

12:49 technomancy: maps are way simple

12:49 PPPaul: i thought that they were

12:49 structs are maps, no?

12:49 technomancy: meh

12:50 PPPaul: i just want my code to be simple and tiny

12:50 so, does anyone have experience using records in 1.3? are they better?

12:51 vinzent_: PPPaul, just use maps then!

12:51 lnostdal: maps are not defstruct

12:51 PPPaul: hmmm

12:52 ok

12:52 but from what i've seen defstruct was made to make certain things involving maps easier.... no?

12:52 dnolen: PPPaul: simple and tiny means using the highest level constructs - maps and functions. defrecord is lower-level and host-y.

12:52 PPPaul: no, defstruct was about performance.

12:52 PPPaul: defstruct code looks pretty, though

12:53 defstruct work well for reading in a csv file

12:54 at least in terms of code simplicity

12:54 can i get the same code simplicity with maps?

12:54 vinzent_: coopernurse, it works here. the same project.clj, config with in-memory versions from the readme, lein create-migration foo throws no exceptions

12:54 coopernurse: vinzent_: interesting. what version of lein?

12:54 technomancy: PPPaul: it will be much simpler with maps

12:54 vinzent_: 1.5.2

12:55 coopernurse: vinzent_: I'm on 1.6.1 - wonder if that matters

12:55 I'm reading the source to leiningen/create_migration.clj

12:55 PPPaul: ok, if i can't get my code working in an hour or so i'll do everything with maps. but i think it'll be more confusing cus i wont see my keys or values in the code

12:55 coopernurse: quite short, but a little over my head..

12:56 vinzent_: coopernurse, may bel the only way to know is to test it :) although I don't know how to setup properly different versions of leiningen...

12:57 lnostdal: the key-names will be the "function names", PPPaul .. if needed (if things become nested perhaps) you can just pass the maps around to functions which will deal with them "for you"

12:57 coopernurse: vinzent_: yes, I'm not sure either.

12:57 source file is here: https://github.com/macourtney/drift/blob/master/src/leiningen/create_migration.clj

12:58 I'm not sure what the `(do ... ) block means. not familiar with the backtick operator yet

12:58 PPPaul: yeah, i was just hoping that all of this junk related to making structs or records was done for me (in terms of programmable constructors) i had success with defstructs in the past, though

13:01 vinzent_: coopernurse, i think it's just evals the code in the context of the project. ` is allows kind of templating (unqoting some exprs). so it fails on requiring file... btw, it's no clear why not just write (require 'drift.generator)

13:01 coopernurse: vinzent_: figured out how to do multiple lein versions (quite easy) - copy the lein bash script to a new name and change the LEIN_VERSION at the top

13:01 vinzent_: sadly I'm still getting the same error with 1.5.2

13:02 vinzent_: not sure what's different about my environment.. I'll try his sample from the readme

13:02 maybe I'm fat fingering the deps or something

13:02 vinzent_: ok...

13:03 technomancy: coopernurse: that's not really a good way to switch lein versions

13:03 better to grab bin/lein from a tag on github

13:03 coopernurse: technomancy: ok, thanks

13:03 just doing this for a quick test

13:06 vinzent_: success! I was invoking the 1.6.1 lein on my last command

13:06 so it appears the problem is lein 1.6.x compatibility

13:06 I'll update my github ticket, but this is a fine workaround for now

13:09 vinzent_: coopernurse, glad to hear :) btw, from the eval-in-project doc: "... If the form depends on any requires, put them in the init arg"

13:09 coopernurse: vinzent_: that's from the lein docs?

13:10 vinzent_: https://github.com/technomancy/leiningen/blob/master/src/leiningen/compile.clj#L134

13:11 coopernurse: vinzent_: ah, very good.

13:14 vinzent_: so that was the "Gilardi Scenario" :)

13:18 coopernurse: vinzent_: heh, yes, it appears so now that I read Phil's article about it

14:00 lein new foo creates: src/foo/core.clj -- is there any difference/advantage to this vs creating src/foo.clj? is core.clj special in any way? (similar to __init__.py in python)?

14:00 Vinzent: it's just a convention

14:01 coopernurse: thanks

14:01 amalloy: Vinzent, coopernurse: that's not really true

14:02 Vinzent: why?

14:02 amalloy: core is not special in any way, but because we live in java it's not a good idea to have single-segment namespaces. you want at least one directory (and usually one is plenty) under src/ before you start adding source files

14:02 java doesn't like the default pakcage, which is where stuff in src/foo.clj would end up

14:05 ibdknox: amalloy: I didn't know data.xml had something in it that would homogenize a bunch of vectors for me

14:06 amalloy: ibdknox: i added it a few weeks ago

14:06 Vinzent: ah, true - I just meant "core" isn't special

14:06 ibdknox: amalloy: sweet

14:06 amalloy: do you happen to have a version of data.xml that works in ClojureScript? :D

14:06 amalloy: hah, good point

14:06 ibdknox: hehe

14:07 what function does the homogenizing?

14:07 amalloy: the AsElements protocol, and sexps-as-fragment helper

14:08 it's all defined in pure clojure with protocols, so you probably could just copy all the code before attribute/emit, which are the only ones dealing with java types

14:08 ibdknox: yeah, it looks like it

14:09 maybe we should just add a clojure.xml (maybe some other name) to cljs

14:09 amalloy: and hopefully those Element records would be more convenient for the client to use than generated DOM? of course they'll want DOM eventually, but a converter is easy

14:09 ibdknox: yeah

14:09 I agree

14:09 amalloy: lovely

14:09 ibdknox: I sent off my CA last week

14:10 hopefully I can contribute to ClojureScript soon

14:10 we should just drop something like this in there, because this would be useful in a ton of contexts

14:17 amalloy: ibdknox: i'm not really involved in cljs, but since i wrote it i could commit it to cljs for you if you can get anyone to agree on it

14:21 ibdknox: amalloy: they didn't approve me for Clojure-Dev, I assume because my CA hadn't arrived yet. So once I can actually get on there, I'll see what people have to say about it.

14:24 amalloy: ~ca

14:24 $whatis ca

14:24 lazybot: ca does not exist in my database.

14:24 amalloy: i hate you both

14:24 ibdknox: lol

14:25 hiredman: huh, I what clojurebot's problem is

14:26 amalloy: ,1

14:26 poor guy

14:27 ibdknox: lol, that was more than 24 hours ago

14:27 amalloy: ibdknox: he's been repeating that set for a while

14:28 hiredman: ~ca

14:28 clojurebot: CA is Contributor Agreement: http://clojure.org/contributing

14:28 amalloy: we also got a nice "(notice) null"

14:28 ibdknox: haha

14:28 he's sick :(

14:28 hiredman: if you'll notice between those notices the bot was restarted

14:28 amalloy: hiredman: really? i saw those twice last night, and once just now

14:29 hiredman: right

14:29 amalloy: okay

14:29 hiredman: (how do people irc with join/parts turned off?)

14:29 amalloy: i only have so much vertical space :P

14:29 hiredman: the bot just keeps the set of stuff scraped from the clojars website in memory

14:30 amalloy: right, i understand

14:30 hiredman: the null thing was a bug exposed once the bug that stopped the clojars notices from being sent was fixed

14:31 technomancy: hiredman: tab completion replaces part messages

14:32 it'd be semi-nice I guess if you could just hide them by default instead of having them not written to the buffer at all, but meh

15:02 vertegal: /leave

15:11 gtrak``: It's not a big deal at all to me, but just curious, why does the clojure compiler seem so slow? I wonder if it's just so much more dense than java and it has to figure out all the dynamic stuff

15:14 amalloy: i wonder what tests you've done to make you think that the clojure compiler is slower than javac

15:15 gtrak``: just subjective ones, not trying to incite anything, I really like clojure :-)

15:18 I guess I could profile it, but maybe you know off the top of your head what dominates the time?

15:19 amalloy: i don't think it does, though. i mean, compiling a *single* java file might be faster than compiling core.clj

15:20 at any rate the main bottleneck is (i think) that core.clj bootstraps the whole language out of compiler primitives every time you start it up

15:20 gtrak``: does it have to do that more than once during an AOT phase in lein?

15:22 it might just be stuff around it more than the compiler itself, compiling one file with C-c C-k is instant

15:24 crazyFox: ,(for [y (range 3) x (range y)] [y x])

15:24 clojurebot: ([1 0] [2 0] [2 1])

15:24 crazyFox: is this a bug in for?

15:24 hiredman: no

15:25 crazyFox: why dosnt y start at 0?

15:25 hiredman: ,(range 0)

15:25 clojurebot: ()

15:25 MasseR: crazyFox: Ending is exclusive

15:25 Start is inclusive

15:25 ,(range 0 2)

15:25 clojurebot: (0 1)

15:26 MasseR: No 2

15:26 crazyFox: i know. that not my point.

15:26 (range 3)

15:26 ,(range 3)

15:26 clojurebot: (0 1 2)

15:26 crazyFox: it starts with 0

15:26 but my y up there starts with 1 instead of 0

15:27 MasseR: Oh, sorry I read you wrong

15:27 amalloy: crazyFox: because when y is 0, x == (range y) == ()

15:27 so no iterations happen

15:27 crazyFox: ah!

15:27 thank you for pointing that out

15:28 gtrak``: ,(for [y (range 0 3) x (range 0 y)] [y x])

15:28 clojurebot: ([1 0] [2 0] [2 1])

15:28 technomancy: clojurebot: lua called, it wants its crazy one-indexed functions back

15:28 clojurebot: functions are maps

15:29 amalloy: technomancy: imo java.util.Date is enough index-confusion for a whole language

15:30 gtrak``: ,(for [y (range 0 3) x (range 0 (inc y))] [y x])

15:30 clojurebot: ([0 0] [1 0] [1 1] [2 0] [2 1] ...)

15:30 technomancy: oh man don't get me started

15:30 * amalloy ignores this warning

15:31 technomancy: the Clojure compiler should ideally issue warnings for every instance of java.util.Date that it sees.

15:31 actually, javac should too

15:31 amalloy: haha

15:31 crazyFox: gtrak'': its ok. i figured it out by now :D

15:31 gtrak``: just trying for myself

15:31 crazyFox: oh sure

15:33 amalloy: technomancy: so we should use TimeUUID instead?

15:33 technomancy: definitely

15:35 mjg123: Good evening

15:36 I would like to split my clojurescript app up, it's too big for one file

15:36 so I create core.cljs and ui.cljs

15:36 and in core, I (:require ui :as ui), but it won't compile

15:36 is there a working demo somewhere?

15:37 I can see the twitterbuzz source, and I seem to have the same setup. But I don't know what command is used to build then.

15:37 amalloy: mjg123: your require syntax is wrong

15:38 doublecheck against twitterbuzz (or any clojure program)

15:38 mjg123: yes - sorry - I typed it into irc wrong. I have the same code as twitterbuzz

15:40 it looks like this: https://gist.github.com/1132536

15:43 I added a description of what I'm doing to build and what the error is to https://gist.github.com/1132536

15:47 is there a need for the namespace structure (game.ui) to match the directory structure (game/ui) ?

15:48 Chousuke: mjg123: yes

15:49 foo.bar corresponds to foo/bar.clj

15:49 mjg123: Chousuke: then that is the problem :)

15:49 Ahhhh

15:49 Yes, thansk

15:50 * mjg123 back to hacking - thanks again

16:14 malkomalko: is there anyway to force clojure to not give me back a large float in exponential form?

16:17 hiredman: malkomalko: what do you mean?

16:17 malkomalko: 999222333111.23 => 9.9922233311123E11

16:17 I'd like 999222333111.23

16:18 hiredman: so you'd like to change the format of how it is printed out?

16:18 the *format* is what you are looking to change?

16:18 malkomalko: *yes*

16:19 hiredman: well, perhaps the `format` function?

16:28 amalloy: ,(format "%.15f" 999222333111.23)

16:28 clojurebot: "999222333111.230000000000000"

16:28 amalloy: malkomalko: fiddle with it, but something like that

16:29 malkomalko: right, but that'd give us a string, and you can't add strings.. if we parse that again, I think we'd end up where we started no?

16:29 hiredman: 9.9922233311123E11 is a string

16:29 amalloy: what. this question makes no sense re the last question

16:29 hiredman: numbers have no format

16:30 malkomalko: that number is in a map that is being used to generate a json string

16:31 the json-string library is outputting in exponential

16:31 hiredman: that is a bug in that library

16:31 malkomalko: just wanted to know if there was a way to tell it to print without it, is all

16:32 hiredman: json encoding has nothing to do with clojure's printing

16:32 st3fan: ,(* 2 21)

16:32 clojurebot: 42

16:32 st3fan: heh awesome

16:32 hiredman: and fyi, that number may be too large to represent as a javascript number (so encoding it as json may not be a good idea)

16:32 amalloy: hiredman: how is that a bug? doesn't json use/support the same exponential format?

16:33 hiredman: amalloy: no idea, there are a lot of json readers out there

16:43 lobotomy: stupid question time: what's the best way of using a library such as math.combinatorics? just pull it from git and copy to wherever?

16:46 dnolen: lobotomy: if it's deployed to maven central it's easy but I don't think math.combinatorics is yet.

16:52 lobotomy: so just pull from git then?

16:53 dnolen: lobotomy: you could use the version from 1.2.0 contrib.

16:54 lobotomy: are you not using lein/cake?

16:54 lobotomy: hmm, i'm using leiningen yes

16:54 dnolen: [org.clojure/clojure-contrib "1.2.0"] I would think then.

16:55 Somelauw: Are there any plans to convert clojure to c or native code or is that considered a bad idea?

16:56 amalloy: Somelauw: never

16:56 Raynes: No known plans. Not to say it's completely off the table forever and evers. Sometime in the next 300 years or so, I'm sure someone will try.

16:56 Somelauw: Why never?

16:57 technomancy: you need a runtime

16:57 Somelauw: What do you need a runtime for?

16:57 dnolen: Somelauw: Clojure's design assumes high performance GC.

16:58 Somelauw: You can use c libraries right?

16:59 dnolen: Somelauw: hmm ... though ClojureScript does greatly relax what is expected from the host.

16:59 noone expects really incredible performance from JavaScript tho...

17:00 Somelauw: Is it really hard to convert clojure to c without preserving performance. I know haskell can be compiled really efficiently and haskell should benefit from good GC as well, I think.

17:02 dnolen: Somelauw: noone's saying it can't be done ... rather how much work is involved and is it worth the effort?

17:03 ClojureScript seems adequate w/ a lot less effort.

17:04 Somelauw: I am not great at javascript, but maybe. Can clojurescript also be ran serverside?

17:05 Raynes: Yes, with nodejs.

17:05 But ClojureScript isn't actually working with nodejs at the moment, given http://dev.clojure.org/jira/browse/CLJS-43 so it might be a bit before you can try it out.

17:05 Somelauw: Okay, I will check it out.

17:48 jhickner: should this work in clojurescript? -- (js/console.log "foo")

17:48 it looks like it compiles to this: goog.global['console']['log'].call(null, "foo")

17:49 but I get an Illegal invocation error when running it in the browser

17:54 dnolen: jhickner: did you try (.log js/console "foo") ?

18:01 jhickner: @dnolen that works! thanks

18:13 leonid_: Rank Username Problems Solved

18:13 75 leonid 75

18:13 consistency

18:15 amalloy: *chuckle*

18:15 leonid_: time to change your username

18:16 maacl: Shouldn't "{:x1 1}" and (pr-str {:x1 1}) be the same in ClojureScript? if I try to pass to js/encodeURIComponent I get differing results.

18:41 ibdknox: maacl: I'm pretty sure that CLJS represents keyword using a different symbol

18:41 it's not a colon

18:41 so those wouldn't be the same

18:41 internally that is

18:42 maacl: nm, I read that wrong

18:42 Raynes: ibdknox: It's killing me: what is the meaning of your IRC nickname?

18:43 ibdknox: haha

18:43 maacl: ibdknox: Ah, tricky - do you know of a cljs function that produces the expected result?

18:44 ibdknox: Raynes: it's from long ago in high school, IB = International Baccalaureate, D=dork, Knox = a name I like lol

18:44 Raynes: Interesting.

18:46 ibdknox: maacl: I misread your original statement, that *should* work. What are you getting instead?

18:49 this works at the REPL

18:49 (= (pr-str {:x1 1 }) "{:x1 1}")

18:49 oh

18:50 encodeURIComponent escapes the ":" character

18:50 maacl: ibdknox: "{:x1 1}" > %7B%3Ax1%201%7D whereas (pr-str {:x1 1}) gives %7B%22%5CxEF%5CxB7%5Cx90'x1%22%201%7D

18:51 ibdknox: yes, which is need if you want to pass clojure form in a query string

18:52 ibdknox: maacl: hm, that is odd. You probably do this as a post though.

18:53 maacl: just to make sure nothing gets lost in translation

18:54 maacl: ibdknox: but the problem arises before I submit it...

18:54 ibdknox: maacl: do you have the latest cljs?

18:54 maacl: ibdknox: I believe so

18:55 ibdknox: ClojureScript:cljs.user> (js/encodeURIComponent (pr-str "{:x1 1}")) => "%22%7b%3ax1%201%7d%22"

18:56 maacl: ibdknox: hm, very strange - I get the same at the REPL

18:56 ibdknox: must look elsewhere

19:13 sjl: Does Clojure have a way to replace a subsequence of a Vector? Something like Python's list slicing (lst[10:20] = [1,2,3]), but immutable?

19:32 arohner: technomancy: M-x slamhound has a high probability (75%+) of making Emacs completely unresponsive. Have you heard of any issues like that?

19:34 using it from the repl appears to work fine

19:34 technomancy: arohner: there are some unresolved infinite loops in the elisp, but C-g has been able to take care of everything I've run into so far

19:35 arohner: technomancy: C-g works unreliably for me. and sometimes, the ns declaration that is added after a C-g is different from what (reconstruct ...) returns

19:36 technomancy: hm; I haven't seen that.

19:36 arohner: technomancy: it appears to be differences of whitespace

19:37 technomancy: oh, sure

19:37 arohner: spaces missing, etc

19:37 technomancy: it performs some cleanups

19:37 amalloy: sjl: no. if the two slices are the same size, you can do it with multiple assocs

19:37 technomancy: I haven't been using it as much as I'd like, primarily due to the pretty-printing being crap.

19:37 arohner: technomancy: yes, but I'll see [hiccup.page-helpers:only[link-to]]

19:37 amalloy: but if the slices are different sizes, you just can't do it efficiently, so you might as well use concat on seqs raterh than messing with vectors

19:37 technomancy: arohner: hm; haven't seen that myself, but it doesn't surprise me too much

19:37 sjl: amalloy: Yeah, that's what I'm going to do I guess. I was wondering if there was something that would be faster. Seems like a lot of assocs if it's a long subsequence.

19:37 technomancy: hopefully after strange loop I'll be able to spend some time polishing the pretty-printing

19:38 ibdknox: technomancy: you presenting at strange loop?

19:38 technomancy: ibdknox: yeah, on Emacs

19:39 amalloy: sjl: vectors are optimized for use cases different from that

19:39 c'est la vie

19:39 ibdknox: technomancy: awesome, good luck with that. :)

19:39 technomancy: thanks

19:39 sjl: amalloy: Is there another data structure better for it? I could use a map, but it seems like a waste since all the keys are just sequential integers

19:40 amalloy: i'm pretty sure finger trees can be built with fast concat and fast indexed-lookup, if you're desperate for performance on a large sequence

19:40 sjl: Hmm, I guess I'll just use the multiple assocs for now and if it turns out it's a bottleneck I'll look into changing it

19:40 Thanks

19:41 amalloy: sjl: if you don't need fast indexed lookup, concat is probably fine

19:42 together with take, drop, and all the other lazy-seq stuff

19:43 sjl: amalloy: Indexed lookup is definitely what I need (it's an array of blocks representing Minecraft chunks, and I'll need to index into it to get values for specific blocks)

20:11 gfrlog: every time I want to push a jar to clojars I have to change the public key (since I never push from the same computer twice in a row); that's annoying in and of itself, but now even that's not working...

20:12 when I try to update the public key it says my username is already taken :|

20:12 hiredman: you should use an ssh agent

20:12 gfrlog: to have the same key on all my computers?

20:13 hiredman: no

20:13 well, maybe

20:13 amalloy: gfrlog: i have the same key on all my computers. i'm sure there's something a little insecure about it, esp as hiredman seems uneasy, but it's simple and makes sense

20:13 hiredman: *shrug*, I guess I don't yuse other computers except via ssh and sshagent forwards my key

20:14 gfrlog: in every other context involving keys, using multiple keys is not an issue

20:14 technomancy: clojars could definitely use some more features

20:14 hiredman: gfrlog: clojars is open source, send a pull request

20:15 gfrlog: hiredman: my primary complaint is about the key-changing bug

20:15 not the multiple keys feature

20:15 amalloy: conceptually, at least, you "should" have the same key. the key is supposed to identify *you*, not a computer

20:15 hiredman: gfrlog: sure, send a pull request to fix it

20:15 gfrlog: amalloy: don't like pseudonyms?

20:16 amalloy: gfrlog: i don't introduce myself to everyone i meet with a different name :P

20:16 gfrlog: hiredman: what? just because I didn't pay for clojars means I can't expect people to fix it for me?

20:16 hiredman: amalloy: or assuming some kind of pki, they keys you use should all be signed by your "actual" key

20:16 gfrlog: expect all you want

20:16 gfrlog: :)

20:17 amalloy: hiredman: also reasonable, though probably too complicated for me

20:17 hiredman: I've never changed my key on clojars so it's unlikely that I will bother fixing it

20:17 amalloy: yeah, i didn't even know it was an option. why would you want to

20:17 hiredman: that I don't want to go anywhere near the web ui

20:18 gfrlog: well even if I decide I like the one-key idea, I'm stuck at the moment because I doubt I have access to the key currently registered

20:18 at least for the next week or so

20:19 hiredman: gfrlog: https://github.com/ato/clojars-web/issues

20:19 amalloy: "but officer, my house has lots of keys in it! if you let me into my house, i'll be happy to show you the key there to prove it's my house!"

20:19 gfrlog: hiredman: thanks, I was wondering where the repo was

20:24 bortreb: I remember an excellent video posted to the mailing list some time ago about "solving the expression problem with clojure" does anyone know where that video is?

20:40 kencausey: bortreb: are you sure it was a video? http://www.ibm.com/developerworks/java/library/j-clojure-protocols/

20:41 bortreb: it was in fact a video. I love the paper but I wish I could find the video :(

20:41 maybe he took it down after publishing the paper?

20:41 kencausey: this was linked at the bottom: http://www.infoq.com/presentations/Clojure-Expression-Problem

20:41 dnolen: hmmm … pattern matching on primitive arrays could fun ...

20:42 s/fun/be fun

20:42 lazybot: <dnolen> hmmm … pattern matching on primitive arrays could be fun ...

20:42 hiredman: on ByteBuffers

20:42 dnolen: hiredman: I'm assuming there are methods to pull them apart? (never used 'em)

20:43 bortreb: thanks kencausey -- that's a great video, but the one I'm looking for is by Stuart Sierra, the same one who wrote the paper.

20:43 hiredman: dnole: yes

20:44 getInt, getFloat, getChar, etc

20:44 dnolen: hiredman: what about sub ByteBuffers ?

20:44 hiredman: sub bytebuffer?

20:44 dnolen: like subvec say

20:45 hiredman: ah, you can slice them

20:45 dnolen: very interesting ...

20:45 hiredman: I'm thinking about reserving vector notation for anything that supports random access + subvec/slicing.

20:45 hiredman: the api is very mutable

20:45 clojurebot: You don't have to tell me twice.

20:45 hiredman: ~botsnack

20:45 clojurebot: Thanks! Can I have chocolate next time

20:47 kencausey: bortreb: Well, he doesn't mention it on his site while he does mention the developerworks article, so it seems unlikely.

20:47 dnolen: hiredman: it's interesting to me to be able to support rest notation w/o discarding the type.

20:48 hiredman: ah, yes

20:48 raek: bortreb: there are some videos here: http://alexott.net/en/clojure/video.html

20:48 hiredman: http://www.infoq.com/presentations/Clojure-Expression-Problem

20:48 raek: but the only one I found was the one by Chris Houser that kencausey and hiredman linked

20:49 dnolen: hiredman: so if you bring the type into the protocol, you can blast through data structure w/ pattern matching.

20:51 bortreb: I guess he either took it down for some reason or my memory is faulty. thanks anyway!

20:55 gfrlog: it is difficult to debug clojars without access to the database :/

20:55 hiredman: you can get a dump of the db

20:56 * gfrlog tries to figure out why that would be allowed

20:56 gfrlog: I guess it wouldn't have anything sensitive

20:56 hiredman: it is sanitized

20:57 gfrlog: hiredman: where would I get such a thing?

20:57 hiredman: the readme

20:57 gfrlog: thx

20:58 hiredman: oh that's a static snapshot?

20:58 I'm not sure that would help me debug my username which used to work but now doesn't

20:58 particularly I'm wondering if my username is also a group name

21:00 sjl: Ugh, I think I'm going to have to use a byte-array instead of a Vector of Integer objects for memory.

21:01 hiredman: have you see primitive vectors?

21:01 sjl: hiredman: No… those sound promising.

21:01 hiredman: (require 'clojure.gvec)

21:01 ,(require 'clojure.gvec)

21:01 clojurebot: nil

21:02 hiredman: ,(doc clojure.gvec/vector-of)

21:02 clojurebot: Huh?

21:02 hiredman: jerk

21:02 sjl: ,(doc vector-of)

21:02 clojurebot: "([t] [t & elements]); Creates a new vector of a single primitive type t, where t is one of :int :long :float :double :byte :short :char or :boolean. The resulting vector complies with the interface of vectors in general, but stores the values unboxed internally. Optionally takes one or more elements to populate the vector."

21:03 hiredman: oh, I see, gvec is in clojure.core, but a seperate file

21:03 sjl: So is the overhead on (vector-of :byte) o(1) or o(length of vector)?

21:04 hiredman: no

21:04 sjl: (I'm storing vectors of ~32,000 items each)

21:04 hiredman: it is not an array (not just a blob of memory)

21:04 it is still a persistent tree structure

21:05 sjl: Ah, hmm, I wonder if it would be worth it then.

21:06 gfrlog: when I create a new clojars account, changing the key works fine.

21:06 hiredman: *shrug*

21:06 gfrlog: ah ha -- I see my username listed as one of the groups that I'm in

21:06 so that IS the issue

21:07 now I don't know if that's an illegal state or not. I'm sure it's my fault somehow

21:07 hiredman: is that the issue?

21:08 gfrlog: hiredman: by looking at the code, I concluded that was one of three equally unlikely-seeming explanations

21:08 I had no reason to think any of them were possible

21:08 the code basically says "if your username is a group you cannot update your profile"

21:09 I don't know if it's intentional or not

21:09 nor do I know yet if I can fix it by just deleting the jar that caused it

21:10 (presumably the original intention of the code is to prevent _creating_ accounts that are the same as group names)

21:14 I think I know an acceptable fix. will code and request pull.

21:26 pull request sent

21:26 hiredman: thanks for the help

21:43 bortreb: is there a way to give a custom .toString for an object created via reify?

21:44 hiredman: ,(.toString (reify Object (toString [_] "foo")))

21:44 clojurebot: "foo"

21:47 bortreb: right -- I forgot the [_] part. thanks!

21:56 amalloy: i've seen a video on the expression problem too. bortreb wasn't imagining it

21:58 kencausey: amalloy: You mean other than Chris Houser's Strangle Loop presentation?

21:58 gfrlog: I saw a halloway video where he talked about it a bit, but I doubt that's what anybody's thinking of

21:58 amalloy: kencausey: yes, it was one of the stuarts

21:59 kencausey: http://www.ibm.com/developerworks/java/library/j-gloverpodcast/#halloway

21:59 that podcast? again that was linked at the bottom of the Mr. Sierra's article

22:00 or perhaps http://vimeo.com/11236603 ?

22:02 amalloy: kencausey: maybe i'm wrong, and it was chouser after all

23:12 icey: I'm doing a tour of the Clojure web stack, and getting to the "(not quite) real time" app phase of things. What is the commonly used stack for comet / server push apps? I *think* it's Compojure / Ring + Aleph.. Anyone using ClojureScript on the client-side yet, or is it all hand-rolled js?

23:17 dnolen: icey: seems like quite a few folks using ClojureScript now. Aleph for coment / server push seems common.

23:19 icey: dnolen: do you know if many people are using aleph.websockets, or mostly streaming http? (not a ton of docs out there on it, so i'm just trying to get a feel of a common use case)

23:20 dnolen: icey: it's been a while since I used aleph, but using aleph for websockets was pretty straightforwards. agree on the docs situation - the aleph ML helpful I think.

23:21 icey: dnolen: awesome, thanks.

23:21 dnolen: also - the pattern matching stuff you tweeted about earlier today looks awesome

23:21 dnolen: icey: thanks. it's a start. lotso stuff todo.

23:25 zmaril: If I wanted to learn how to think in lisp, what would be a good resource to read/use? Joy of Clojure and Programming Clojure are good introductions but they aren't quite doing it for me.

23:25 Scriptor: zmaril: reading the source for various functions helps

23:25 personally...I learned bits of haskell :p

23:26 icey: zmaril: it's not Clojure, but I enjoyed Practical Common Lisp

23:26 zmaril: Scriptor: I took a look at a The Haskell School of Expression and it looked like pure math by the end.

23:27 Scriptor: zmaril: eh, learn you a haskell was what I use

23:27 *used

23:27 zmaril: And that helps to understand functional programming then?

23:27 icey: Thank you! This looks neat.

23:27 Scriptor: definitely, it devotes a good bit of text on how to think in a functional way

23:28 whenever it introduced a new function I'd try to implement it myself without looking at the answer and see how it compared

23:30 zmaril: Scriptor: Haskell it is then. Thank you!

23:31 Scriptor: no prob!

Logging service provided by n01se.net