#clojure log - Jul 13 2014

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

0:05 seancorfield: be nice to have some ops in here to kick/ban the spammers

0:10 looks like technomancy is on the channel access list but is not an op?

0:24 technomancy: I'm an op when I need to be an op.

0:24 which as far as I can tell is not right now?

0:25 systemfault: Idiots tend to learn languages like PHP, C, Java… not Clojure. Been on the channel for months now, it’s an amazing community and I don’t remember seeing any OP

0:31 Zardoz: ls

0:31 lazybot: bin lib lib64 lost+found mnt proc run srv

0:31 technomancy: oh, just got PM spam

0:31 Zardoz: that was definitely the wrong window :P

0:32 gfixler: Zardoz: but it worked!

0:33 ls mnt

0:33 lazybot: etc home media opt proc run srv tmp

0:33 gfixler: ls mnt/home

0:33 lazybot: bin boot home lib lib64 lost+found opt proc root srv sys tmp var

0:33 Jaood: systemfault: what was your point?

0:47 andyf: Mostly a test message to see if spammers are around and what that looks like -- working on cheatsheet/Grimoire touchup enhancements

0:53 mthvedt: ls mnt/home/home

0:53 lazybot: boot dev etc home lib64 sbin srv tmp

0:53 mthvedt: ls mnt/home/home/home

0:53 lazybot: dev home lost+found opt proc root srv tmp

0:53 mthvedt: ls foo

0:53 lazybot: boot dev etc mnt proc run sys usr

0:54 technomancy: ls ignores its args is what you're trying to say, eh lazybbt?

0:54 lazybot: home lib64 opt run sys

0:54 technomancy: bot

0:54 wait what?

0:54 mthvedt: sudo ls -R /

0:57 trptcolin: https://github.com/Raynes/lazybot/blob/04fd054199a3f9c862714b1e0430bb1c9cb57912/src/lazybot/plugins/unix_jokes.clj#L9-L16

1:04 seancorfield: technomancy sorry... i went off to #freenode and was asking about staff and access list there... you'll see i posted to clojure-dev about it...

1:05 was that kikinii that you kicked/banned?

1:05 technomancy: yeah

1:05 I'm not on clojure-dev any more

1:05 another op would be a good idea

1:07 * Raynes votes amalloy

1:07 amalloy: technomancy: yeah, lazybot's response to ls is to randomly choose 5-10 of the directories in / and print them. it's fun watching people try to "hack" that

1:08 seancorfield: technomancy didn't realize you'd dropped off clojure-dev, sorry

1:09 * seancorfield is happy to be an op

1:09 seancorfield: after all, i'm freenode nearly 24x7 :)

1:11 i

1:12 i'm _on_ freenode nearly 24x7...

1:12 that's what i get for typing while watching R.I.P.D. ... :)

1:16 technomancy: I second amalloy, and as he's topped the karma list I think that counts as a third from lazybot

1:16 motion passes

1:16 seancorfield: :)

1:16 technomancy: oh, I'm not authorized to change the access list

1:16 welp

1:16 amalloy: oh man. guys. is there an acceptance speech? i'd like to thank my parents, and rich hickey

1:17 but actually i have no idea how to use ops. i'm a very low-tech irc user

1:17 * Jaood is going to beat amalloy's karma

1:17 technomancy: amalloy: repeat after me: "Klaatu, verata niktu"

1:18 amalloy: i'm worried that phrase might summon aliens or something

1:19 Jaood: what's wrong with having one more op? seancorfield seems like a good candidate

1:19 technomancy: Jaood: I think that requires the power of a chouser-level thetan.

1:20 chouser-level or higher, I mean

1:20 Jaood: we don't want him to slow down on java.jdbc anyways ;)

1:21 amalloy: i wonder if freenode ops would elevate technomancy, based on him being and op and no higher-powered ops having been in the channel for two weeks

1:22 technomancy: six months is enough time for freenode policy to consider a nick abandoned

1:24 Jaood: seancorfield vs amalloy on freenode

1:24 6 vs 3 years

1:24 seancorfield wins

1:25 seancorfield: hehehe, well, freenode can't do much right now since our ops are all absent or expired :)

1:25 but hopefully the other ops will step in any not be expired?

1:26 nathan7: oh hey

1:26 …nevermind that

1:27 seancorfield: and, Jaood thanx for the vote of confidence :)

1:41 hiredman: obviously we should only ever have one op at a time, with some kind of elaborate changing of the guard ceremony when who ever is an op goes offline

1:44 Jaood: seancorfield: :)

1:45 the Clojure Programming book has the word "semantic" on every page :P

1:54 andyf: Test message to see if I still have nick andyf after the freenode effort to weed out the clonebots

1:56 Jaood: andyf: how we know its you?

1:56 andyf: Because I'm not advertising anything :)

1:57 Jaood: clever clone ;)

1:58 andyf: Apparently there is a musical piece titled "Return of the Clonebots" that someone has written, according to Google (not an ad or endorsement :-)

3:41 ivan: &(.getBytes "hello" "UTF-8")

