#clojure log - Aug 02 2014

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

3:38 dazone: Hello 안녕하세요

5:06 blunte: ? given a record with fields :a, :b, and :c, how can I retrieve the values for a list/vec of keys such as (:a :c)?

5:07 arrdem: &(map (partial get {:a 1 :b 2 :c 3 :d 4}) [:a :b :c])

5:07 lazybot: ⇒ (1 2 3)

5:07 blunte: but the operator function in this case is the key name

5:07 ah let's see

5:09 so "get" is what I didn't know about. that brings me to another question. Is there documentation that shows a comprehensive list of operations for a given type/thing? Like if I look up records in clojure, I would like to see not only details on how to construct, but also various ways of interacting with that thing

5:09 arrdem: thanks, by the way :)

5:10 with "get" as example, I hadn't seen that yet. All the info I see shows (:keyname my-record)

5:11 arrdem: http://clojure.org/data_structures#Data%20Structures-Keywords

5:13 blunte: ah ha, my failure at reading then :). Thanks again

5:13 arrdem: np

5:16 TEttinger: there's also less-comprehensive docs (but organized well, and with examples) at clojuredocs

5:16 http://clojuredocs.org/quickref/Clojure%20Core

5:16 it's somewhat out-of-date, but the core language is all there. clojuredocs is stuck on version 1.3...

5:17 arrdem: http://jafingerhut.github.io/cheatsheet/grimoire/cheatsheet-tiptip-cdocs-summary.html

5:19 blunte: great, I'll take a look at both

5:20 TEttinger: arrdem, what version is that? I see no reduced

5:21 arrdem: TEttinger: latest. huh. looks like there isn't reduced at all...

5:27 Glenjamin: did the cheatsheet used to have reduced on it?

5:28 oo, the "Examples" headings in grimoire don't check the :added metadata

5:29 arrdem: Glenjamin: hum?

5:30 Glenjamin: http://grimoire.arrdem.com/1.6.0/clojure.core/reduced has an empty heading for 1.4, but :added says 1.5

5:30 arrdem: Glenjamin: oh... you're saying it should 404 for 1.4.0?

5:31 derp

5:31 gotcha

5:31 * arrdem ponders

5:31 Glenjamin: it does 404 (which is blank), but there also shouldn't be an "Examples from Clojure 1.4.0" section

5:32 arrdem: yeah... thinking about how to address that.

5:32 Glenjamin: just about to update my PR, the contributing.md with the notes on how to syntax highlight seem to have gone awol?

5:32 arrdem: http://grimoire.arrdem.com/contributing

5:33 Glenjamin: ah, the readme links to http://grimoire.arrdem.com/contributing/ which 404s

