#clojure logs

2014-08-02

03:38dazoneHello 안녕하세요
05:06blunte? 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)?
05:07arrdem&(map (partial get {:a 1 :b 2 :c 3 :d 4}) [:a :b :c])
05:07lazybot⇒ (1 2 3)
05:07bluntebut the operator function in this case is the key name
05:07blunteah let's see
05:09blunteso "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
05:09bluntearrdem: thanks, by the way :)
05:10bluntewith "get" as example, I hadn't seen that yet. All the info I see shows (:keyname my-record)
05:11arrdemhttp://clojure.org/data_structures#Data%20Structures-Keywords
05:13blunteah ha, my failure at reading then :). Thanks again
05:13arrdemnp
05:16TEttingerthere's also less-comprehensive docs (but organized well, and with examples) at clojuredocs
05:16TEttingerhttp://clojuredocs.org/quickref/Clojure%20Core
05:16TEttingerit's somewhat out-of-date, but the core language is all there. clojuredocs is stuck on version 1.3...
05:17arrdemhttp://jafingerhut.github.io/cheatsheet/grimoire/cheatsheet-tiptip-cdocs-summary.html
05:19bluntegreat, I'll take a look at both
05:20TEttingerarrdem, what version is that? I see no reduced
05:21arrdemTEttinger: latest. huh. looks like there isn't reduced at all...
05:27Glenjamindid the cheatsheet used to have reduced on it?
05:28Glenjaminoo, the "Examples" headings in grimoire don't check the :added metadata
05:29arrdemGlenjamin: hum?
05:30Glenjaminhttp://grimoire.arrdem.com/1.6.0/clojure.core/reduced has an empty heading for 1.4, but :added says 1.5
05:30arrdemGlenjamin: oh... you're saying it should 404 for 1.4.0?
05:31arrdemderp
05:31arrdemgotcha
05:31Glenjaminit does 404 (which is blank), but there also shouldn't be an "Examples from Clojure 1.4.0" section
05:32arrdemyeah... thinking about how to address that.
05:32Glenjaminjust about to update my PR, the contributing.md with the notes on how to syntax highlight seem to have gone awol?
05:32arrdemhttp://grimoire.arrdem.com/contributing
05:33Glenjamin ah, the readme links to http://grimoire.arrdem.com/contributing/ which 404s
05:34arrdemso 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.
05:34arrdemthere's no longer any markup required
05:34Glenjaminoh, neat
05:34arrdemyeah that was the big point of 0.3.0
05:34arrdemget rid of the markup requirement and make each example its own file
05:35Glenjamini think the "contribute an example!" links are missing /resources/
05:35arrdemfucking really...
05:35arrdemgah
05:36TEttingerthanks for contributing to the docs, Glenjamin, arrdem
05:36blunteI second that
05:40arrdemokay Glenjamin what was the other one...
05:40arrdemoh. right. :added
05:40arrdemalso real 404 fails...
05:45arrdemokay... the version range thing I'll fix some other time
05:48arrdemGlenjamin: hotfix'd
05:48Glenjamincheers
05:48arrdemugh that's embarasing
05:49arrdem<3 patches against develop
05:50arrdemanother reason for 0.3.0... lets me be more of a git-flow nazi
05:50arrdemGlenjamin: thanks for the pr!
08:19vdmit11Hi 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?
08:22vdmit11The 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.
08:22Bronsavdmit11: aget requires reflection only if used as a HOF
08:23Bronsa,(set! *warn-on-reflection* true)
08:23clojurebot#<IllegalStateException java.lang.IllegalStateException: Can't change/establish root binding of: *warn-on-reflection* with set>
08:23Bronsashush
08:23Bronsa,*warn-on-reflection*
08:23clojurebotfalse
08:23Bronsavdmit11: http://sprunge.us/gDPZ?clj
08:24Bronsayou just need to type-hint the return value of the aget since aget will return an Object
08:29vdmit11Bronsa: http://pastebin.com/AWuCZYqU - how about this?
08:29vdmit11why doesn't it work
08:30Bronsavdmit11: hint array with ^objects
08:31Bronsa(aget ^objects array 0)
08:32Bronsavdmit11: clojure only has local type inference you need to explicitely tag vars
08:33vdmit11Bronsa: thanks
08:33Bronsavdmit11: if you have lots of aget calls on that var you can tag directly the var rather than tag it at each invocation site
08:33Bronsa(def ^{:tag 'objects} array ..)
08:34Bronsavdmit11: np
09:00Fareso, I'm starting to have a collection of small-time utilities
09:00Fareis there a place to contribute them to?
09:05hyPiRionFare: https://github.com/weavejester/medley or https://github.com/flatland/useful
09:05Farethanks!
09:16Fareuseful has lots of good stuff
09:16Fareit's a bit chunky, though
09:17Fare(inc hyPiRion)
09:17lazybot⇒ 41
09:17hyPiRionFare: right, it's a huge chunk of functions – it's not necessarily the thing you want
09:18hyPiRionI just heard "collection of small-time utilities" and took what I had at the top of my head
09:19Fareok, so does map always return a list as per list? ?
09:20Fareapparently not.
09:20Farehow do I make it so?
09:21hyPiRionmap always return a (possibly chunked) lazy-seq
09:21Farewith (into () ...)
09:22hyPiRionFare: 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
09:22hyPiRionit might be that persistent vectors is fine for the job at hadn
09:22hyPiRion*hand
09:24Fareis it OK to have macros return lazy-seq's?
09:24Farewhen I analyze source code, how do I distinguish between list and vector?
09:24Fareor is that vector and anything-but-vector?
09:26hyPiRionFare: mmm, right, I understand your concern. Generally you'd use seq? for list-like things, vector? for vectors, map? for maps, set? for sets
09:26hyPiRionno problem with emitting lazy seqs from macros as far as I know
09:27Fareapparently, a vector is not a seq?
09:27Fareinteresting
09:28hyPiRionFare: A vector is sequential, but not a seq in and by it self
09:29hyPiRionI tend to think of seqs as things which wraps what it contains in parens
09:30visofhi
09:30visofis this conversion right? https://www.refheap.com/88832
09:31visofplease anybody help
09:31hyPiRionvisof: yes, that seems to look right
09:31visofhyPiRion: i got this error: java.lang.IllegalArgumentException: No matching field found: execute for class com.orientechnologies.orient.graph.gremlin.OCommandGremlin
09:32hyPiRionboo
09:33visofhyPiRion: check this http://www.massapi.com/class/com/orientechnologies/orient/graph/gremlin/OCommandGremlin.java.html check the first example
09:34hyPiRionvisof: ah
09:34visofhyPiRion: ?
09:36hyPiRioncould you try (. (.command db (OCommandGremlin. "g.V[0..10]")) (execute)) instead?
09:36hyPiRionI think (.. db (command (OCommandGremlin. "g.V[0..10]")) (execute)) should be the equivalent statement.
09:36hyPiRionan equivalent*
09:37visofhyPiRion: what is the difference?
09:41hyPiRionvisof: (.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
09:41hyPiRionthat being said, I've not done a lot of work with method calls, so I may be wrong
09:44visof_hyPiRion: are you there
09:44hyPiRionyes
09:44visof_hyPiRion: i have tested both with the same error
09:48visof_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
09:48visof_can anybody help in this?
09:49pyrtsavisof_, 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 [])`.
09:49hyPiRionvisof_: oh, you're trying to call a vararg method?
09:49hyPiRionpyrtsa: yeah, I just realised ;_;
09:50visof_pyrtsa: so i need to call it with (.execute (...) []) ?
09:50pyrtsaGoogled it. :)
09:50hyPiRionvisof_: (.. db (command (OCommandGremlin. "g.V[0..10]")) (execute (object-array [])) should work
09:50pyrtsaThat. ^
09:50visof_pyrtsa: what google results you get ?
09:51pyrtsavisof_: Well, just googled to find out what the method signature of execute() was. You should be aware of these issues when doing Java interop
09:52visof_pyrtsa: hyPiRion thanks guys
09:54visof_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:00mdo_hello
11:02l3dxanyone using liberator? I can't figure out how to set the Location header after doing a successful POST (201)
11:07tcsavagel3dx: (ring-response {:headers {"Location" "http://urlwhatever&quot;}}) should do the trick
11:07tcsavageit's a bit messy to use ring directly but it seems like the easiest way to do it
11:08vsj_Hello, I'm still new to Clojure and I've a question about nested vectors (output of instaparse)
11:08vsj_Here's the example:
11:09vsj_[[:t [:a 1] [:b [[:e 4] [:f 5]]] [:c 3]] [:t [:a 4] [:b [[:e 7] [:f 8]]] [:c 6]]]
11:09vsj_I'd like to extract the values related to :f anc :c, ie expected output: [5 3] [8 6]
11:09vsj_What is the best way to do this? I played around with zippers, walk, etc. but it seems to complex
11:10vsj_Thanks in advance
11:10tcsavageis there a reason why you're using nested vectors [:a [...]] rather than a map? {:a [...]}
11:11vsj_It's instaparse output
11:11l3dxtcsavage: thanks
11:12vsj_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:13l3dxI'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:14ambroseb_vsj_: try changing the output format https://github.com/Engelberg/instaparse#output-format
11:15tcsavagel3dx: there are a few things liberator doesn't handle too well, but it's pretty good as the basics
11:20l3dxtcsavage: yes it seems very promising
11:20vsj_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:21vsj_maybe turn the nested vector into a nested dict ? would that make it easier?
11:22vsj_sorry, I mean map, I come from the Python-world :)
11:25tcsavagel3dx: 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:48l3dxtcsavage: seems like there is some handling of it (201 location) https://github.com/clojure-liberator/liberator/blob/master/src/liberator/core.clj#L166
11:48l3dxI'm unable to figure out how to do it without hard coding the :location of the resource
11:48l3dxso I'll just stick with ring-response for now
11:48l3dx:)
11:50tcsavagel3dx: oh interesting. I didn't know that
11:50tcsavageit looks like it will look in the context first though
11:55l3dxoh, so I could probably just do (assoc ctx :location "http://whatever&quot;) in :post! then
11:56l3dxwell, at least it is working :)
11:59tcsavageor just return {:location "http://whatever&quot;} from :post! (it'll automatically merge it into ctx)
12:01l3dxah
12:20vdmit11Hi 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:21opqdonutvdmit11: not easily, but you can always just define it with [& args] and parse args "manually"
12:23vdmit11Yea, I just thought that perhaps I don't need to do that manually
12:23jeremyheiler,(fn state".
12:23clojurebot#<RuntimeException java.lang.RuntimeException: EOF while reading string>
12:23jeremyheiler,(fn ([a b c] :three) ([& args] :many))
12:23clojurebot#<CompilerException java.lang.RuntimeException: Can't have fixed arity function with more params than variadic function, compiling:(NO_SOURCE_PATH:0:0)>
12:25opqdonutvdmit11: frankly, I'd just give the two arities different names
12:25opqdonutvdmit11: myfunction and myfunction-kw perhaps
12:38gfredericksvdmit11: those two definitions are just barely not ambiguous ;-)
13:39tickingthe "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:39ticking*provides
14:12l3dxtcsavage: (or anyone else) am I supposed to update :new? from within put! ? seems like the function of :new? is evaluated after put!
14:15tcsavageput! 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:17tcsavageso for example, put! could return {:created-records true/false} and your :new? could be the function (fn [ctx] (:created-records ctx))
14:17tcsavage(I hope i'm answering your question correctly)
14:18l3dxyes you do! :)
14:18l3dxthank you
14:19l3dxI 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:30dnolen_ticking: what are you asking?
14:31tickingwhat is the best way to compile entire clojurescript expressions, including the loading of other libraries/namespaces, from within clojure?
14:34tickingdnolen_: It seems that everything is pretty straight forward except for refer, require, require-macros and use.
14:34dnolen_ticking: oh, you have cljs.analyzer/analyze-file and cljs.compiler/compile-file
14:35dnolen_ticking: not many people go this route so not sure how well using the CLJS compilation pipeline works when doing it this way
14:39tickingdnolen_: 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:40tmarblednolen_: I found a necessary change to the basic tutorial as a result of the React upgrade
14:40tmarblehttps://github.com/facebook/react/issues/1920
14:41tmarbleold - :onKeyPress #(when (== (.-keyCode %) 13) (commit-change text owner))
14:41tmarblenew - :onKeyDown #(when (= (.-key %) "Enter") (commit-change text owner))
14:41dnolen_tmarble: great, please update
14:42tmarbleok, will do
14:42tmarblein trying to understand the react event (passed in as an arg) I tried (naively) to do this
14:42tmarblein the above method
14:42tmarble(println (.stringify js/JSON %))
14:42tmarblebut that didn't work (not sure why)
14:43dnolen_tmarble: if the JS object has cycles
14:44tmarbled'oh!
14:53bryanmaassDoes anyone have a bunch of experience with enlive?
15:03tickingdnolen_: Does the compiler delegate dependency management entirely to the tools calling it?
15:07dnolen_ticking: dependency stuff happens in cljs.closure
15:07dnolen_ticking: and yes it's hand rolled and deal with a lot of cases
15:09arohnerwhile 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:09arohnerwhere 'cljsbuild auto dev' means I have to switch over to the tab to see if anything happened
15:13LauJensenHey - 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:13LauJensenMy auto-mode-alist has this entry ("//.clj$" . cider-mode)
15:15expezLauJensen: automode-alist is used to activate major modes
15:15expezcider is a minor-mode
15:15dnolen_arohner: I'm not aware of something like that though it's really just a matter of someone spending some time on it
15:15dnolen_arohner: if there's anything missing in CLJS to make it work - will happily take patches
15:16LauJensenexpez: Ah okay. How how to attach a minor mode?
15:16LauJensenFirst 'how', should have been a 'So'
15:17expezLauJensen: (add-hook 'clojure-mode-hook #'cider-mode) should do it
15:19expezalternatively (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:19expezthere's a #clojure-emacs channel where you can ask more questions about clojure development in emacs
15:24michaelr`hello
15:31vdmit11Is 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:32bbloom_,(quote #=(+ 2 2))
15:32clojurebot#<RuntimeException java.lang.RuntimeException: EvalReader not allowed when *read-eval* is false.>
15:32bbloom_,(set! *read-eval* true)
15:32clojurebottrue
15:32bbloom_,(quote #=(+ 2 2))
15:32clojurebot#<RuntimeException java.lang.RuntimeException: EvalReader not allowed when *read-eval* is false.>
15:32bbloom_ah, oh well
15:32bbloom_anyway, try that locally
15:32bbloom_usual security caveats apply
15:36vdmit11Yea, 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:36LauJensenexpez: That did the trick, thanks a bunch
15:37bbloom_vdmit11: rewind: what are you trying to do?
15:39vdmit11Let 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:41bbloom_vdmit11: unless you've measured & know you have a performance issue, just use condp =
15:41vdmit11well, I have the performance issue and I measured it :)
15:42vdmit11condp seems to be slow, even slower than cond with a bunch of comparisons
15:43vdmit11but case with hardcoded numbers is much faster
15:43bbloom_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:44vdmit11They 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:44bbloom_so then why doesn't #=var-name solve your problem?
15:46bbloom_or better yet, just write a simple macro for this
15:46bbloom_where you just var-get the enumeration values by name
15:47bbloom_anyway, some macro for your needs can just produce the case expression you want
15:47bbloom_shouldn't be a problem
15:48vdmit11(def one 1) #=one -> ClassNotFoundException one
15:48vdmit11why?
15:48clojurebotwhy is the ram gone is <reply>I blame UTF-16. http://www.tumblr.com/tagged/but-why-is-the-ram-gone
15:48bbloom_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:48bbloom_you need to do #(identity one)
15:48bbloom_i mean: #=(identity one)
15:49bbloom_but in this case, a regular macro will solve your problem
15:49vdmit11Yea, I'd like the macro too, thanks
15:51dbushenkohi all!
15:51vdmit11(defmacro four [] 4) (case 4 (four) (print "four")) -> IllegalArgumentException No matching clause: 4
15:51vdmit11I guess I miss something
15:51dbushenkolets 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:52bbloom_vdmit11: case does not macro expand it's arguments
15:52bbloom_vdmit11: or evaluate them in any way for that matter
15:52bbloom_vdmit11: i meant your own macro that returns a case expression
15:52vdmit11oh
15:52vdmit11ok
15:52vdmit11thanks
15:53bbloom_(defmacro var-case [expr & clauses] `(case ~expr ...))
15:53bbloom_where in the ... you look up the vars
15:57vdmit11btw, (def one 1) (case 1 #=(identity one) "foo") -> No matching clause: 1
15:58bbloom_vdmit11: *shrug* not sure about that
15:58bbloom_but anyway, just do the var-case or whatever
15:59Fareis there an implementation of delimited continuations for clojure?
15:59vdmit11yea, I'll do the macro, but I just checked another approach for test
15:59bbloom_Fare: not any one that has dynamic extent
16:00Farethat might or might not be enough to implement python generators.
16:01bbloom_Fare: generators are shallow, so lexical extent shoudl be good enough
16:01Fareyes
16:02bbloom_Fare: core.async's internals are the most robust finite state machine transform available
16:02bbloom_Fare: rich mentioned some interest in incorporating that stuff for generators potentially in to the mainline compiler
16:02BronsaI toyed with delimc a while ago, it's broken with records IIRC
16:03Farebroken with records? How do records interact with continuations??
16:03lazybotFare: What are you, crazy? Of course not!
16:04BronsaFare: the cps rewriter wasn't handling them correctly
16:04bbloom_Fare: evaluation of record literals
16:04FareI don't imagine what's magic about them that requires special treatment.
16:05Fare(are there record literals? I thought it was (->my-record-type arg1 arg2 arg3))
16:07bbloom_,(defrecord Point [x y])
16:07clojurebotsandbox.Point
16:07bbloom_,(Point. 5 10)
16:07clojurebot#sandbox.Point{:x 5, :y 10}
16:07bbloom_,(->Point 5 10)
16:07clojurebot#sandbox.Point{:x 5, :y 10}
16:07bbloom_,#sandbox.Point{:x 5, :y 10}
16:07clojurebot#<RuntimeException java.lang.RuntimeException: Record construction syntax can only be used when *read-eval* == true>
16:08Bronsauhm nevermind, it wasn't records that were breaking delimc, it was using a map destructuring in a let
16:09Fareoh, makes more sense
16:09bbloom_user=> #user.Point{:x 5, :y (+ 5 10)}
16:09bbloom_#user.Point{:x 5 :y (+ 5 10)}
16:09bbloom_note how the record does not evaluate it's data
16:09BronsaI remember a "create" call was being inserted somewhere in the transformed code though I have no idea where that would come from
16:09bbloom_compare to maps, which would return 5 and 15
16:10Farebbloom_, sounds evil and non-orthogonal to me
16:10Fare,`#user.Point{:x 5, :y ~(+ 5 10)}
16:10clojurebot#<RuntimeException java.lang.RuntimeException: Record construction syntax can only be used when *read-eval* == true>
16:11Fare,(set! *read-eval* true)
16:11clojurebottrue
16:11Fare,`#user.Point{:x 5, :y ~(+ 5 10)}
16:11clojurebot#<RuntimeException java.lang.RuntimeException: Record construction syntax can only be used when *read-eval* == true>
16:12Farehaving implemented (and painfully debugged) a ` for CL, I always hated how it did or didn't interact with vector or structure syntax.
16:12bbloom_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:12bbloom_also the 'user namespace is from my local repl
16:12bbloom_it's the 'sandbox namespace here in irc
16:13bbloom_i've gone back and forth on record evaluation behavior
16:13bbloom_on one hand, we've already got the factory functions for applicative-order evaluation
16:13Fareand at my repl, it expands to: #user.Point{:x 5, :y (clojure.core/unquote (+ 5 10))}
16:13Fareyuck
16:13bbloom_but on the other hand, so does maps have hash-map etc
16:22arohnersomeone needs to get on ClojureSwift, so I can go back to working in a good language
16:23Farearohner, you're forced to use Swift?
16:23ben_vulpesis there any implicit retraction for maps in datomic, similar to the d/transact [{...}] ?
16:23arohnerFare: forced to osx native, yes. and Swift >> ObjC
16:24arohnerFare: writing an osx native app that talks to a Clojure server, so it's not all bad :-)
16:24FareI suppose Swift is also for iOS
16:24michaelr525hey
16:24Farehow does conditional compilation happen to distinguish clj from cljs, clswift ?
16:25ben_vulpesi guess dbfn/retractentity...
16:26arohnerFare: there are a handful of options, none 'blessed' yet
16:26arohnerhttps://github.com/lynaghk/cljx
16:26arohnerthere's another, I don't remember its name
16:26arohnerbut it's quite amazing how much Swift the lang has to anticipate which features you'll want
16:27arohnerso many special cases compared to lisps
16:27dnolen_arohner: cljsbuild has :crossovers built in, though been deprecated by cemerick
16:27BronsaFare: bbloom_ I feel like `#user.record[~x] returning #user.record[(unquote x)] is probably a bug
16:27arohnerdnolen_: there's another I'm trying to remember, it assumed you'll write 'mostly' clj, with cljs as the less common case
16:28bbloom_Bronsa: no, it's not
16:28dnolen_arohner: steve miner also had something based on reader literals
16:29bbloom_Bronsa: http://clojure.org/datatypes
16:29bbloom_Bronsa: see the defrecord reader support
16:29Bronsabbloom_: I understand why it happens but I feel uneasy about #foo.bar[~x] being equal to `#foo.bar[~x]
16:29bbloom_it's documented to leave elements unevaluated
16:29Farebbloom_, a bug in the spec, perhaps?
16:30michaelr525dnolen_: 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:30dnolen_michaelr525: om-sync is really still at proof of concept phase, and I'm not actively working on, would take PRs of course
16:30Bronsabbloom_: eh, I guess you're right, there's really no way to make that "work"
16:31michaelr525dnolen_: ok, thought so but wasn't sure maybe I'm missing something :)
16:36vdmit11Hey 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:37arohner,(doc declare)
16:37clojurebot"([& names]); defs the supplied var names with no bindings, useful for making forward declarations."
16:37arohnervdmit11: that only says that you will define something later, you can't e.g. specify arguments
16:38arohnervdmit11: for the most part, it's not very common though. mostly people just declare things in order
16:39bbloom_vdmit11: reading top-to-bottom is arguably better or worse than bottom-to-top, but both are better than totally random order
16:40bbloom_vdmit11: just get used to define-before-use, which i'd argue is preferable to top-to-bottom reading order :-)
16:41vdmit11bbloom_: give me an argument why it is better
16:42vdmit11perhaps I wold like to use it
16:42bbloom_vdmit11: 1) it's naturally enforced
16:42bbloom_2) it mirrors interactive use of the repl to define things
16:43bbloom_3) it makes mutual recursion explicit
16:43arohner4) it's easier to read top-to-bottom, because you've seen the definition of everything before use
16:44bbloom_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:45bbloom_it means your compiler operates on a stream, rather than a batch
16:45bbloom_lots of reasons
16:46bbloom_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:46arohnervdmit11: understanding lisp compilation model helps a lot
16:47arohnervdmit11: the compiler essentially treats .clj files as if you typed it all into the repl
16:47arohnerrather than a C compiler that works on files
16:47vdmit11well, 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:47kristofbbloom_: I think that's just an excuse for babysitting the compiler.
16:48bbloom_kristof: disagree
16:48vdmit11ok, thanks for the advice anyway
16:48bbloom_it means that i can reason about my file as being effectively inside a big (do ...)
16:48FareCL 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:50bbloom_yup :-/
16:50bbloom_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:51Bronsabbloom_: 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:51bbloom_Bronsa: why would it complicate the compiler?
16:52Bronsabbloom_: to allow for args evaluation the compiler would need a node for records rather than using ConstExpr as it is now
16:52kristofbbloom_: 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:52Farebbloom_, I once designed (but did not implement, for compatibility reasons) a "Meta-Unquote" protocol so that unquote can be generalized to extensible syntax
16:54bbloom_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:54bbloom_Fare: John Shutt's thesis on "Kernel" is worth studying
16:54kristofbbloom_: Fexprs?
16:54kristofOh, yeah
16:54bbloom_kristof: to a first approximation, yes
16:55Bronsakristof: 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:55bbloom_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:55kristofSomething that had a lot of staying power with me was Shutt's sentiment that abstraction is the second derivative of semantics.
16:56bbloom_kristof: derivative with respect to what?
16:56kristofbbloom_: tokens, I suppose
16:57bbloom_not sure i follow
16:57bbloom_but i really do prefer the declare-before-use style of clojure
16:57kristofbbloom_: 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:57bbloom_although i do think that the batch-style definitions are also useful for a variety of things
16:58kristofbbloom_: 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:58bbloom_kristof: i guess i need to re-read http://fexpr.blogspot.com/2013/12/abstractive-power.html
16:59bbloom_i do believe in the primacy of syntax, however
16:59kristofbbloom_: I think everyone needs to reread it, I'm not going to pretend like I understood more that 3/4 of it
17:08Farebbloom_, one predecessor of Lisp had this too, explicit evaluation
17:08bbloom_Fare: prolog uses explicit evaluation
17:09bbloom_& Mathematica has LOTS of evaluation control options
17:09lazybotjava.lang.RuntimeException: Unable to resolve symbol: Mathematica in this context
17:09bbloom_(too many maybe)
17:09bbloom_the new mathematica 10 has some cool "inactive expressions" thing too
17:09bbloom_http://reference.wolfram.com/language/guide/EvaluationControl.html
17:12Fare meanwhile I'm bumbling on a stupid python evaluator
17:12Farethat, and interfaces between CL and scripting
17:13Farewell, at least, the CL scripting thing is done — yay for #!/usr/bin/cl
17:13csd_Can someone please tell me what is wrong with this code?
17:13Farecsd_: the stars are not aligned
17:13csd_#(loop [len 0, acc %] (if (empty acc) len (recur (+ len 1) (rest acc))))
17:14dbushenkowhats best for migrations in clojure?
17:15tickingcsd_: you probably mean empty? acc
17:15arohner,(doc empty)
17:15clojurebot"([coll]); Returns an empty collection of the same category as coll, or nil"
17:15arohner,(doc empty?)
17:15clojurebot"([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:15arohner,(if [] "[] is truthy" "[] is falsey")
17:15clojurebot"[] is truthy"
17:15FareI believe Newell's IPL required explicit evaluation of variables
17:16csd_ticking: ugg... i spent way too long trying to debug this
17:16csd_thanks
17:17Faredbushenko, what kind of migration?
17:18dbushenkodb migrations
17:18tickingdnolen_: 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:18Farefrom what db to what db?
17:18dbushenkoFare, never mind
17:19Farethere is a nice tool in CL for migrating stuff to pgsql
17:20Farepgloader
17:24Farehow 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:30Farestupid question: markdown, restructured text, etc. — which should I be using?
17:32bbloom_Fare: depends on what for
17:32dnolen_ticking: on purpose
17:32bbloom_Fare: for readmes on github and similar, markdown seems to have won
17:33dnolen_ticking: everyone that uses the complier is using cljsbuild and the file oriented stuff is for perf
17:33bbloom_dnolen_: i don't use cljsbuild :-P
17:33tickingdnolen_: very interesting thanks :)
17:34technomancyFare: 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:34dnolen_bbloom_: heh ok I meant "most"
17:35bbloom_i haven't tried this new thing tho, what was it called? just saw something about it
17:36dnolen_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:37FareI want to tweak the cl-launch self-help into a format that I can extract a man page from
17:37Fareapparently, pandoc can do that for me.
17:38technomancypandoc is supposed to be pretty fancy =)
17:39bbloom_dnolen_: ah, found it https://github.com/bhauman/lein-figwheel
17:39tickingdnolen_: too bad ;), being able to embed cljs into hiccup, never leaving a clojure repl, would be pretty cool
17:39bbloom_haven't tried that yet
17:39dnolen_ticking: you can do that - you just use the existing top level entry points, write your own thing
17:39dnolen_s/you just/you just can't
17:40tickingdnolen_: yeah I figured the best way to turn quoted clojure structures into js is probably writing a custom repl environment
17:40tickingstealing a bit of code from the browser env
17:40dnolen_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:43tickingdnolen_: yeah, the most daunting bit is probably proper dependency loading and I
17:43tickingcan look into the repl code for that, thanks :)
17:47dnolen_bbloom_: oh yeah did you see the recent VIM CLJS workflow post? seemed interesting
18:38swgillespiehi all, does anyone in here have experience with korma?
18:46amalloy~anyone
18:46clojurebotanyone is anybody
18:46amalloysigh
18:47amalloy~ask
18:47clojurebotThe Ask To Ask protocol wastes more bandwidth than any version of the Ask protocol, so just ask your question.
18:47Aim_HereOne of these days, what I'll really want to know is whether someone can help me with thing X
18:48Aim_HereI won't care about getting X to work, just a social survey of some IRC channel
18:53swgillespiek, never mind
19:00Farepandoc seems to output a pretty lousy man page.
19:00Fare:-(
19:10tmarblednolen_: I adapted the Basic Om tutorial: https://github.com/tmarble/om-tut2
19:10tmarblethis removes IClonable and takes baby steps towards Intermediate (w/o a DB)
19:29rpaulois there anything like lex/yacc in clojure?
19:33_ericis there something like using (map vector l1 l2) that continues going until the longest list is done?
19:40jeremyheilerrpaulo: you may be interested in instaparse
19:41rpauloah, looks better than parsley
19:41dnolen__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:42dnolen_tmarble: cool
19:47TriesteHi, 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:48hyPiRionTrieste: You're lacking a set of parentheses.
19:48TriestehyPiRion: where?
19:48hyPiRion→ (fn [coll n] (last (take (+ n 1) coll)))
19:48hyPiRionoh, perhaps you lost the one in front of last, because you have 3 ending ones.
19:49Triesteoh! thanks :)
19:49Triestestill getting the hang of this
19:50hyPiRionTrieste: good luck with the next ones =)
19:52mthvedtrpaulo: there is also my favorite parser, https://github.com/mthvedt/clearley
20:40rpaulointeresting
21:05dbyrneanyone here have experience working with core.typed?