This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2016-01-07
Channels
- # admin-announcements (69)
- # alda (8)
- # beginners (6)
- # boot (182)
- # cider (10)
- # cljs-dev (24)
- # cljsrn (17)
- # clojars (70)
- # clojure (142)
- # clojure-brasil (5)
- # clojure-czech (1)
- # clojure-poland (4)
- # clojure-russia (96)
- # clojurescript (115)
- # community-development (37)
- # component (6)
- # cursive (11)
- # datomic (32)
- # events (4)
- # funcool (6)
- # hoplon (17)
- # ldnclj (10)
- # lein-figwheel (24)
- # mount (12)
- # om (141)
- # onyx (7)
- # parinfer (48)
- # re-frame (24)
- # reagent (31)
Why would I get call to java.lang.Integer ctor can't be resolved.
when I run lein check
with the code line (some-> env :port Integer.)
@drusellers does (do (import 'java.lang.Integer) (some-> env :port Integer.)) work?
drusellers: the Integer constructor in java takes either a primitive int
or a String
as an argument. the clojure compiler is telling you it doesn't know which one to use
that logic happens here if you like guts https://github.com/clojure/clojure/blob/master/src/jvm/clojure/lang/Reflector.java#L171-L184
@bobbycalderwood: In your presentation, it looks like you have a single stream of commands. Is this true? Or do you have different streams for different types of commands?
with-bindings takes a map where keys are vars
(let [out out] (future (with-bindings {#'out out} (println "test"))))
Anyone using timbre with slf4j-timbre and know how to blacklist a javaclass?
would you say that codox is still the go-to plugin for library documentation or is there something else i should be looking at?
Is it idiomatic to use a keyword with a trailing question mark as a map key that has a corresponding boolean value?
I know that symbols with trailing question marks in symbols refer to predicate functions and not boolean values
@frank: good question. You've got the right thought process. Made me think, though. A keyword isn't actually a function but it does implement the IFn
(or whatever the name is) protocol so that it can act like a function. But that made me realize that I don't actually know what a function is in relation to protocols. Hmm. A gap in my Clojure knowledge.
(e.g. a protocol always has a backing interface, so step 1 of calling a protocol function is to check if the type implements the interface, if so call that method. Otherwise it uses an inline cache in the generated code)
I'm at the point where I understand protocols and am starting to use/define them (and defrecords) in my own code and I even used a reify
trick the other day to delay the creation of strings for outputting to xml files, but I don't even know what a function really is. Odd.
@meow: functions are for sure either just IFn
or a protocol call. There's an optimization around keyword lookups as well I guess…
@tcrayford: Okay, cool. Appreciate the insights.
I have a long OO background (but not Java) so I get the whole class/method thing. So defrecord and such end up defining java classes with method implementations of interfaces...
if defrecord implements a protocol, then it uses the backing interface. But if you use extend-type
, that effectively goes into a cache on the protocol itself
though I understand that cljs uses protocols and clj uses more interfaces than protocols due to historical reasons
partly that a lot of clojure's core things are written in java, and kinda had to be at the time
and that's how things like keywords can act like functions because it all just comes down to implementing IFn for some object
Would love to see someone publish a few tutorials or blog posts about this subject. For example, when I first attempted to work with defrecord and deftype to define something that implemented some of the clojure collection protocols it was hard for me to figure out what all of them were and how they needed to behave and such.
And I was trying to do it in a cljc file with both clj and cljs variations and it made my head explode.
@jethroksy: in what way different? Immutability certainly helps equality, and =
is just java's .equals
as opposed to ==
, but otherwise it's mostly the same
@jethroksy: at least equality that makes sense 😉
I don't have a Java background. The last significant languages I worked in were QML (briefly) and Python (since about 1999) and in Python I knew exactly how an instance would be called upon in all the various contexts and could define classes accordingly.
i remember my desperation in converting vecs to lists doing 4clojure problems when it wasn't even necessary
Looking back I was really just trying to do too much at once as a first time working with defrecord/deftype without having any significant experience with either Java or Javascript.
Sure, I understand all the concepts because of my background with other languages, but that isn't enough to make it easy.
I just think there is a big gap in this area and would love to see more blog posts and tutorials and such.
https://github.com/Prismatic/eng-practices/blob/master/clojure/20130926-data-representation.md
@meow: some more documentation around the core interfaces is hopefully coming soon https://github.com/clojure/clojure-site/issues/17
I just added a suggested topic for clojure/west: https://github.com/clojurewest/clojurewest2016/wiki/Suggested-Topics
@bronsa: I have a start of this in a blog post somewhere. I guess I should post a gist directly in that issue
still about ext-map seems like there's room for optimisations when they arent' used no? (ex avoiding some ops on count, iterator etc...)?
@jethroksy: No, I haven't. TYVM. I will give that a read. Looks good.
@bronsa: You nailed it on the head with that ticket. Awesome. So glad that alex is going to work on that.
ex https://github.com/clojure/clojure/blob/master/src/clj/clojure/core_deftype.clj#L216-L217
I dont' know, maybe it's a bit extreme, I guess it also depends on the impact code like this has
@bronsa: if __extmap ...
would probably even things out, but (seq (concat foo nil)) is not free
since records are often used in performance critical stuff maybe such optimisations wouldn't hurt
@meow: so what makes a function a function in Clojure if it's not implementing IFn ? That was my naive assumption.
@agile_geek: if something is not an IFn it's not a function
@meow: ignore that comment. Slack had not updated and I didn't read rest of thread
@bronsa - exactly what I thought
what @tcrayford was saying is that invoking something doesn't always mean that IFn/invoke
will be used
It is kind of meta-trippy that you come to this functional language where functions are first class objects and its all about functions and then you come to find out that there really aren't any functions, there's just the concept of behaving like a function and anything can do it by implementing the IFn protocol and then you grasp the ironic beauty of it all.
@meow: being able to declare stuff as invokable is not a novel idea or unique to clojure
I guess because I was coming from a primarily OO background and kept reading about how the functional approach was superior and how to think functionally and so forth before I picked Clojure.
Now that I've been doing it for about 8 months I have a much better understanding and certainly I can find all kinds of things that are in common with Python. At the same time, I also now understand what it means to think about things in a functional way.
Python has good support for functions but I still went about tackling things in an OO way.
Is the purpose of macro as->
to let you put the value (aka $
) in various spots which you can’t do with ->
or ->>
. I feel like i’d use it to thread the needle to various spots in follow on calls.
REPL-y 0.3.1
Clojure 1.7.0
Docs: (doc function-name-here)
(find-doc "part-of-name-here")
Source: (source function-name-here)
Javadoc: (javadoc java-object-or-class-here)
Exit: Control+D or (exit) or (quit)
Results: Stored in vars *1, *2, *3, an exception in *e
user=> (conj [])
[]
I think you should get an exception
user=> (conj [])
ArityException Wrong number of args (1) passed to: core/conj clojure.lang.AFn.throwArity (AFn.java:429)
@timvisher, (source conj)
.
@akiva: ah yes i understand that. i guess my point is that that behavior changed from 1.6 to 1.7
jcomplex: it should be handled seamlessly if the jar is on the classpath... https://github.com/clojure/java.jdbc/blob/master/src/main/clojure/clojure/java/jdbc.clj#L131
This is my connection: `(def db-spec {:classname "com.microsoft.jdbc.sqlserver.SQLServerDriver" :subprotocol "sqlserver" :subname "//xxxx;database=Test;integratedSecurity=true"}) `
@timvisher: yeah it was changed in 1.7 for easier transducers support
@meow with reference to earlier on records etc., I'm just reading Clojure Applied and the various methods of model domain entities are explained in the first chapter. Might wanna check that out as well.
@jethroksy: Cool, thanks.
ztellman: I’m using manifold and aleph; and I feel like I might be doing things a bit incorrectly - unless I’m intentionally wanting to block; should I avoid dereffing deferreds as much as possible?
dangit @borkdude I was just going to click on that, then it vanished!