5:34 arrdem: so if you want to add an example for clojure.core/foo, just go to the page, click add example, choose a random filename (it totally doesn't matter) and paste in a REPL session. that's it.

5:34 * arrdem facedesk

5:34 arrdem: there's no longer any markup required

5:34 Glenjamin: oh, neat

5:34 arrdem: yeah that was the big point of 0.3.0

5:34 get rid of the markup requirement and make each example its own file

5:35 Glenjamin: i think the "contribute an example!" links are missing /resources/

5:35 arrdem: fucking really...

5:35 gah

5:35 * arrdem fixes

5:36 TEttinger: thanks for contributing to the docs, Glenjamin, arrdem

5:36 blunte: I second that

5:40 arrdem: okay Glenjamin what was the other one...

5:40 oh. right. :added

5:40 also real 404 fails...

5:45 okay... the version range thing I'll fix some other time

5:48 Glenjamin: hotfix'd

5:48 Glenjamin: cheers

5:48 arrdem: ugh that's embarasing

5:49 <3 patches against develop

5:50 another reason for 0.3.0... lets me be more of a git-flow nazi

5:50 Glenjamin: thanks for the pr!

8:19 vdmit11: Hi folks. I have a Java array of objects of non-primitive types. The problem is the "aget" seems to be slow because of the reflection. Can I provide type hints for non-primitive arrays? Or perhaps can I transform the array into something else where I can provide hints?

8:22 The array is created only once at program startup, but then it is may be accessed a million times (literally), so I would like to optimize "get" perhaps in cost of transforming the array into another data structure.

8:22 Bronsa: vdmit11: aget requires reflection only if used as a HOF

8:23 ,(set! *warn-on-reflection* true)

8:23 clojurebot: #<IllegalStateException java.lang.IllegalStateException: Can't change/establish root binding of: *warn-on-reflection* with set>

8:23 Bronsa: shush

8:23 ,*warn-on-reflection*

8:23 clojurebot: false

8:23 Bronsa: vdmit11: http://sprunge.us/gDPZ?clj

8:24 you just need to type-hint the return value of the aget since aget will return an Object

8:29 vdmit11: Bronsa: http://pastebin.com/AWuCZYqU - how about this?

8:29 why doesn't it work

8:30 Bronsa: vdmit11: hint array with ^objects

8:31 (aget ^objects array 0)

8:32 vdmit11: clojure only has local type inference you need to explicitely tag vars

8:33 vdmit11: Bronsa: thanks

8:33 Bronsa: vdmit11: if you have lots of aget calls on that var you can tag directly the var rather than tag it at each invocation site

8:33 (def ^{:tag 'objects} array ..)

8:34 vdmit11: np

9:00 * Fare ports his DBG macro to clojure

9:00 Fare: so, I'm starting to have a collection of small-time utilities

9:00 is there a place to contribute them to?

9:05 hyPiRion: Fare: https://github.com/weavejester/medley or https://github.com/flatland/useful

9:05 Fare: thanks!

9:16 useful has lots of good stuff

9:16 it's a bit chunky, though

9:17 (inc hyPiRion)

9:17 lazybot: ⇒ 41

9:17 hyPiRion: Fare: right, it's a huge chunk of functions – it's not necessarily the thing you want

9:18 I just heard "collection of small-time utilities" and took what I had at the top of my head

9:19 Fare: ok, so does map always return a list as per list? ?

9:20 apparently not.

9:20 how do I make it so?

9:21 hyPiRion: map always return a (possibly chunked) lazy-seq

9:21 Fare: with (into () ...)

9:22 hyPiRion: Fare: that reverses the order though. perhaps (apply list (map ...)) works, but think about why you want it to be a list in the first place

9:22 it might be that persistent vectors is fine for the job at hadn

9:22 *hand

9:24 Fare: is it OK to have macros return lazy-seq's?

9:24 when I analyze source code, how do I distinguish between list and vector?

9:24 or is that vector and anything-but-vector?

9:26 hyPiRion: Fare: mmm, right, I understand your concern. Generally you'd use seq? for list-like things, vector? for vectors, map? for maps, set? for sets

9:26 no problem with emitting lazy seqs from macros as far as I know

9:27 Fare: apparently, a vector is not a seq?

9:27 interesting

9:28 hyPiRion: Fare: A vector is sequential, but not a seq in and by it self

9:29 I tend to think of seqs as things which wraps what it contains in parens

9:30 visof: hi

9:30 is this conversion right? https://www.refheap.com/88832

9:31 please anybody help

9:31 hyPiRion: visof: yes, that seems to look right

9:31 visof: hyPiRion: i got this error: java.lang.IllegalArgumentException: No matching field found: execute for class com.orientechnologies.orient.graph.gremlin.OCommandGremlin

9:32 hyPiRion: boo

9:33 visof: hyPiRion: check this http://www.massapi.com/class/com/orientechnologies/orient/graph/gremlin/OCommandGremlin.java.html check the first example

9:34 hyPiRion: visof: ah

9:34 visof: hyPiRion: ?

9:36 hyPiRion: could you try (. (.command db (OCommandGremlin. "g.V[0..10]")) (execute)) instead?

9:36 I think (.. db (command (OCommandGremlin. "g.V[0..10]")) (execute)) should be the equivalent statement.

9:36 an equivalent*

9:37 visof: hyPiRion: what is the difference?

9:41 hyPiRion: visof: (.a x) expands to (. x a), which may translated to a field lookup, whereas (. x (a)) is always a method call. Not sure if that solves your original problem, but it should make it explicit for the compiler that you're referring to a method

9:41 that being said, I've not done a lot of work with method calls, so I may be wrong

9:44 visof_: hyPiRion: are you there

9:44 hyPiRion: yes

9:44 visof_: hyPiRion: i have tested both with the same error

9:48 error: No matching method found: execute for class com.tinkerpop.blueprints.impls.orient.OrientGraphCommand and http://www.tinkerpop.com/docs/javadocs/blueprints/2.4.0/com/tinkerpop/blueprints/impls/orient/OrientGraphCommand.html tell there is execute method for this class

9:48 can anybody help in this?

9:49 pyrtsa: visof_, hyPiRion: Is `execute` a variadic method? I.e. `execute(Object... args)`? In that case, you'd need to call it with another argument, an empty `(object-array [])`.

9:49 hyPiRion: visof_: oh, you're trying to call a vararg method?

9:49 pyrtsa: yeah, I just realised ;_;

9:50 visof_: pyrtsa: so i need to call it with (.execute (...) []) ?

9:50 pyrtsa: Googled it. :)

9:50 hyPiRion: visof_: (.. db (command (OCommandGremlin. "g.V[0..10]")) (execute (object-array [])) should work

9:50 pyrtsa: That. ^

9:50 visof_: pyrtsa: what google results you get ?

9:51 pyrtsa: visof_: Well, just googled to find out what the method signature of execute() was. You should be aware of these issues when doing Java interop

9:52 visof_: pyrtsa: hyPiRion thanks guys

9:54 got another error: java.lang.IllegalAccessError: class com.tinkerpop.blueprints.impls.orient.OrientGraphQuery$OrientGraphQueryIterable cannot access its superclass com.tinkerpop.blueprints.util.DefaultGraphQuery$DefaultGraphQueryIterable

11:00 mdo_: hello

11:02 l3dx: anyone using liberator? I can't figure out how to set the Location header after doing a successful POST (201)

11:07 tcsavage: l3dx: (ring-response {:headers {"Location" "http://urlwhatever"}}) should do the trick

11:07 it's a bit messy to use ring directly but it seems like the easiest way to do it

11:08 vsj_: Hello, I'm still new to Clojure and I've a question about nested vectors (output of instaparse)

11:08 Here's the example:

11:09 [[:t [:a 1] [:b [[:e 4] [:f 5]]] [:c 3]] [:t [:a 4] [:b [[:e 7] [:f 8]]] [:c 6]]]

11:09 I'd like to extract the values related to :f anc :c, ie expected output: [5 3] [8 6]

11:09 What is the best way to do this? I played around with zippers, walk, etc. but it seems to complex

11:10 Thanks in advance

11:10 tcsavage: is there a reason why you're using nested vectors [:a [...]] rather than a map? {:a [...]}

11:11 vsj_: It's instaparse output

11:11 l3dx: tcsavage: thanks

11:12 vsj_: To be more accurate, its a seq with nested vectors, like this ([:t [:a 1] [:b [[:e 4] [:f 5]]] [:c 3]] [:t [:a 4] [:b [[:e 7] [:f 8]]] [:c 6]])

11:13 l3dx: I'm a bit surprised that it isn't handled by liberator. thought that was kind of rest/hypermedia-101 :) (but I don't know. I'm kind of a newbie when it comes to this topic)

11:14 ambroseb_: vsj_: try changing the output format https://github.com/Engelberg/instaparse#output-format

11:15 tcsavage: l3dx: there are a few things liberator doesn't handle too well, but it's pretty good as the basics

11:20 l3dx: tcsavage: yes it seems very promising

11:20 vsj_: the other output format turns it into somekind of dict, but much more complicated than it needs to be, with things like { :tag :t :content {:tag :a :content 1 etc

11:21 maybe turn the nested vector into a nested dict ? would that make it easier?

11:22 sorry, I mean map, I come from the Python-world :)

11:25 tcsavage: l3dx: liberator is awesome. We've been using it at work for a few months now and I can't imagine writing restful services any other way

11:48 l3dx: tcsavage: seems like there is some handling of it (201 location) https://github.com/clojure-liberator/liberator/blob/master/src/liberator/core.clj#L166

11:48 I'm unable to figure out how to do it without hard coding the :location of the resource

11:48 so I'll just stick with ring-response for now

11:48 :)

11:50 tcsavage: l3dx: oh interesting. I didn't know that

11:50 it looks like it will look in the context first though

11:55 l3dx: oh, so I could probably just do (assoc ctx :location "http://whatever") in :post! then

11:56 well, at least it is working :)

11:59 tcsavage: or just return {:location "http://whatever"} from :post! (it'll automatically merge it into ctx)

12:01 l3dx: ah

12:20 vdmit11: Hi folks, is there a way to get a function with two arities, one is [foo bar baz] and another is [& {:keys [foo bar baz]}]?

12:21 opqdonut: vdmit11: not easily, but you can always just define it with [& args] and parse args "manually"

12:23 vdmit11: Yea, I just thought that perhaps I don't need to do that manually

12:23 jeremyheiler: ,(fn state".

12:23 clojurebot: #<RuntimeException java.lang.RuntimeException: EOF while reading string>

12:23 jeremyheiler: ,(fn ([a b c] :three) ([& args] :many))

12:23 clojurebot: #<CompilerException java.lang.RuntimeException: Can't have fixed arity function with more params than variadic function, compiling:(NO_SOURCE_PATH:0:0)>

12:25 opqdonut: vdmit11: frankly, I'd just give the two arities different names

12:25 vdmit11: myfunction and myfunction-kw perhaps

12:38 gfredericks: vdmit11: those two definitions are just barely not ambiguous ;-)

13:39 ticking: the "hello-cljsc" tutorial good overview on how to call the clojurescript compiler from clojure, however I was wondering if there is any support for referring other namespaces (or is this handled by each tool individually?)

13:39 *provides

14:12 l3dx: tcsavage: (or anyone else) am I supposed to update :new? from within put! ? seems like the function of :new? is evaluated after put!

14:15 tcsavage: put! is where you perform the action of creating or updating. You can store a value in the context and retrive it in new? to choose the return value

14:17 so for example, put! could return {:created-records true/false} and your :new? could be the function (fn [ctx] (:created-records ctx))

14:17 (I hope i'm answering your question correctly)

14:18 l3dx: yes you do! :)

14:18 thank you

14:19 I didn't think of that. I tried checking if the element was part of a collection (just playing around) but it always was after the put! function completed

14:30 dnolen_: ticking: what are you asking?

14:31 ticking: what is the best way to compile entire clojurescript expressions, including the loading of other libraries/namespaces, from within clojure?

14:34 dnolen_: It seems that everything is pretty straight forward except for refer, require, require-macros and use.

14:34 dnolen_: ticking: oh, you have cljs.analyzer/analyze-file and cljs.compiler/compile-file

14:35 ticking: not many people go this route so not sure how well using the CLJS compilation pipeline works when doing it this way

14:39 ticking: dnolen_: yeah I'll see how far I get :) thanks, I thought it would be nice to have clojurescript preview support in gorilla repl so that one can just write (cljs '(some cljs code)) to get a prototype inlined

14:40 tmarble: dnolen_: I found a necessary change to the basic tutorial as a result of the React upgrade

14:40 https://github.com/facebook/react/issues/1920

14:41 old - :onKeyPress #(when (== (.-keyCode %) 13) (commit-change text owner))

14:41 new - :onKeyDown #(when (= (.-key %) "Enter") (commit-change text owner))

14:41 dnolen_: tmarble: great, please update

14:42 tmarble: ok, will do

14:42 in trying to understand the react event (passed in as an arg) I tried (naively) to do this

14:42 in the above method

14:42 (println (.stringify js/JSON %))

14:42 but that didn't work (not sure why)

14:43 dnolen_: tmarble: if the JS object has cycles

14:44 tmarble: d'oh!

14:53 bryanmaass: Does anyone have a bunch of experience with enlive?

15:03 ticking: dnolen_: Does the compiler delegate dependency management entirely to the tools calling it?

15:07 dnolen_: ticking: dependency stuff happens in cljs.closure

15:07 ticking: and yes it's hand rolled and deal with a lot of cases

15:09 arohner: while we're on the subject of cljs compilation, is there a cider-like workflow for cljs? I really like that C-c C-k puts exceptions in my face when compiling clj code

15:09 where 'cljsbuild auto dev' means I have to switch over to the tab to see if anything happened

15:13 LauJensen: Hey - I've just tried removing my old packages, installing cider in emacs and lein and everything works great, except for one thing. When I open a .clj file, Clojure-Mode activates automatically and then I manually have to run M-x cider-mode. Any idea what gives?

15:13 My auto-mode-alist has this entry ("//.clj$" . cider-mode)

15:15 expez: LauJensen: automode-alist is used to activate major modes

15:15 cider is a minor-mode

15:15 dnolen_: arohner: I'm not aware of something like that though it's really just a matter of someone spending some time on it

15:15 arohner: if there's anything missing in CLJS to make it work - will happily take patches

15:16 LauJensen: expez: Ah okay. How how to attach a minor mode?

15:16 First 'how', should have been a 'So'

15:17 expez: LauJensen: (add-hook 'clojure-mode-hook #'cider-mode) should do it

15:19 alternatively (add-hook 'clojure-mode-hook #'my-clojure-mode-hook) and put (cider-mode 1) when you create the function my-clojure-mode-hook in which you do everything relevant to clojure-mode (turn on cider-mode, turn on company-mode, turn on paredit etc etc)

15:19 there's a #clojure-emacs channel where you can ask more questions about clojure development in emacs

15:24 michaelr`: hello

15:31 vdmit11: Is there a reader macro that evaluates a form at the read time. Common Lisp has the "#." and I can do something like "#.(+ 1 2)" which is evaluated to "3" by the reader. Is there something like this in Clojure?

15:32 bbloom_: ,(quote #=(+ 2 2))

15:32 clojurebot: #<RuntimeException java.lang.RuntimeException: EvalReader not allowed when *read-eval* is false.>

15:32 bbloom_: ,(set! *read-eval* true)

15:32 clojurebot: true

15:32 bbloom_: ,(quote #=(+ 2 2))

15:32 clojurebot: #<RuntimeException java.lang.RuntimeException: EvalReader not allowed when *read-eval* is false.>

15:32 bbloom_: ah, oh well

15:32 anyway, try that locally

15:32 usual security caveats apply

15:36 vdmit11: Yea, thanks, but it seems it doesn't solve my problem, because I forgot that it involves local lexical bindings and the reader could not understand them.

15:36 LauJensen: expez: That did the trick, thanks a bunch

15:37 bbloom_: vdmit11: rewind: what are you trying to do?

15:39 vdmit11: Let me define a problem. I use "case", but I would like to use numbers as clauses. I don't want to hardcode them, so I use "let" to bind some locals to numbers, but I can't use them as case's clauses, so I thought perhaps I can evaluate them before macro expansion stage.

15:41 bbloom_: vdmit11: unless you've measured & know you have a performance issue, just use condp =

15:41 vdmit11: well, I have the performance issue and I measured it :)

15:42 condp seems to be slow, even slower than cond with a bunch of comparisons

15:43 but case with hardcoded numbers is much faster

15:43 bbloom_: vdmit11: you don't want to hard code them b/c they vary at runtime, or because you want them to have symbolic names?

15:44 vdmit11: They don't vary, these numbers are enumerations used in a binary protocol. I just would like to give them names to make code readable.

15:44 bbloom_: so then why doesn't #=var-name solve your problem?

15:46 or better yet, just write a simple macro for this

15:46 where you just var-get the enumeration values by name

15:47 anyway, some macro for your needs can just produce the case expression you want

15:47 shouldn't be a problem

15:48 vdmit11: (def one 1) #=one -> ClassNotFoundException one

15:48 why?

15:48 clojurebot: why is the ram gone is <reply>I blame UTF-16. http://www.tumblr.com/tagged/but-why-is-the-ram-gone

15:48 bbloom_: vdmit11: because of the fact that #= isn't a documented feature, it's a broken hack for a particular use case rich/stu had however long ago

15:48 you need to do #(identity one)

15:48 i mean: #=(identity one)

15:49 but in this case, a regular macro will solve your problem

15:49 vdmit11: Yea, I'd like the macro too, thanks

15:51 dbushenko: hi all!

15:51 vdmit11: (defmacro four [] 4) (case 4 (four) (print "four")) -> IllegalArgumentException No matching clause: 4

15:51 I guess I miss something

15:51 dbushenko: lets say I'm running 'lein test' -- I need to select different db connection URL. How would I learn that I'm in testing mode?

15:52 bbloom_: vdmit11: case does not macro expand it's arguments

15:52 vdmit11: or evaluate them in any way for that matter

15:52 vdmit11: i meant your own macro that returns a case expression

15:52 vdmit11: oh

15:52 ok

15:52 thanks

15:53 bbloom_: (defmacro var-case [expr & clauses] `(case ~expr ...))