3:41 lazybot: ⇒ #<byte[] [B@131c5291>

3:43 opqdonut: &(seq (.getBytes "hello" "UTF-8"))

3:43 lazybot: ⇒ (104 101 108 108 111)

3:43 ivan: thanks, that's much better

3:52 I really wish I could represent and compare bytestrings with the same convenience of Python 2

3:53 right now I just wrote some software that breaks if file attrs are not UTF-8

4:18 andyf: ivan: Sounds like something you may be able to write your own function for? Or does Python 2's bytestring comparison do something fancy that would be difficult to implement?

4:21 justin_smith: ivan: do you primarily care about the bytes (fixed size numbers) or the chars (which can have various encodings, and depending on encodings, various sizes)

4:35 ivan: andyf: yeah, it shouldn't be too hard, but return byte-arrays would annoy users who expect strings from my library

4:35 anyway I did it right and they'll have to use (map as-utf8 whatever)

4:36 justin_smith: I don't really understand

4:38 justin_smith: a jvm byte is 8 bits. a jvm char is natively 16 bits, but can have a variety of sizes in various supported string encodings. So do you care about the bytes, or the chars that the bytes represent?

4:40 ivan: I care about fidelity when dealing with the bytes that I get from POSIX APIs like listdir or llistxattr

4:45 justin_smith: a UNIX file name is just a sequence of bytes, the kernel knows nothing about encoding

4:45 ivan: Python 2 is particularly convenient because you get the punt on the encoding, put bytestrings in your source (without .getBytes or whatever), compare bytestrings

4:46 is #bin in edn a thing? I saw puget printing it (#bin base64stuff) and it's awful

4:46 justin_smith: I think if you want fidelity to the original bytes, you should treat them as bytes, and not as chars

4:46 ivan: doesn't look like it re: edn https://github.com/edn-format/edn/issues/59

4:47 justin_smith: yeah, I did

4:48 https://www.refheap.com/5e86bbb357a521fb3bcb38baf/raw this took over an hour to figure out :-)

4:48 justin_smith: ivan: I think I was confused by your term "bytestring" - in the jvm byte and string are two different things

4:48 ivan: indeed

5:10 http://dev.clojure.org/jira/browse/CLJ-1025 it sure would be great to have this (printing \u escapes in a bytestring representation is misleading and wastes some space)

6:47 mschuene:

6:47 [Sun Jul 13 2014]

6:47 *** You have joined channel #clojure [12:37]

6:47 *** Topic for #clojure: Clojure, the language http://clojure.org | Currently

6:47 at 1.6.0; top analysts expect this to be followed by newer versions with

6:47 still higher numbers:

6:47 https://github.com/clojure/clojure/blob/master/changes.md | discussion:

6:47 http://groups.google.com/group/clojure

6:47 *** #clojure: topic set by

6:47 technomancy!~user@ec2-54-244-178-65.us-west-2.compute.amazonaws.com,

6:47 2014-03-26 17:33:15

6:47 *** Users on #clojure: mschuene edlothiol jmc75 jml kwladyka vyorkin

6:47 dark_element mengu afhammad programmancer dark4eg malbertife deadghost_

6:47 nooga bryanmaass borkdude Gonzih sillyotter deevus rtra annapawlicka

6:47 tgkokk kovrik Ven worrelsik vendethiel- d0ky yotsov onthestairs ambrosebs

6:47 Bronsa onr sputnikus telex danvet zeebrah xjiujiu telser io2 vurma

6:48 onr: :)

6:54 annapawlicka: i thought i was being summoned :)

7:08 * vendethiel- goes back to sleep

7:47 wink: anyone got a rough minimal ram figure for a very basic ring web app? I'm at 190MB now, that's not too bad, but still...

8:20 onr: wink: that sounds really bad

9:30 tvanhens: is there any way to "fake" saving a local file? I know thats not the right term, but I can't think of exactly what it is. Basically I am using the jopbox api and want to save some data to dropbox but I don't want to store that data on the local filesystem at all. The jopbox api uploads the file from a local directory to dropbox. Since heroku does not allow saving to the local filesystem, this is not possible (also seems like a bad

9:30 solution). Is there any way to pass in an argument thats like a "fake" local file which contains the data I want to save?

10:57 kegund: Day 3 w/ clojure. How to proceed? Emacs is now fully tweaked. I need to process a few sets of large sceince data in various ways. Any libraries to know about before starting?

12:22 broquaint: kegund: incanter?

12:58 lambda: Running cider-jack-in in emacs/osx is spitting out errors that basic unix commands are not found in lein script.

12:58 lein is working fine on the command line.

12:58 like, rm not found, etc.

12:58 Anybody has any idea what’s wrong with my emacs?

12:59 Starting nREPL server...

12:59 error in process sentinel: nrepl-server-sentinel: Could not start nREPL server: /usr/local/bin/lein: line 9: whoami: command not found

13:03 TimMc: lambda: /usr/local/bin/lein... how did you install lein?

