This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2017-11-01
Channels
- # aws (2)
- # aws-lambda (18)
- # beginners (68)
- # boot (6)
- # cider (2)
- # clara (2)
- # clojars (27)
- # clojure (68)
- # clojure-austin (5)
- # clojure-berlin (6)
- # clojure-dev (28)
- # clojure-greece (7)
- # clojure-italy (46)
- # clojure-japan (3)
- # clojure-nl (1)
- # clojure-russia (8)
- # clojure-sg (1)
- # clojure-spec (17)
- # clojure-uk (86)
- # clojurescript (82)
- # community-development (2)
- # cursive (18)
- # datomic (11)
- # duct (5)
- # fulcro (254)
- # garden (2)
- # graphql (6)
- # hoplon (19)
- # instaparse (4)
- # kekkonen (2)
- # leiningen (4)
- # luminus (3)
- # lumo (9)
- # off-topic (28)
- # om (7)
- # onyx (38)
- # other-languages (27)
- # portkey (7)
- # protorepl (1)
- # re-frame (56)
- # reagent (64)
- # ring (14)
- # ring-swagger (7)
- # shadow-cljs (255)
- # sql (2)
- # vim (11)
- # yada (10)
is a lambda function the same as a closure?
hey all - I'm having super slow compile times on my clojure app - I remember there being a way to report on which namespace the compiler is busy working on, but can't find it anywhere now?
that doesn’t ring any bells for me other than the :verbose flag in require. Getting that set at the right place in your code might help. There is a particularly bad exponential problem in compilation that was fixed in the 1.9 alphas - curious if you’re using a 1.9.0 beta or 1.8.0 etc?
I suspect one or two namespaces to be culprits, so would like to identify them and then see what I can do
@arno They are not the same. A lambda is a function as a value (you can assign it, pass it around, execute etc). A closure is an implementation detail. It has to do with visibility of symbols when the function is created inside another function (think of it as an implicit map). The inner function "closes over" the context of the outer function, thus creating a closure. This allows the inner fn to refer to symbols that are not declared locally to it. The wikipedia entry does a decent job describing it: https://en.wikipedia.org/wiki/Closure_(computer_programming)
excellent comparison. by the way, your avatar is incredible. always glad to meet a fellow Dead head, especially a developer Dead head
Apart from repainting with clj colors, I've just stolen a logo with long history 🙂 http://xahlee.info/UnixResource_dir/lambda_logo.html
are there people that set clojure to strict type checking?
I'm trying to scrape the slack logs here
for a quick analysis thing but am getting a javax.net.ssl.SSLHandshakeException: Received fatal alert: handshake_failure
with slurp/http-kit/clj-http. anyone know a solution for this?
in clojure, is it possible to use , in large numbers, like entering 1e9 as 1,000,000,000 ?
Cursive colors them a gray color by default
not sure if that’s reusing something public or not
kibit or eastwood would be good places to look
@alexmiller I think Cursive uses it’s own static analysis to do that
that would be my suspicion too
It can be harder than that too. Cursive colours them grey, but if you have a unit test exercising that function then it is 'used', even if it's only the test and nothing in the 'actual' codebase that uses it
more incentive not to test :)
one could theoretically write relatively easily a tool which goes through the code and finds which parts are used and which aren’t
as part of this https://github.com/portkey-cloud/portkey
I’ve done some stuff with tools.analyzer that could answer these questions, but it’s not in a consumable form atm
@chrisblom As I recall from some months ago, I didn't see unused-function checking in kibit or eastwood. This extremely simple bash script was enough for me at the time: https://gist.github.com/joelittlejohn/4729776
hey guys,
what’s the idiomatic clojure way to handle accessing a data source from multiple disparate points? say you had some data db
and “features” a
and b
that needed to get into that data. on one hand it feels wrong to just use direct interactions like get get-in
etc. we should be programming to an interface, no? on the other hand, an interface feels clunky if mostly all it’s doing is using get get-in
itself. am I thinking about this incorrectly?
@lwhorton the data type is made of a number of interfaces
it's considered idiomatic to put things in plain data, and access it as plain data, and not hide things with private values or accessor functions
i see. and the “interface” to which you are programming is just stricter rules on schema mutations? such as accretion instead of deletion?
unless you made something mutable and have to prevent invalid operations... then you probably want to just do it the way you would in java, but seriously second guess whether it actually needs to be mutable
the data structure itself, eg. hash-map, implements a number of interfaces. We use those to manage the data in the map.
on a more abstract level there are things like spec and schema if you want to make assertions about the content and shape of the data, but honestly clojure isn't designed for making these sorts of restrictions
it's possible, but a bit clunky, and it's easy to make a mess if you try to program with that mindset in a clojure codebase
I think I understand. it’s a whole new world, coming from a different paradigm. I just can’t help but think about some sort of data access layer, or a (spooky) data access object. it allows you to aggregate things like logging/monitoring, and provides a “single door” through which everyone has to walk. leaving that behind feels uncomfortable
if you think giving up controlling data access is scary, just try using clojure for a while then trying to go back and write code with mutable objects again - that stuff is horrifying
there are other languages where you both have strictness about access and types, and immutability, but they have their own trade offs too (typically clumsy and complex language design, and spending a large amount of your time trying to make the compiler happy instead of solving your problem directly)
https://news.ycombinator.com/item?id=15603023 <--- For those interested, we're also looking for more developers
on vectors, is last guaranteed to be O(1) time and pop guaranteed to be O(log_32 n) time ?
Hey, Alex's tweeting has reminded me of a particular case that I find difficult to deal with in Clojure. I wonder if there's an interesting way to deal with it.
The recent example was turning nested maps which would work for transacting to Datomic except for having reverse attributes in them, into a sequence of maps which do work because they have entities broken out with forward references.
The part of it that's difficult (for me) to handle in Clojure is the recursion on a tree structure /and/ collecting multiple values.
@eraserhdanything that involves "complex thing on nested data structure" generally has me reaching for #specter ; it'll probably still be somewhat complex though
((fn map-paths [path m]
(if (map? m)
(for [[k v] m
i (map-paths (conj path k) v)]
i)
[[path m]]))
[]
{:a {:b 1
:c [3]}
:w {:x 1}})
([[:a :b] 1] [[:a :c] [3]] [[:w :x] 1])
Hi all, I was looking for a shortcut to see whether a key in a map was present, and was mildly surprised that this didn't work:
(def s [{:a 1} {:a 2} {:a 1} {:a 0}]) ; I want to filter for {:a 1}
Using an anonymous function is trivial:
user=> (filter #(= (:a %) 1) s)
({:a 1} {:a 1})
But I sort of expected this to work just as well, and it doesn't seem to:
user=> (filter (comp :a #{1}) s)
()
Oh, darn it! Got the order backwards
Awesome. Thanks @dpsutton!