15:53 where in the ... you look up the vars

15:57 vdmit11: btw, (def one 1) (case 1 #=(identity one) "foo") -> No matching clause: 1

15:58 bbloom_: vdmit11: *shrug* not sure about that

15:58 but anyway, just do the var-case or whatever

15:59 Fare: is there an implementation of delimited continuations for clojure?

15:59 vdmit11: yea, I'll do the macro, but I just checked another approach for test

15:59 bbloom_: Fare: not any one that has dynamic extent

16:00 * Fare looks at https://github.com/swannodette/delimc

16:00 Fare: that might or might not be enough to implement python generators.

16:01 bbloom_: Fare: generators are shallow, so lexical extent shoudl be good enough

16:01 Fare: yes

16:02 bbloom_: Fare: core.async's internals are the most robust finite state machine transform available

16:02 Fare: rich mentioned some interest in incorporating that stuff for generators potentially in to the mainline compiler

16:02 Bronsa: I toyed with delimc a while ago, it's broken with records IIRC

16:03 Fare: broken with records? How do records interact with continuations??

16:03 lazybot: Fare: What are you, crazy? Of course not!

16:04 Bronsa: Fare: the cps rewriter wasn't handling them correctly

16:04 bbloom_: Fare: evaluation of record literals

16:04 Fare: I don't imagine what's magic about them that requires special treatment.

16:05 (are there record literals? I thought it was (->my-record-type arg1 arg2 arg3))

16:07 bbloom_: ,(defrecord Point [x y])

16:07 clojurebot: sandbox.Point

16:07 bbloom_: ,(Point. 5 10)

16:07 clojurebot: #sandbox.Point{:x 5, :y 10}

16:07 bbloom_: ,(->Point 5 10)

16:07 clojurebot: #sandbox.Point{:x 5, :y 10}

16:07 bbloom_: ,#sandbox.Point{:x 5, :y 10}

16:07 clojurebot: #<RuntimeException java.lang.RuntimeException: Record construction syntax can only be used when *read-eval* == true>

16:08 Bronsa: uhm nevermind, it wasn't records that were breaking delimc, it was using a map destructuring in a let

16:09 Fare: oh, makes more sense

16:09 bbloom_: user=> #user.Point{:x 5, :y (+ 5 10)}

16:09 #user.Point{:x 5 :y (+ 5 10)}

16:09 note how the record does not evaluate it's data

16:09 Bronsa: I remember a "create" call was being inserted somewhere in the transformed code though I have no idea where that would come from

16:09 bbloom_: compare to maps, which would return 5 and 15

16:10 Fare: bbloom_, sounds evil and non-orthogonal to me

16:10 ,`#user.Point{:x 5, :y ~(+ 5 10)}

16:10 clojurebot: #<RuntimeException java.lang.RuntimeException: Record construction syntax can only be used when *read-eval* == true>

16:11 Fare: ,(set! *read-eval* true)

16:11 clojurebot: true

16:11 Fare: ,`#user.Point{:x 5, :y ~(+ 5 10)}

16:11 clojurebot: #<RuntimeException java.lang.RuntimeException: Record construction syntax can only be used when *read-eval* == true>

16:12 Fare: having implemented (and painfully debugged) a ` for CL, I always hated how it did or didn't interact with vector or structure syntax.

16:12 bbloom_: Fare: read-eval is a security issue, so clojurebot blocks it, even tho i'm pretty sure you can turn it on w/ some hackery & it's not that big a security issue b/c of sandboxing etc

16:12 also the 'user namespace is from my local repl

16:12 it's the 'sandbox namespace here in irc

16:13 i've gone back and forth on record evaluation behavior

16:13 on one hand, we've already got the factory functions for applicative-order evaluation

16:13 Fare: and at my repl, it expands to: #user.Point{:x 5, :y (clojure.core/unquote (+ 5 10))}

16:13 yuck

16:13 bbloom_: but on the other hand, so does maps have hash-map etc

16:18 * Fare should probably have stored his analysis results in meta data rather than in an additional field.

16:22 arohner: someone needs to get on ClojureSwift, so I can go back to working in a good language

16:23 Fare: arohner, you're forced to use Swift?

16:23 ben_vulpes: is there any implicit retraction for maps in datomic, similar to the d/transact [{...}] ?

16:23 arohner: Fare: forced to osx native, yes. and Swift >> ObjC

16:24 Fare: writing an osx native app that talks to a Clojure server, so it's not all bad :-)

16:24 Fare: I suppose Swift is also for iOS

16:24 michaelr525: hey

16:24 Fare: how does conditional compilation happen to distinguish clj from cljs, clswift ?

16:25 ben_vulpes: i guess dbfn/retractentity...

16:26 arohner: Fare: there are a handful of options, none 'blessed' yet

16:26 https://github.com/lynaghk/cljx

16:26 there's another, I don't remember its name

16:26 but it's quite amazing how much Swift the lang has to anticipate which features you'll want

16:27 so many special cases compared to lisps

16:27 dnolen_: arohner: cljsbuild has :crossovers built in, though been deprecated by cemerick

16:27 Bronsa: Fare: bbloom_ I feel like `#user.record[~x] returning #user.record[(unquote x)] is probably a bug

16:27 arohner: dnolen_: there's another I'm trying to remember, it assumed you'll write 'mostly' clj, with cljs as the less common case

16:28 bbloom_: Bronsa: no, it's not

16:28 dnolen_: arohner: steve miner also had something based on reader literals

16:29 * Fare is a bit scared that sometimes he has to lein clean and restart cider, or his classes are somehow redefined and his multimethods fail

16:29 bbloom_: Bronsa: http://clojure.org/datatypes

16:29 Bronsa: see the defrecord reader support

16:29 Bronsa: bbloom_: I understand why it happens but I feel uneasy about #foo.bar[~x] being equal to `#foo.bar[~x]

16:29 bbloom_: it's documented to leave elements unevaluated

16:29 Fare: bbloom_, a bug in the spec, perhaps?

16:30 michaelr525: dnolen_: om-sync, does it support sending DELETE requests to /collection/id somehow? I've experimented with it a bit and it seems to send the requests just to /collection (the url parameter)..

16:30 dnolen_: michaelr525: om-sync is really still at proof of concept phase, and I'm not actively working on, would take PRs of course

16:30 Bronsa: bbloom_: eh, I guess you're right, there's really no way to make that "work"

16:31 michaelr525: dnolen_: ok, thought so but wasn't sure maybe I'm missing something :)

