This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2020-11-13
Channels
- # aleph (1)
- # announcements (18)
- # babashka (11)
- # beginners (112)
- # business (1)
- # calva (19)
- # cider (8)
- # clj-kondo (63)
- # cljsrn (10)
- # clojure (188)
- # clojure-australia (1)
- # clojure-dev (38)
- # clojure-europe (112)
- # clojure-nl (3)
- # clojure-provo (1)
- # clojure-spec (22)
- # clojure-uk (108)
- # clojurescript (37)
- # cryogen (4)
- # cursive (8)
- # data-science (1)
- # datomic (13)
- # emacs (9)
- # events (1)
- # fulcro (26)
- # funcool (3)
- # graalvm (2)
- # graphql (11)
- # helix (8)
- # jobs (1)
- # jobs-discuss (7)
- # nrepl (3)
- # off-topic (72)
- # pathom (10)
- # pedestal (1)
- # reagent (6)
- # reitit (7)
- # remote-jobs (1)
- # shadow-cljs (28)
- # xtdb (12)
One thing that I can't figure out is why does this work (let [{funky-name :old-name} my-map] funky-name)
. How does the {}
know to pull out the key called :old-name
and give it a new name called funky-name
?
what is the value of `my-map'?
looks like an unwholesome kind of destructuring within-a-let-statement kind of thing?
morning
not unwholesome, that's just destructuring
people get tempted into deeply nesting them
I'm not a big fan
i prefer this syntax, it's declarative and i can read it at a glance years later
yeah like that form
but there a few odd occasions, for clarity, that when I pull out a key from a map, I want to rename it
I dislike it because the syntax is subtle
and I dont want to have to deal with nuance when reading some elses code
i'm the other way around - i quite often find myself destructuring two objects of the same type next to each other, and :keys
is useless then, and even when it's not absolutely necessary i find a destructure like [{u-name :name u-id :id :as u} user]
makes the subsequent code easier to read
Morning
so i actively avoid :keys
🙂 It’s good to know there are a few ways of doing these things. I’ll ask in #beginners
the docs are not bad @dharrigan https://clojure.org/guides/destructuring#_associative_destructuring
doh! dup :man-facepalming:
The destructuring form is now a map rather than a vector, and instead of a symbol on the left side of the let, we have a map. The keys of the map are the symbols we want to bind in the let. The values of the destructuring map are the keys we will look up in the associative value.
I've steered clear of the basic associative destructuring approach in the past of favour of keys
because the way that works is more intuitive.
destructuring forms are written backwards from map-literal forms - which kind of makes sense @dharrigan - map-literals are putting something in to a map, destructuring is taking it out
(let [{foo :foo} {:foo 10}] foo)
(let*
[map__211906
{:foo 10}
map__211906
(if (seq? map__211906)
(clojure.lang.PersistentHashMap/create (seq map__211906))
map__211906)
foo
(get map__211906 :foo)]
foo)
there's an example of what happens (gotten with macroexpand-1
)
@dharrigan (my-map :old-name)
is exactly what happens after macroexpansion
here's a keys example
(let [{:keys [foo]} {:foo 10}] foo)
(let*
[map__211910
{:foo 10}
map__211910
(if (seq? map__211910)
(clojure.lang.PersistentHashMap/create (seq map__211910))
map__211910)
foo
(get map__211910 :foo)]
foo)
the generated code is identical!
I don’t really use a mac, but were people here stung badly by the oscp outage yesterday?
(which is diabolical anyway! - apple controls what you can open up on your computer. every bit of software calls home to apple on open)
i never noticed - didn't try and install anything yesterday
it was the ocsp server on apple being unavailable. Everytime you open an app on a mac, it calls home
to check if it’s allowed to run or not (i.e., if apple kindly bestows its blessing upon you to run the apps that you may have bought)
if that is offline, then apps don’t open, as rather than a soft-fail (which is what is recommended), apple did a hard-fail.
@dharrigan are you sure about that? surely they must work offline
also you could just block the phoning home :woman-shrugging:
also final point on the destructuring - the long form with an :as entity-type
is imo the most readable
@alex.lynham the problem was instead of hard-failing on the TCP connection (which would be fast), it was timing out after a long time (30s? 60s?); Happened to me as well and rebooting (hence opening lots of apps) exasperated the problem. I ended up booting into safe-mode to modify my /etc/hosts
and restore my sanity.
It's a wonderful example of Leslie Lamport's: "A distributed system is one in which the failure of a computer you didn't even know existed can render your own computer unusable."
so it is solvable by modifying your hosts file then? cool cool
i used to do a similar thing to stop adobe creative cloud cocking up my work laptop when i switched wifi networks
looks like apple can bypass any vpn restrictions (or little snitch restrictions) you have in place
but presumably not the hostsfile?
i'm still on mojave, no plans to move atm
I use one of those ethernet power plug things, and I frequently lose internet but stay connected. I don't usually notice for about 30m or so. It's just me, vim and localhost. Bliss.
do you have flakey electrics @dominicm? i've got the ethernet power plug things and i almost never lose connection
@mccraigmccraig the electrics in this house haven't been checked since before I was born.
my old house was much different - definitely flakey electrics and some sockets didn't work very well, others were fine
I also have really old versions of the ethernet plugs, which don't use ground. The new ones are supposed to be way more reliable.
I have a powerline too. Never experienced any droppage that I didn’t initiate myself.
yeah i found they were solid but the speed was poor, so i switched a several relay wireless routers and the speed is way higher now
although that powerline unit was bought in errrr 2014? so possibly they're better now
They were all us based before I believe. So the power line standard was just 2-port. I'm planning to run ethernet throughout the house for cctv and computers pis etc
morning 👋
I think the powerline bandwidth is highly sensitive to the quality of the wiring in your house
and other electrical items perturbing the AC wave