13:04 (I'm not sure why that would make a difference, though...)

13:04 lambda: TimMc: Using the lein script from the website

13:04 lein -v shows me Leiningent 2.4.1

13:04 That’s on the command line

13:05 I don’t know how emacs is running it, but it’s not finding basic unix commands like rm and basename

13:05 TimMc: My lein doesn't have a whoami command in it. I wonder if that's a spurious line attribution.

13:06 catern: lambda: try M-! whoami

13:07 lambda: I did cat /usr/local/bin/lein | grep whoami and it’s there in the script

13:07 /bin/bash: whoami: command not found

13:07 TimMc: Weird. Not in 2.4.2.

13:08 catern: lambda: that's what you get from emacs?

13:08 lambda: heh, my emacs has gone bonkers

13:08 yeah

13:08 TimMc: lambda: Are you *sure* that's the lein from the website? That's where you put it?

13:08 catern: ok, so your emacs doesn't have the correct PATH env variable

13:08 you're starting it wrong or something, I don't know

13:08 TimMc: (And not the remnants of some distro install?)

13:08 catern: here's a nickel, get yourself a better operating system

13:08 lambda: I see. I use zsh in os x but emacs seems to be using bash

13:09 I use Ubuntu for most of the stuff and cider is running fine there. I just need some work to be done on osx also.

13:09 TimMc: catern: Haha, that's from Dilbert, right?

13:09 catern: TimMc: yes

13:10 lambda: okay, you persuaded me to help you. how do you start emacs?

13:10 lambda: I use Alfred, which just runs Emacs.app

13:10 catern: try starting it from the commandline and see if it works that way

13:11 lambda: I tried that, no difference

13:11 I’ll try to find how to fix bash environment for emasc on os x

13:11 It doesn’t seem to use my bash_profile

13:12 catern: when you run bash, everything works, right?

13:12 lambda: On the command line everything works, yeah

13:12 But I use zsh

13:12 Though I have set the same paths for both bash and zsh, and lein works in bash also

13:14 catern: right, the problem is with Emacs, not lein

13:14 lambda: Yeah, seems so. Purcell seems to have written a plugin just for osx emacs: exec-path-from-shell

13:14 Going to try that

13:18 amalloy: lambda: have you gone through http://www.emacswiki.org/emacs/EmacsApp#toc2 ?

13:19 osx emacs traditionally gives you a stupid PATH unless you ask for a good one

13:19 lambda: I have gone through it before but will go over it one more time

13:19 Thanks

13:20 The path is not getting set properly even if I start emacs from command line, like that wiki page suggests

13:25 TimMc: I'm still confused where it's getting whoami from.

13:28 lambda: TimMc: I checked, it’s the Homebrew version that’s installed on this osx.

13:29 * Bird|otherbox throws catern onto a box running TNS/R Guardian

13:29 Bird|otherbox: happy now?

13:32 catern: huh?

13:41 daGrevis: how can i get random element from a map? rand-nth doesn't work

13:41 justin_smith: ,(rand-nth (into [] {:a 0 :b 1}))

13:42 clojurebot: [:b 1]

13:42 justin_smith: that's one way

13:42 metellus: daGrevis: do you want a random key, value, or kv pair?

13:42 TEttinger: ,(rand-nth (values {:a 1 :b 2}))

13:42 clojurebot: #<CompilerException java.lang.RuntimeException: Unable to resolve symbol: values in this context, compiling:(NO_SOURCE_PATH:0:0)>

13:42 Luyt: daGrevis: Maybe make a seq of it first?

13:42 metellus: ,(rand-nth (seq {:a 1 :b 2 :c 3}))

13:42 clojurebot: [:b 2]

13:42 justin_smith: yeah, you could just call rand-nth of keys / vals

13:42 TEttinger: ,(rand-nth (vals {:a 1 :b 2}))

13:42 clojurebot: 1

13:45 daGrevis: metellus, pair

13:45 thanks, it makes sense

13:47 now, can I somehow unpack pair and give key and value a meaningful names?

13:47 justin_smith: for the into vs. seq, a rule of thumb would be to use seq if you are going to do it once, into if you are going to do it more (into has a higher overhead for making the result, but much faster lookup)

13:47 ,((fn [[k v]] {:key k :value v}) (rand-nth (seq {:a 0 :b 1 :c 2})))

13:47 clojurebot: {:key :a, :value 0}

13:48 justin_smith: destructuring works nicely

13:50 daGrevis: justin_smith, https://gist.github.com/5c508b8eeebcd9eb6fa6

13:50 how can i apply destructing to let's, I was thinking

13:50 justin_smith: daGrevis: (let [[k v] pair ...])

13:50 daGrevis: oh

13:51 justin_smith: ,(let [[k v] (rand-nth (seq {:a 0 :b 1 :c 2}))] {:key k :value v})

13:51 clojurebot: {:key :b, :value 1}

13:51 justin_smith: destructuring in arglists and let is identical

13:52 daGrevis: also, let is sequential

13:52 you don't need nested let

13:52 that is, binding n+1 can refer to binding n (unlike in common lisp)

13:53 ,(let [a 0 b (inc a) c (inc b) d (inc b)] d)

13:53 clojurebot: 2

13:54 justin_smith: err, meant to have d be inc c, but you get the idea I hope

13:54 daGrevis: i hope so too

13:54 thanks :)