16:36 vdmit11: Hey folks, sorry if I ask too much stupid questions, but is there a way to use a function before defining it? I'd like when I can read the code from top to bottom and I would like to organize it in this way. In languages like C I can make a bunch of declarations first, then define a top-level function like main() and then define other functions used in main() and so on. Can I do something similar in clojure?

16:37 arohner: ,(doc declare)

16:37 clojurebot: "([& names]); defs the supplied var names with no bindings, useful for making forward declarations."

16:37 arohner: vdmit11: that only says that you will define something later, you can't e.g. specify arguments

16:38 vdmit11: for the most part, it's not very common though. mostly people just declare things in order

16:39 bbloom_: vdmit11: reading top-to-bottom is arguably better or worse than bottom-to-top, but both are better than totally random order

16:40 vdmit11: just get used to define-before-use, which i'd argue is preferable to top-to-bottom reading order :-)

16:41 vdmit11: bbloom_: give me an argument why it is better

16:42 perhaps I wold like to use it

16:42 bbloom_: vdmit11: 1) it's naturally enforced

16:42 2) it mirrors interactive use of the repl to define things

16:43 3) it makes mutual recursion explicit

16:43 arohner: 4) it's easier to read top-to-bottom, because you've seen the definition of everything before use

16:44 bbloom_: 5) in reality it's not reading top-to-bottom or bottom-to-top, it's reading top-to-bottom-to-top in both cases

