This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2016-03-30
Channels
- # admin-announcements (10)
- # beginners (17)
- # boot (14)
- # braveandtrue (4)
- # cider (6)
- # cljsrn (38)
- # clojure (232)
- # clojure-austin (1)
- # clojure-belgium (2)
- # clojure-dev (20)
- # clojure-greece (20)
- # clojure-japan (3)
- # clojure-poland (39)
- # clojure-russia (76)
- # clojure-sanfrancisco (6)
- # clojure-uk (4)
- # clojurescript (90)
- # cursive (2)
- # data-science (10)
- # datomic (18)
- # garden (16)
- # hoplon (244)
- # immutant (3)
- # jobs (6)
- # jobs-discuss (2)
- # juxt (1)
- # off-topic (3)
- # om (50)
- # onyx (23)
- # re-frame (5)
- # reagent (36)
- # remote-jobs (11)
- # slack-help (6)
- # spacemacs (2)
- # untangled (46)
@josh.freckleton: I used https://github.com/ngrunwald/ring-middleware-format ! Here's a gist of how to do it: https://gist.github.com/fasiha/378e53152a9162da80c6a10ff1d4ade8
@josh.freckleton: I didn't use ring-transit for a very pedestrian reason: when I used it, it would try to parse some requests as transit as well, which was making compojure catch on fire, and I couldn't readily figure out how to make that middleware apply to some (not all) routes. I know, cargo-culting, but ring-middleware-format was smarter about only encoding the responses I wanted (inside a :body
slot, per the gist), so I went with that…
@fasiha: Thanks for the response. So, wouldn't compojure *not* apply ring-transit
for things that don't signify they're content-type is transit? Would that not be your solution?
@josh.freckleton: you may very well be right—I see that the cljs client code does specify Accept: application/transit+json, */*
in the request, and it's very possible I learned about that after I stopped using ring-transit and started using ring-middleware-format, and the former might have done the right thing if I'd had that request header.
@bronsa, I’m looking at the ast fields for http://clojure.github.io/tools.analyzer.jvm/spec/quickref.html.
@zcaudate: if you need :loops
, you'll have to schedule #'clojure.tools.analyzer.passes.jvm.annotate-loops/annotate-loops
along with the default passes
@bronsa: I’m not sure of the purpose of the :loops
tag. does the analyser predict how many times a loop might run?
@zcaudate: not how many, but which loops might cause an expression to recur. e.g. in (loop <a> [] (loop <b> [] (println "foo") (when some-cond (recur))) (when some-cond (recur)))
(println "foo")
might be re-evaluated because of loop <b>
recurring or loop <a>
recurring
@zcaudate: if you don't understand the purpose of :loops
chances are you don't need it it's currently only used/needed by a complex analysis pass that deals with locals clearing
@bronsa: yeah… I’m designing a mini workflow language that uses a micro-set of clojure
Is there a reason why (read-string "a/b/c")
is OK, while (clojure.tools.reader/read-string "a/b/c")
fails with Invalid token
?
the docs have precluded symbols like a/b/c for some time, and the behavior of how those unspecified symbols were read apparently changed at some point
@hiredman: seriously. I’m really peeved about that because I’ve been using :a/b/c
keywords for a while… even wrote a whole freaking library to deal with that http://docs.caudate.me/hara/hara-string.html#api---path
user=> (require '[clojure.walk :as walk])
nil
user=> ::walk/hello
:clojure.walk/hello
@zcaudate: ::foo/bar
style keywords are in by design and not going anywhere, :foo/bar/baz
have always been invalid by the spec and undefined behaviour
that code is already broken if it's using invalid clojure. It's just accidentaly working
pragmatically, :foo/bar/baz
is a bug waiting to happen. what does (namespace :foo/bar/baz)
return?
@dm3 @bronsa I wouldnt even agree that you are theoretically right. As soon as enough people adapted the broken code it falls under something like a common law that was accepted by both parties for a long enough time.
@sveri: I would agree with you, as long as the undefined behaviour we accept as defined doesn't cause impossible to fix semantics.
that's why for example, the patch that made symbols starting with numbers illegal was rolled back
it broke existing code, it didn't cause weird semantics so it was rolled back. not the case with :foo/bar/baz
@dm3: you could make the point that fixing any bug is a breaking change then -- people might be relying on that bug.
yep, I guess what matters is how obvious the incorrect behaviour is and how many people rely on it
if the doc explicitely says "you can use one /
inside a symbol", then if you're using more than one you're writing invalid clojure and you should expect it to maybe break
I really haven't even thought about multiple slashes (nor noticed the docs) in a symbol in ~3 years of using Clojure
well, that doesn't make much sense though. /
in clojure means namespace separator
. if I see FOO/BAR
, no matter what FOO
and BAR
are, I know that FOO
is the namespace, and BAR
is the name. if you want to express paths with keywords as in @zcaudate's lib, you should use a different separator in your keywords that doesn't have a special meaning in clojure, like .
(i.e. :foo/bar/baz
-> :foo.bar.baz
or :foo/bar.baz
)
and my point is that pragmatic point of views (especially when they go against the current doc) should only be considered if the semantics they imply are clear and unambiguous
@slotkenov: https://github.com/flyingmachine/streaming-proxy might work. also, maybe https://github.com/ztellman/aleph
or just nginx
@nonrecursive: thanks, the streaming-proxy seems easy to set up!
@nonrecursive: nice to see you around, just wanted to saythanks for clojure for the brave and true
@bronsa: written form of communication has a way of making things more serious than they seem
honestly… i knew it was coming since 1.6 when the edn reader started breaking my code
it’s probably more my fault for not communicating this earlier but oh well.. we all have to roll with the times
@zcaudate: yeah no worries, I was just using your lib as an example since you brought that up
having said that, you can imagine my disappointment because I had designed an entire query semantic based on the keyword :foo/bar/baz
feature (now bug)
you noticed I didn’t use (adi/select ds {:student/classes/teacher/name "Mr. Blair"}})
like it’s not a big deal… but I thought that there is a parallel between the path structure of the /
calls and the nesting of maps
and so there is an equivalence to {:student {:classes {:teacher {:name '(?fulltext "Blair")}
@zcaudate: sorry if that wasn't clear, but I don't actually have any control over when or what gets into clojure or not, I'm just a contributor so there are chances that the clojure/core team will take a different decision and actually decline that ticket (I would be really disappointed if that was the case though!). If that will happenI will obviously make a change to tools.reader
to allow them aswell,
don't think that'll ever be done. validating inputs to keyword
/`symbol` etc has been asked/discussed tons of times and repeatedly declined for performance reasons
(not that I agree with that decision, but it seems like Rich isn't going ot change his mind on that)
@zcaudate: there's a difference between what a symbol/keyword can be at runtime, and what a valid read-time symbol/keyword is
and also, it means I can setup a reader macro #k foo/bar/baz and get the same effect
@zcaudate: that wouldn't work either way, if http://dev.clojure.org/jira/browse/CLJ-1530 gets accepted neither :foo/bar/baz
nor foo/bar/baz
will be valid anymore
@zcaudate: btw I'd suggest you log your issues with that ticket in a comment there if you feel strongly against it
I suspect that the response will be "you should use a delimiter that doesn't have a special meaning in clojure", but I might be completely wrong (I find the core team doesn't agree with my opinions quite frequently :) ) especially if you point out that your library will break.
@bronsa: thanks for the heads up. I’ll leave a comment and add a prayer for the bdfl
@zcaudate: thanks for that! I just edited your comment wrapping the discussion in a {quote}
block for readability
I'm curious whether people use #'private-fn
in tests to test private functions
I feel like I shouldn't be doing it, but it's useful in some use cases
@anmonteiro: all the time...
another option is to put all the private functions in a sub namespace and make them public. The sub namespace is only used by the main
namespace and so there is less noise and you can test easier too.
@anmonteiro: but yeah… i don’t think what I do is standard practice so you may want a second opinion
@zcaudate: @anmonteiro the .impl
namespace is also done by libraries like core.async
so I'd say that's a good sign that it's good practice
Does anyone know how i could create a instance of userIndex by using Clojure interop
Collection<U> users = /// some collection
FastUserIndex<U> userIndex = new SimpleFastUserIndex<>() {
{
users.forEach(u -> add(u));
}
}
here’s javadoc: http://ranksys.org/javadoc/es/uam/eps/ir/ranksys/fast/index/SimpleFastUserIndex.htmlI'd do something like (reduce (fn [^FastUserIndex user-index user] (doto user-index (.add user))) (SimpleFastUserIndex.) users)
or (reduce #(doto ^FastUserIndex % (.add %2)) (SimpleFastUserIndex.) users)
if that's too verbose
Yes, the constructor of SimpleFastUserIndex is a protected method - Java version works, but for clojure i get “No matching ctor"
don't know off the top of my head if gen-class
supports protected methods but I would not use it in this case even if it did
I do have a clojure fork implementing defclass
and extend-class
special forms and wrapping macros (more general than deftype
and reify
) that would work in this case -- but it's unlikely going to be accepted into core so I never bothered opening a ticket about that
Hello everybody, we are planning to give a training in San Francisco area in the imminent future and would like to kind of survey the topic to be effective
I don't know if this is the best place to ask actually, maybe there is a more suitable another channel
ok I moved to #C0KQRPPBP
@base698: my guess would be @seancorfield -> https://github.com/clojure/java.jdbc/graphs/contributors
base698: have you looked at the source, you can just grep for executeBatch and there are plenty of hits
it looks like it does it by default. I can't see the errors coming back and jdbc/insert! don't work right with PGSQL.
or double check that it is actually happening, since postgres pretty much doesn't care about case in table names
It definitely does case about case, if you do: select from SomeTable; It gets interpreted as select from sometable;
java.jdbc
supports :entities quoting-strategy
as part of the API.
That allows you to tell java.jdbc
how to quote entities in SQL.
For MySQL we use
:entities (jdbc/quoted \`)
So then java.jdbc
generates
select * from `foo
`For SQL Server, you can use
(quoted [\[ \]])
to generate [foo]
in the SQL.(not just about case sensitivity — you need to quote entities if they would conflict with SQL reserved words too)
@seancorfield: Where do you put the :entities keyword?
Anyone have an example for execute-batch? The docs aren't doing it for me. I'm using insert! and that seems to be working great, except that the 300k insert statements take many minutes
cool, so my clojure code is about 10 times faster than the python code by doing that. Going to go demo it
@base698: did you figure out where to put :entities (quoted \")
?
(it just goes at the end of the argument list in the call)
There are examples here http://clojure-doc.org/articles/ecosystem/java_jdbc/using_sql.html#clojure-identifiers-and-sql-entities
This is the main java.jdbc
documentation http://clojure-doc.org/articles/ecosystem/java_jdbc/home.html
Has examples of nearly everything — and it’s community-contributable!!
Also on the DDL page it shows how to use :entities
with create-table
and drop-table
@seancorfield: Thanks! Did you used to host a clojure meetup in SF?
docstrings are such a subjective thing, I really don't know, I think I tend to favor terseness because if I really want to know I read the source
there are a few different projects for generating html docs if that is more what you are looking for, I've used https://github.com/weavejester/codox and it seems nice
https://aphyr.github.io/tesser/tesser.core.html is an example of the output of codox
the nice thing about honeysql, is it separates the dsl for generating and composing sql, from executing sql, so you can use honeysql to construct your sql queries, and then use java jdbc to run them
and on the topic of documentation… I’ve been dogfooding this for a while now https://www.youtube.com/watch?v=3MIaucjfJcE
the docstrings are taken from test suites: ie. https://github.com/zcaudate/hara/blob/master/src/hara/common/checks.clj#L8-L11 is generated using https://github.com/zcaudate/hara/blob/master/test/hara/common/checks_test.clj#L5-L9
uh, actually I haven't checked, but I am pretty sure it was, it looks exactly like codox
well, there is always going to be some kind of lag between when feature X is added to your favorite database and when you will be able to use it from some library
There are alot of strategies out there and there is so much to learn just to understand how to parse text
Execution semantics are really nice - it matches in one way or not at all, no ambiguous parses
well… when we use something without understanding it… there is an element of magic about it
like I was trying to explain the immutable datastructure the other day… “it looks like a vector… but it’s actually a tree"
and by exposing the underlying data, it gives a clue as to how something is implemented
@base698: the reason why I chose to write my own documentation tooling instead of using codox is because I wanted to write prose and to be able to configure it the way I want it to look: http://docs.caudate.me/adi and http://docs.caudate.me/hara are completely generated…
there are certain directives that take a namespace and expose it’s docstrings. i.e: http://docs.caudate.me/hara/hara-string.html#api---case is generated from only one line: https://github.com/zcaudate/hara/blob/master/test/documentation/hara_string.clj#L26