13:55 ,(let [x 2 y (* x 2)])

13:55 clojurebot: nil

13:55 justin_smith: you would need to return one of those values :)

13:55 daGrevis: ,(let [x 2 y (* x 2)] y)

13:55 clojurebot: 4

13:56 daGrevis: ;)

13:56 so it makes this https://gist.github.com/2dc82333bb437558d4cb

13:56 justin_smith: looks about right

13:57 also, you could optionally break the seq and rand-nth calls into their own lines, depending on what results in clearst code in the end

13:57 but that's a preference thing, of course

13:58 daGrevis: yes i will probably do that, but first i want my tests to pass

13:58 by the way, do I structure my tests correctly? https://gist.github.com/f26f15c7ea495238c57d

13:59 justin_smith: daGrevis: if you only have one testing per is, you can also just use the optional second arg to is

13:59 instead of the wrapping testing form

14:09 daGrevis: so I have this test in which I need to mock rand-nth to always return known entry. how can I do that?

14:10 i mean, is it possible w/o 3rd party?

14:11 i found with-redefs

14:41 Fare: which test framework do you recommend for simple testing?

14:41 and what do you recommend as a mechanism for reporting errors to the end-user?

14:44 justin_smith: daGrevis: is passing it a collection with 1 element / all elements identical out of the question?

14:45 Fare: for the former, clojure.test, for the latter, it depends on how the end user interacts with your project

14:49 Fare: I don't know yet. For now, I'm interacting at the REPL

14:50 parsing files in python, and wondering what's the right way of architecting the display of syntax errors

14:54 mi6x3m: is it idiomatic to call a listener in clojure on-something

14:54 on-select for instance

15:15 justin_smith: even better, you can use CSP via core.async so you don't even need to do things in terms of callbacks, but yeah on-foo is a decent naming scheme for listeners

16:25 mbac: off topic but listen to some techno while you hack clojure why not? http://www.mixify.com/michael-bacarella/live/omfg-sunday-wtf/

16:26 justin_smith: mbac: fyi, though we are pretty lenient about off topic stuff here, there is a #clojure-offtopic channel

16:29 mbac: word

16:58 augustl: does it make sense to depend on clojure.jar for a non-Clojure project where I want to use the data structures (just invoke the Java API)?

16:58 or: does depending on Clojure have side-effects

16:58 ?

17:10 ivan: augustl: maybe you want https://github.com/krukow/clj-ds

17:10 amalloy: augustl: it's perfectly reasonable to depend on clojure.jar from a java-only project that wants immutable data structures

17:12 augustl: ivan, amalloy: since clj-ds is on 1.5 at the moment I'd prefer to just depend on Clojure itself :)

17:42 TimMc: augustl: If you do: https://github.com/timmc/johnny/commit/340a217e4554ca296351affbc20911aeb805d85a#diff-0

17:42 (since RT.init() prints to stderr and is a lie)

17:43 mi6x3m: can one execute if-let with multiple bindings?

17:44 ,(if-let [x nil y 2] nil nil)

17:44 clojurebot: #<IllegalArgumentException java.lang.IllegalArgumentException: if-let requires exactly 2 forms in binding vector in sandbox:>

17:44 mi6x3m: there's my answer

17:45 ,(macroexpand-1 '(if-let [x nil y 2] nil nil))

17:45 clojurebot: #<IllegalArgumentException java.lang.IllegalArgumentException: if-let requires exactly 2 forms in binding vector in sandbox:>

17:45 TimMc: mi6x3m: Various people have written if-let+ or similar.

17:45 mi6x3m: Here's my version: https://github.com/timmc/handy/blob/master/src/org/timmc/handy.clj#L6

17:45 mi6x3m: TimMc: true, question is whether it makes sense to use one of those :)

17:46 TimMc: let me see :)

17:47 TimMc: is your lib lein'd ?

17:47 i see yes :)

17:49 TimMc: Other folks have made different variants. (Code repetition vs. thunk for else clause.)

17:56 mi6x3m: TimMc: i settled for yours, works nicely :)

19:04 gfredericks: have there been any attempts at enabling (somehow) annotating functions with example input-output, primarily for documentation, with optional test integration?

19:04 every time I embed example calls to a function inside a docstring it makes me a little sad

19:07 nathan7: gfredericks: you could make a prototype that works now

19:08 gfredericks: a macro that replaces your defn with a version that *reads* that data and builds a regular docstring out of it

19:09 gfredericks: keeping the original docstring as :your.prototype/doc

19:11 gfredericks: so write a macro to use instead of defn?

19:11 so many prospective features have that as the only rational path to realization...doesn't seem scalable.

19:17 technomancy: gfredericks: there should be a convention for metadata that's not a docstring but still relevant to display when docstrings are shown

19:17 :doc/examples [...] or something

19:20 nathan7: gfredericks: it's very popular for many languages