16:45 it means your compiler operates on a stream, rather than a batch

16:45 lots of reasons

16:46 Bronsa: Fare: i'm trying to find some discussion of the evaluation behavior of records, but can't find any good history about it

16:46 arohner: vdmit11: understanding lisp compilation model helps a lot

16:47 vdmit11: the compiler essentially treats .clj files as if you typed it all into the repl

16:47 rather than a C compiler that works on files

16:47 vdmit11: well, I don't want to organize the code in some way just because the compiler treats them like a stream or because of any other thinks that looks like a technical limitation

16:47 kristof: bbloom_: I think that's just an excuse for babysitting the compiler.

16:48 bbloom_: kristof: disagree

16:48 vdmit11: ok, thanks for the advice anyway

16:48 bbloom_: it means that i can reason about my file as being effectively inside a big (do ...)

16:48 Fare: CL has something horrible: vectors, notated #(foo bar), do NOT evaluate their arguments, yet unquote DOES work inside them. On the other hand, N-dimensional arrays support neither evaluation not unquote. And structures don't even have a standard readable syntax.

16:50 bbloom_: yup :-/

16:50 kristof: vdmit11: the semantics of namespaces & vars are that of mutable maps, which differs from something like racket, for which the compilation unit is a module

16:51 Bronsa: bbloom_: the only reason I can think of why the record literals don't evaluate their args is to avoid complicating the compiler. but I really hope that wasn't the only reason

