This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2017-05-08
Channels
- # aws (9)
- # beginners (69)
- # boot (14)
- # cider (26)
- # cljs-dev (56)
- # cljsrn (9)
- # clojars (4)
- # clojure (229)
- # clojure-brasil (1)
- # clojure-france (11)
- # clojure-greece (2)
- # clojure-italy (4)
- # clojure-mke (6)
- # clojure-serbia (6)
- # clojure-spec (83)
- # clojure-uk (38)
- # clojurescript (171)
- # core-async (3)
- # cursive (11)
- # data-science (11)
- # datomic (27)
- # emacs (113)
- # funcool (6)
- # hoplon (4)
- # jobs (1)
- # luminus (13)
- # lumo (44)
- # off-topic (148)
- # onyx (5)
- # overtone (1)
- # pedestal (4)
- # powderkeg (1)
- # proton (2)
- # re-frame (150)
- # reagent (16)
- # ring-swagger (43)
- # spacemacs (4)
- # specter (36)
- # vim (4)
- # yada (10)
Not a good start to the morning... train arrived 8 mins late already...wonder how much time it will lose due to slow local services all the way down east coast now? 🚂
agile_geek: Where are you commuting from/to?
From Newcastle Upon Tyne (actually Washington, Tyne and Wear but trains from Newcastle) to Londinium...my once a week commute to the big smoke.
I stay in London for the week and go back on Friday evening
That's quite the commute, but at least it's only once a week each direction. Not sure whether I'd prefer that over 2 hours each way every day which lots of folks do here 🙂
how is the journey progressing @agile_geek ?
So far so good..train status webpage is still predicting we'll only be 8 mins late into London...but I never believe it.
Still in South Yorkshire (just south of Doncaster) so a way to go yet
I was right to be sceptical. Now delayed 13 mins... once you're out of your time slot by more than a couple of mins on East Coast line you're frequently held up by slower local services.
Still. Could be a lot worse....the worse delay I've ever had was in 2011...stuck stationary in train on afternoon of hottest day that year for over 5 hours making trip over 8 hours long.. fun!
morning!
rcfotd:
-------------------------
clojure.core/definline
([name & decl])
Macro
Experimental - like defmacro, except defines a named function whose
body is the expansion, calls to which may be expanded inline as if
it were a macro. Cannot be used with variadic (&) args.
@peterwestmacott I'm not sure I fully understand definline
. PLease use it in a sentence.
@agile_geek neither do I
"Someone said I cut in but I was definline"
user=> (definline a [x] `(+ ~x ~x))
#'user/a
user=> (a 1)
2
user=> (map a [1 2])
(2 4)
the gotchas are that because it can be used both at runtime and at compile time, you can't do any rewriting in the body that assume the arguments won't be evaluated
it sounds too powerful to be a free lunch
e.g. my example suffers from double execution
user=> (a (do (println "foO") 1))
foO
foO
2
sounds like one of those features that you overuse when you first find it and becomes painful when your codebase grows?
Agree with @bronsa here, not a lot of uses for definline
. Looking at the standard lib, they have been used on functions to 1. carry over type info 2. during interop calls 3. still allowing them to be used as higher order fns. If that is not specific enough! 🙂
Anyway, there is some notable example in clj/java mixed projects. Manifold makes good use of them:
https://github.com/ztellman/manifold/search?utf8=✓&q=definline&type=
but I am not sure Zach Tellman is actually human... that might explain why he understands how to use it.
I've made the mistake of trying to do something clever. As I'm working with a lot of database extracts at the moment I'm trying to dynamically create a function that uses juxt, but takes the fields as an argument, so I end up with something like #((juxt :field1 field2... ) %)
. I've been able to generate the field names and order them, but I'm stuck trying to figure out how to pass a bunch of keys to a function. Is there a way to do this?
@geek-draven What do you mean by: > how to pass a bunch of keys to a function ?
Do you mean something like:
(let [x [:a :b :c]]
((apply juxt x) {:a 1 :b 2 :c 3}))
;; => [1 2 3]
?@dominicm Thanks, I was passing the keys as a list rather than vector 🙂
@geek-draven a list works with apply
too. I might have misunderstood you though.