19:20 gfredericks: ES6 promises were developed entirely outside the language, as just programs

19:21 gfredericks: like, what is becoming ES6 promises now — Promises/A+ was the 'prototype'

19:28 gfredericks: technomancy: yeah I was thinking that; but also you'd have to suggest how to render it?

19:29 technomancy: I wonder if the ^:internal convention from lein has caught on elsewhere

19:44 kristof: Weren't we just talking about that a few weeks ago?

20:08 arrdem: technomancy: what does ^:internal buy you? just a warning to the user? it's not like the compier warns that you're crowbaring into an "implementation detail".

20:08 *compiler

20:13 gfredericks: I keep trying to design a generic defn-macro-creator so that you can mix together whatever features you're interested in

20:13 I wonder if nrepl's middleware model could make that sane

20:14 mdeboard: a macro macro?

20:16 gfredericks: eh, sorta

20:16 not as impossible to wrangle as a literal macro-macro

20:16 mdeboard: `,`@'body

20:16 night terrors

20:17 gfredericks: you'd implement feature by providing a middleware that transforms the form

20:23 TimMc: gfredericks: Yeah, the various defn macros are particularly non-composable.

20:32 Middleware is the least offensive idea I can think of.

20:41 technomancy: arrdem: it's a warning to the user, yeah