16:51 bbloom_: Bronsa: why would it complicate the compiler?

16:52 Bronsa: bbloom_: to allow for args evaluation the compiler would need a node for records rather than using ConstExpr as it is now

16:52 kristof: bbloom_: Lisp style has almost always been to define the more abstract functions before the simpler ones. Scheme style is like this, CL style is like this. The JVM simply doesn't allow forward references like that. Wasn't it Michael Fogus who used the same phrase I did when talking about declare?

16:52 Fare: bbloom_, I once designed (but did not implement, for compatibility reasons) a "Meta-Unquote" protocol so that unquote can be generalized to extensible syntax

16:54 bbloom_: Fare: that's interesting. in designs i'm working on, i'm exploring the idea of avoiding quoting all together and instead making evaluation explicit, rather than implicit with explicit quoting

16:54 Fare: John Shutt's thesis on "Kernel" is worth studying

16:54 kristof: bbloom_: Fexprs?

16:54 Oh, yeah

16:54 bbloom_: kristof: to a first approximation, yes

16:55 Bronsa: kristof: clojure could easily allow implicit forward references of Vars, in fact supporting that would require only a couple of lines to be changed in the compiler. it's a design choice that it doesn't

16:55 bbloom_: kristof: and it's also possible to swipe out types at runtime too, although much more difficult to do so (you need a custom class loader)