20:52 verma: hey everyone, I am trying to learn clojure macros, I am trying to write a macro that would run the given body in reverse, like (do-reverse (print "hello") (print ("world")) should print "worldhello"

20:55 arrdem: verma: well your second print will try to call a string as a function which doesn't work..

20:55 gfredericks: TimMc: that's a good description

20:56 verma: arrdem, sorry mistyped that

20:56 arrdem: verma: but such a thing is pretty easy. you just need a macro that splices the reverse of its arguments into a do form. I'd read up on macro splicing in clojure, the do special form and variadic functions.

20:56 verma: it is (print "world")

20:56 arrdem: verma: or I can just give you the answer now #spoilers

20:57 * arrdem wished Grimoire had a macro cheat sheet already

20:57 verma: arrdem I am trying to splice unquuote-splice the reverse, but its not working :(

20:57 arrdem ~@(reverse body)

20:57 justin_smith: ,(do (defmacro do-reverse [& body] (cons 'do (reverse body))) (do-reverse (print "hello") (print "world")))

20:58 clojurebot: worldhello

20:58 justin_smith: no need for syntax quote here

20:58 arrdem: justin_smith: eh... I'd write it as (defmacro do-reverse [& body] `(do ~@(reverse body))) rather than using cons but it gets you the same place.

20:58 verma: arrdem, justin_smith oh shit! :)

20:58 arrdem: SPOILERZ

20:59 verma: code is data is code is fucking hard for my brain :(

20:59 justin_smith: arrdem: my thought was, as a beginner it's helpful to explicitly work with the form, and then use the magic once it makes more sense

20:59 gfredericks: (apply concat (list (list (quote do)) (cond->> body true (reverse))))

20:59 arrdem: justin_smith: meh they'll learn the macro syntax eventually if they don't see it first. I'd rather use it and teach it than leave it as black magic.

20:59 gfredericks: ^enterprise style

20:59 arrdem: lololol\

21:00 * arrdem starts writing a macros cheat sheet for Grimoire

21:00 verma: ok, I was missing the "do"

21:00 johnwalker: (inc arrdem)

21:00 lazybot: ⇒ 33

21:00 verma: my first print was evalauating to nil which was being called as a function

21:01 johnwalker, what's this?

21:01 johnwalker: verma: the inc?

21:01 verma: in inc arrdem specifically

21:01 no*

21:01 johnwalker: it adds to a users reputation

21:02 verma: oh ok :)

21:02 arrdem: verma: note that normally inc is pure and has no side effects. here inc is a lie and has side effects :P

21:02 &(-> 1 inc inc inc)

21:02 lazybot: ⇒ 4

21:03 verma: lol

21:04 can I not use ~@ outside of a macro definition?

21:05 justin_smith: verma: yes, but only inside `

21:05 arrdem: no. ~@ is syntax-quote magic.

21:05 eh... okay. I'm wrong and justin_smith is right

21:05 justin_smith: ,`(a b c)

21:05 clojurebot: (sandbox/a sandbox/b sandbox/c)

21:05 justin_smith: ,`(a b c ~@[0 1 2])

21:05 clojurebot: (sandbox/a sandbox/b sandbox/c 0 1 ...)

21:06 justin_smith: clojurebot, that 2 is shorter than your ...

21:06 clojurebot: 'Sea, mhuise.

21:06 justin_smith: ~that 2

21:06 clojurebot: that 2 is shorter than your ...

21:07 justin_smith: how do I make it forget things again?

21:07 gfredericks: ,(alter-var-root #'clojure.core/unquote-splicing (constantly (constantly 42)))

21:07 clojurebot: #<core$constantly$fn__4085 clojure.core$constantly$fn__4085@c25346>

21:07 gfredericks: ,~@(hehe)

21:07 clojurebot: #<CompilerException java.lang.RuntimeException: Unable to resolve symbol: hehe in this context, compiling:(NO_SOURCE_PATH:0:0)>

21:07 gfredericks: ,~@(:hehe)

21:07 clojurebot: #<IllegalArgumentException java.lang.IllegalArgumentException: Wrong number of args passed to keyword: :hehe>

21:07 gfredericks: ,~@(+ 1 2)

21:07 clojurebot: 42

21:07 gfredericks: phew

21:07 arrdem: gfredericks: you broke the bot. wp.

21:07 gfredericks: ,(alter-var-root #'clojure.core/unquote (constantly inc))

21:07 clojurebot: #<core$inc clojure.core$inc@192c07a>

21:07 gfredericks: ,~~3

21:07 clojurebot: 5

21:08 arrdem: verma: this is black magic. please don't try this at home

21:08 gfredericks: ,~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~0

21:08 clojurebot: #<IllegalStateException java.lang.IllegalStateException: Attempting to call unbound fn: #'clojure.core/unquote>

21:08 gfredericks: ,(alter-var-root #'clojure.core/unquote (constantly inc))

21:08 clojurebot: #<core$inc clojure.core$inc@1f530ab>

21:08 gfredericks: ,~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~0

21:08 clojurebot: 42

21:08 johnwalker: lol

21:08 verma: dafuq

21:08 arrdem, not trying it .... yet

21:09 * gfredericks has actually never tried this before

21:09 arrdem: verma: ~, `, ~@ and ' are hacks, gfredericks is mucking with the symbols they translate into and doing evil things

21:09 gfredericks: I dunno if I'd describe ' as a hack

21:10 fifosine: Anyone here familiar with working with Datomic? I'm trying to delete an entity but I get the error ":db.error/datom-cannot-be-altered Boot datoms cannot be altered: [:db/excise :db/valueType :db.type/ref 13194139534317 false]"

21:10 verma: arrdem, I am going to leave them alone for now

21:10 :)

21:10 gfredericks: clojurebot: ' is not a hack

21:10 clojurebot: Ok.

21:10 gfredericks: ~'

21:11 clojurebot: ' is the quoting you want here

21:11 arrdem: verma: they're fine to use, just don't use alter-var-root until you're really really sure what you're doing.

21:11 gfredericks: only do it for funsies

21:11 arrdem: or when you need to add features to clojure.core :X

21:11 gfredericks: yeah I guess that doesn't preclude normal macro usage does it

21:11 ,~0

21:11 clojurebot: 1

21:12 gfredericks: ,(defmacro thing [x] `(identity ~x))

21:12 clojurebot: #'sandbox/thing

21:12 metellus: ,~~0

21:12 gfredericks: ,(thing 99)

21:12 clojurebot: 2

21:12 99

21:12 gfredericks: arrdem: okay it's totes cool

21:12 rich put it there for such a time as this

21:13 ,(alter-var-root #'clojure.core/unquote (constantly reverse))

21:13 clojurebot: #<core$reverse clojure.core$reverse@3af8a6>

21:13 gfredericks: ,~"foo"

21:13 clojurebot: (\o \o \f)

21:13 andyf: Mom, Gary's messing with the bot again!

21:14 verma: lol

21:14 * gfredericks runs off to do chores

21:16 arrdem: quick someone alter-var-root on eval to (constantly 42)

21:27 gfredericks: before it's too late!

21:34 masonn: does anything else besides false a nil evaluate to false in a boolean context?

21:35 and

21:36 justin_smith: masonn: false and nil are the only "falsey" values

21:37 masonn: nil is used to indiate no value?

21:38 verma: ,(into {] [[:hello "world" :bye "world"]])

21:38 andyf: masonn: This is a real corner case, probably only arising if you do Java interop with Java Boolean values, but in Java and Clojure a freshly constructed Boolean object is treated as true, even if the value it contains is false: http://grimoire.arrdem.com/1.6.0/clojure.core/if/

21:38 clojurebot: #<RuntimeException java.lang.RuntimeException: Unmatched delimiter: ]>

21:38 andyf: nil is Java null

21:38 gfredericks: masonn: or something

21:39 verma: ,(into {] [[:hello "world"] [:bye "world"]])

21:39 clojurebot: #<RuntimeException java.lang.RuntimeException: Unmatched delimiter: ]>

21:39 verma: ,(into {} [[:hello "world"] [:bye "world"]])

21:39 clojurebot: {:hello "world", :bye "world"}

21:39 andyf: masonn: Ignore that comment and link I sent you if you aren't doing Java interop

21:39 justin_smith: masonn: yes, it often comes from get with a selector that isn't in the collection

21:39 ,(get [] :a)

21:39 clojurebot: nil

21:39 verma: ,(into {} (partition 2 [:hello "world" :bye "world"]))

21:39 clojurebot: #<ClassCastException java.lang.ClassCastException: clojure.lang.Keyword cannot be cast to java.util.Map$Entry>

21:40 verma: how are these two different?

21:40 gfredericks: partition returns seqs

21:40 justin_smith: verma: a seq cannot be a map entry, a vector can

21:41 verma: justin_smith, hmmm

21:41 justin_smith: ,(into {} (map vec (partition 2 [:hello "world" :bye "world"])))

21:41 clojurebot: {:hello "world", :bye "world"}

21:42 justin_smith: once you have vectors, it is fine

21:42 verma: justin_smith, hmm ok, thanks

21:45 justin_smith: ,(apply hash-map [:hello "world" :bye "world"]) verma: also, consider this

21:45 clojurebot: {:hello "world", :bye "world"}

21:45 verma: justin_smith, nice

21:46 here it shouldn't matter if that second argument is a vec or a list, right

21:46 justin_smith: right

21:46 because apply is different

21:46 ,(apply hash-map '(:hello "world" :bye "world"))

21:46 clojurebot: {:hello "world", :bye "world"}

21:46 verma: nice

21:46 justin_smith: into is stricter (and faster, if things are already shaped the way it likes)

21:56 gfredericks: into doesn't need a top-level vector either

21:56 just that the pairs themselves are vectors

21:56 verma: haha shit man, macros so awesome

21:56 gfredericks: uh oh

21:56 verma: ama gonna create a new language using clojure

21:57 gfredericks: ,(defn impoverish [data] (clojure.walk/postwalk #(if (zero? (rand-int 2)) %) data))

21:57 clojurebot: #<CompilerException java.lang.ClassNotFoundException: clojure.walk, compiling:(NO_SOURCE_PATH:0:0)>

21:57 gfredericks: nevermind I'm going to bed

22:47 Fare: debugged the lexer, now debugging the parser

22:47 what do you use to debug clojure code?

22:49 justin_smith: Fare: what I do is keep my functions as stateless as possible, and provide tests with the range of inputs selected. If those tests don't catch the error, then use an atom to record the inputs I actually get at runtime, and make tests out of those if they were not in the expected range.

22:50 s/selected/expected

22:51 also, move all possible logic out of stateful code and into stateless, so most everything can be trivially tested without magic or mocking

22:53 andyf: Fare: printf, clojure.tools.trace

22:56 Fare: justin_smith, yes, I'm writing in mostly pure functional style

22:56 so all the debugging is happening with pure functions

22:57 andyf: thanks!

22:57 FileNotFoundException Could not locate clojure/tools/trace__init.class or clojure/tools/trace.clj on classpath: clojure.lang.RT.load (RT.java:443) — it's not builtin?

22:58 andyf: also pprint is nice for big data structures, especially nested maps

22:58 Frozenlock: pprint is one of those function I'd like in every namespace in my repl

22:58 drusellers: agreed

22:59 andyf: Fare: no, a separate lib that you can add to your Leiningen dependencies, assuming you are using Leiningen. Line to add to your dependencies for latest version at the README here: https://github.com/clojure/tools.trace

22:59 justin_smith: also, if it was not clear, what I meant about the map thing was (def calls (atom {})) (defn debugged-f [args] (let [... result (frob args)] (swap! calls assoc args result) result))

22:59 *the atom thing that is

23:00 Fare: [com.gfredericks/tools.trace "0.7.3-SNAPSHOT"] ?

23:00 justin_smith: that way you can use your repl to interactively look at the args / try variations, etc.

23:01 andyf: Fare: That looks like a version customized by someone else. The README I linked to says this: [org.clojure/tools.trace "0.7.8"]

23:03 Fare: that's the one I found on clojars

23:04 andyf: Clojure core team distributes their libs via maven.org repos. You can search for them at search.maven.org

23:06 Frozenlock: Before I start coding... is there a library to make tutorials for ring websites?

23:06 TEttinger: Frozenlock: ?

23:06 tutorial to make libraries, you mean?

23:06 Frozenlock: No, I mean what I said :-p

23:06 kristof: Fare: Hello!

23:06 Fare: What exactly are you working on?

23:06 brehaut: Frozenlock: O_o

23:07 Frozenlock: TEttinger: sya I have a website in ring. I'd like to make a tutorial to guide a user through many steps (pages).

23:07 Surely this can be done with middlewares

23:07 *say

23:07 Fare: kristof, still the same: a compiler for a pure python dialect

23:07 kristof: I never knew what you were working on :P

23:07 Fare: right now, debugging a python 3.5 parser

23:07 the lexer is pretty stable now

23:08 Frozenlock: Does my question make more sense now? :-p

23:09 TEttinger: yes, you kinda want a chain-of-pages thing

23:09 Frozenlock: Ahhh, that's the technical term I was lacking. Chain-of-pages.

23:10 Fare: ClassCastException java.lang.Long cannot be cast to java.lang.String clojure.lang.Compiler.analyze (Compiler.java:6464) — how do I get a backtrace?

23:10 (.printStacktrace *e) isn't very helpful

23:11 wow, the REPL is hosed. Is it worth trying to debug it?

23:11 I hosed it with (set! *file* 0)

23:12 TEttinger: Frozenlock, not a technical term at all! but it should be what you need, right? I mean even webcomics and blogs have a similar need

23:12 Frozenlock: Oh, wait, I'm not sure that's what I want.

23:12 brehaut: TEttinger, Frozenlock: pagination?

23:12 TEttinger: thanks brehaut

23:13 Frozenlock: Wow I must suck at explaining

23:13 I'll be back...

23:14 TEttinger: Frozenlock, you want to have a continuous stream of read this->next->read this new thing->next, but also the ability to bookmark or skip around mid-way?

23:14 like http://www.xkcd.com/

23:15 Frozenlock: https://www.refheap.com/88141

23:16 Is this more clear?

23:16 TEttinger: much

23:16 that seems like a common pattern, it could be a lib

23:16 but I kinda doubt it

23:17 Frozenlock: Well, that's why I asked. I don't want to redo what has already be done. (and probably of higher quality than what I could do)

23:18 Seems like middlewares are an obvious solution for this. You can associate the tutorial to a ring session and just pop the stack at each steps.

23:18 TEttinger: I rewrote a java lib's Timer class in C# because synchronized doesn't behave like lock does. the original Timer class re-implemented functionality in java itself, I believe...

23:18 re-writing does happen for all sorts of reasons!Z

23:21 brehaut: Frozenlock: why does it need to be stateful?

23:22 Frozenlock: To know at which step the user is?

23:22 brehaut: the users client can track that?

23:23 (ie, you send the link to the next step with the current step, and the client follows that as needed)

23:23 Frozenlock: as in "/tuto/1" "/tuto/2" ?

23:23 brehaut: sure

23:24 Frozenlock: Eh, sounds dangerous to me. What if the user clicks on something else? If it's in the session, you can see it and guide him back to the right place.

23:25 brehaut: if you arent tracking per user state, then its really non-dangerous. they can go back and forth as needed without you having to trak tha

23:29 Frozenlock: Dangerous to lose the user. He's at "/tuto/12" and then clicks on "/home" or whatever.

23:30 andyf: Fare: Can you do a paste of what (.printStackTrace *e) showed you? (clojure.repl/pst *e) may give a nicer format for Clojure stack traces.

23:30 but maybe not, depending on what it looks like

23:30 Frozenlock: Or do you think the user is smart enough to press 'back'? :-p

23:30 andyf: Also, don't do (set! *file* 0) :-)

23:31 Fare: andyf: nothing more than what I showed. Looks like the clojure runtime is just not prepare for *file* being of the wrong type

23:31 Frozenlock: But it would be simpler... I think the pages are already in HTML for the middlewares...

23:31 andyf: Fare: I've never tried that, but not surprised if that messes up something fairly deep down in the compiler

23:32 Fare: Strings are better :)

23:33 brehaut: Frozenlock: is this a tutorial for people recently defrosted from cryostorage?

23:33 Fare: (incredible how much smaller than the java code this parser is, btw)

23:34 Frozenlock: brehaut: I'd say for people who can't see a difference between IE and Chrome. "It's the Internet."

23:34 Fare: yeah, since my parser reports the value of *file* everywhere (or should I be using a different parameter?), I figured I'd bind it to something with a very short representation. What's shorter than nil? Why, 0!

23:35 TEttinger: Frozenlock, heh I installed an antivirus software for a woman who didn't know that yahoo was internet

23:36 Frozenlock: Yeah, I'm sure it's most of the population. We take so much information for granted...

23:37 For example, I recently realized that using 'placeholders' in html forms is confusing for some people, because they think it's already filled.

23:37 xk05: hm emacs-live with overtone looks interesting

23:38 * Fare successfully parses "1+2"

23:38 xk05: i've got a fender strat with a little 35w practice amp that i play around on, this would be a good backup

23:40 Fare: OK, one thing I'm missing for a full python 3.5 lexer is better unicode support.

23:40 brehaut: xk05: 35w is little O_o?

23:41 xk05: 35 watts? yeah

23:41 Fare: is the solution ICU4J ?

23:42 brehaut: xk05: what constitutes loud then?! 5 watts is capable of pushing 100dB

23:42 xk05: its about the size of a small desktop tower

23:42 maybe i mean amps

23:42 brehaut: xk05: nobody measures amps in amps

23:43 Frozenlock: uh?

23:43 brehaut: xk05: that would super confusing too :

23:43 xk05: actually its 38

23:44 Frozenlock: Intensity is measured in amperes, is it not?

23:44 You are kidding me...

23:44 justin_smith: Frozenlock: decibels

23:44 Frozenlock: (dec Intensity)

23:44 lazybot: ⇒ -1

23:44 Frozenlock: (dec so)

23:44 lazybot: ⇒ -31

23:44 Frozenlock: Stop using words as username!

23:44 brehaut: xk05: wait, is this a solidstate frontman?

23:45 Frozenlock: I meant electric intensity -_-

23:46 xk05: it looks like this: https://reverb.com/item/141098-fender-frontman-pr-241-black

23:46 clojure sure has come a long way

23:46 brehaut: xk05: yes thats solid state. as you were then.

Logging service provided by n01se.net