16:55 kristof: Something that had a lot of staying power with me was Shutt's sentiment that abstraction is the second derivative of semantics.

16:56 bbloom_: kristof: derivative with respect to what?

16:56 kristof: bbloom_: tokens, I suppose

16:57 bbloom_: not sure i follow

16:57 but i really do prefer the declare-before-use style of clojure

16:57 kristof: bbloom_: What he wrote went something like: expressiveness is how fast you can change what something means through the addition of tokens, and abstractiveness is how fast you can change expressiveness

16:57 bbloom_: although i do think that the batch-style definitions are also useful for a variety of things

16:58 kristof: bbloom_: It's obviously a strained comparison but I think it's slightly intuitive and it was fun to think about. And how fun something is is the most important metric of a concept.

16:58 bbloom_: kristof: i guess i need to re-read http://fexpr.blogspot.com/2013/12/abstractive-power.html

16:59 i do believe in the primacy of syntax, however

16:59 kristof: bbloom_: I think everyone needs to reread it, I'm not going to pretend like I understood more that 3/4 of it

17:08 Fare: bbloom_, one predecessor of Lisp had this too, explicit evaluation

17:08 bbloom_: Fare: prolog uses explicit evaluation

17:09 & Mathematica has LOTS of evaluation control options

17:09 lazybot: java.lang.RuntimeException: Unable to resolve symbol: Mathematica in this context

17:09 bbloom_: (too many maybe)

17:09 the new mathematica 10 has some cool "inactive expressions" thing too

17:09 http://reference.wolfram.com/language/guide/EvaluationControl.html

17:12 Fare: meanwhile I'm bumbling on a stupid python evaluator

17:12 that, and interfaces between CL and scripting

17:13 well, at least, the CL scripting thing is done — yay for #!/usr/bin/cl

17:13 csd_: Can someone please tell me what is wrong with this code?

17:13 Fare: csd_: the stars are not aligned

17:13 csd_: #(loop [len 0, acc %] (if (empty acc) len (recur (+ len 1) (rest acc))))

17:14 dbushenko: whats best for migrations in clojure?

17:15 ticking: csd_: you probably mean empty? acc

17:15 arohner: ,(doc empty)

17:15 clojurebot: "([coll]); Returns an empty collection of the same category as coll, or nil"

17:15 arohner: ,(doc empty?)

17:15 clojurebot: "([coll]); Returns true if coll has no items - same as (not (seq coll)). Please use the idiom (seq x) rather than (not (empty? x))"

17:15 arohner: ,(if [] "[] is truthy" "[] is falsey")

17:15 clojurebot: "[] is truthy"

17:15 Fare: I believe Newell's IPL required explicit evaluation of variables

17:16 csd_: ticking: ugg... i spent way too long trying to debug this

17:16 thanks

17:17 Fare: dbushenko, what kind of migration?

17:18 dbushenko: db migrations

17:18 ticking: dnolen_: it seems that the cljs compiler is very file oriented and heavily relying on side effects through emit, is this done on purpose or did it just evolve that way?

17:18 Fare: from what db to what db?

17:18 dbushenko: Fare, never mind

17:19 Fare: there is a nice tool in CL for migrating stuff to pgsql

17:20 pgloader

17:24 how with tools.analyzer do I specify which data or meta-data fields are to be preserved, and which are to be recomputer, or added / removed ?

17:30 stupid question: markdown, restructured text, etc. — which should I be using?

17:32 bbloom_: Fare: depends on what for

17:32 dnolen_: ticking: on purpose

17:32 bbloom_: Fare: for readmes on github and similar, markdown seems to have won

17:33 dnolen_: ticking: everyone that uses the complier is using cljsbuild and the file oriented stuff is for perf

17:33 bbloom_: dnolen_: i don't use cljsbuild :-P

17:33 ticking: dnolen_: very interesting thanks :)

17:34 technomancy: Fare: depends on whether it's for personal use or optimized for lowest friction from external contributors. (markdown wins on the latter despite being kinda crap)

17:34 dnolen_: bbloom_: heh ok I meant "most"

17:35 bbloom_: i haven't tried this new thing tho, what was it called? just saw something about it

17:36 dnolen_: ticking: and it's like to become more not less reliant on the file system for caching - caching analysis is the next thing I'm going to work on.

17:37 Fare: I want to tweak the cl-launch self-help into a format that I can extract a man page from

17:37 apparently, pandoc can do that for me.

17:38 technomancy: pandoc is supposed to be pretty fancy =)

17:39 bbloom_: dnolen_: ah, found it https://github.com/bhauman/lein-figwheel

17:39 ticking: dnolen_: too bad ;), being able to embed cljs into hiccup, never leaving a clojure repl, would be pretty cool

17:39 bbloom_: haven't tried that yet

17:39 dnolen_: ticking: you can do that - you just use the existing top level entry points, write your own thing

17:39 s/you just/you just can't

17:40 ticking: dnolen_: yeah I figured the best way to turn quoted clojure structures into js is probably writing a custom repl environment

17:40 stealing a bit of code from the browser env

17:40 dnolen_: ticking: all the existing gnarliness only happens on the file level entry points - if this isn't true let me know and we can work on fixing.

17:43 ticking: dnolen_: yeah, the most daunting bit is probably proper dependency loading and I

17:43 can look into the repl code for that, thanks :)

17:47 dnolen_: bbloom_: oh yeah did you see the recent VIM CLJS workflow post? seemed interesting

18:38 swgillespie: hi all, does anyone in here have experience with korma?

18:46 amalloy: ~anyone

18:46 clojurebot: anyone is anybody

18:46 amalloy: sigh

18:47 ~ask

18:47 clojurebot: The Ask To Ask protocol wastes more bandwidth than any version of the Ask protocol, so just ask your question.

18:47 Aim_Here: One of these days, what I'll really want to know is whether someone can help me with thing X

18:48 I won't care about getting X to work, just a social survey of some IRC channel

18:53 swgillespie: k, never mind

19:00 Fare: pandoc seems to output a pretty lousy man page.

19:00 :-(

19:10 tmarble: dnolen_: I adapted the Basic Om tutorial: https://github.com/tmarble/om-tut2

19:10 this removes IClonable and takes baby steps towards Intermediate (w/o a DB)

19:29 rpaulo: is there anything like lex/yacc in clojure?

19:33 _eric: is there something like using (map vector l1 l2) that continues going until the longest list is done?

19:40 jeremyheiler: rpaulo: you may be interested in instaparse

19:41 rpaulo: ah, looks better than parsley

19:41 dnolen_: _eric: you can concat all the seqs with a repeatedly sentinel, then take-while as long as every value of vector is not the sentinel

19:42 tmarble: cool

19:47 Trieste: Hi, can anybody tell me what's wrong with my version of nth for problem 21 on 4clojure? (fn [coll n] last (take (+ n 1) coll)))

19:48 hyPiRion: Trieste: You're lacking a set of parentheses.

19:48 Trieste: hyPiRion: where?

19:48 hyPiRion: → (fn [coll n] (last (take (+ n 1) coll)))

19:48 oh, perhaps you lost the one in front of last, because you have 3 ending ones.

19:49 Trieste: oh! thanks :)

19:49 still getting the hang of this

19:50 hyPiRion: Trieste: good luck with the next ones =)

19:52 mthvedt: rpaulo: there is also my favorite parser, https://github.com/mthvedt/clearley

20:40 rpaulo: interesting

21:05 dbyrne: anyone here have experience working with core.typed?

Logging service provided by n01se.net