clojure-uk

A place for people in the UK, near the UK, visiting the UK, planning to visit the UK or just vaguely interested to randomly chat about things (often vi and emacs, occasionally clojure). More general the #ldnclj
dominicm 2020-11-13T04:23:42.435700Z

Morning

1
dharrigan 2020-11-13T06:40:15.436Z

Good Morning!

djm 2020-11-13T06:49:44.436200Z

đź‘‹

yogidevbear 2020-11-13T07:38:26.436400Z

o/

jasonbell 2020-11-13T08:15:41.436600Z

Morning

thomas 2020-11-13T08:17:28.436800Z

mogge

dharrigan 2020-11-13T08:44:19.438500Z

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?

2020-11-13T08:54:27.439100Z

what is the value of `my-map'?

2020-11-13T08:54:51.439700Z

looks like an unwholesome kind of destructuring within-a-let-statement kind of thing?

alexlynham 2020-11-13T08:56:11.440600Z

morning

rlj 2020-11-13T08:56:15.440900Z

Mornin

alexlynham 2020-11-13T08:56:23.441Z

not unwholesome, that's just destructuring

2020-11-13T08:57:02.441400Z

people get tempted into deeply nesting them

2020-11-13T08:57:08.441700Z

I'm not a big fan

dharrigan 2020-11-13T09:07:24.441900Z

my-map is just {:old-name "david"}

dharrigan 2020-11-13T09:08:27.442700Z

I use {:keys [foo bar baz]} my-map a lot in my code

2020-11-13T09:08:43.443300Z

yeah like that form

dharrigan 2020-11-13T09:08:45.443400Z

but there a few odd occasions, for clarity, that when I pull out a key from a map, I want to rename it

2020-11-13T09:09:23.444700Z

I dislike it because the syntax is subtle

2020-11-13T09:10:03.445500Z

and I dont want to have to deal with nuance when reading some elses code

mccraigmccraig 2020-11-13T09:16:01.449Z

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

2020-11-13T09:17:32.449500Z

Morning

mccraigmccraig 2020-11-13T09:17:50.449800Z

so i actively avoid :keys

dharrigan 2020-11-13T09:18:16.450500Z

🙂 It’s good to know there are a few ways of doing these things. I’ll ask in #beginners

dharrigan 2020-11-13T09:18:29.451Z

about how it works for the renaming

mccraigmccraig 2020-11-13T09:19:45.452600Z

the docs are not bad @dharrigan https://clojure.org/guides/destructuring#_associative_destructuring

dharrigan 2020-11-13T09:20:10.453100Z

Yes, I’ve read them

mccraigmccraig 2020-11-13T09:20:11.453300Z

doh! dup :man-facepalming:

dharrigan 2020-11-13T09:20:16.453600Z

but I don’t understand the mechanics

dharrigan 2020-11-13T09:20:27.454200Z

how does it know to pull out the key from the map

dharrigan 2020-11-13T09:20:38.454600Z

it’s abit counterintuiative

dharrigan 2020-11-13T09:20:40.454800Z

for example

dharrigan 2020-11-13T09:20:44.455Z

I would have expected this

dharrigan 2020-11-13T09:20:57.455500Z

{:old-name funky-name} so to speak

dharrigan 2020-11-13T09:21:05.455900Z

since we do this

dharrigan 2020-11-13T09:21:09.456200Z

(:old-name my-map)

dharrigan 2020-11-13T09:22:10.457700Z

So this explains what it is doing

dharrigan 2020-11-13T09:22:12.457900Z

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.

dharrigan 2020-11-13T09:22:24.458700Z

I just don’t understand the mechanics

rlj 2020-11-13T09:22:29.458800Z

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.

mccraigmccraig 2020-11-13T09:23:00.459700Z

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

mccraigmccraig 2020-11-13T09:23:27.460400Z

(let [{foo :foo} {:foo 10}] foo)

dharrigan 2020-11-13T09:23:36.460600Z

okay… so why not (my-map :old-name) since that’s taking old-name out of my-map

mccraigmccraig 2020-11-13T09:23:49.461Z

(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)

dharrigan 2020-11-13T09:23:56.461400Z

reading…

mccraigmccraig 2020-11-13T09:24:10.461700Z

there's an example of what happens (gotten with macroexpand-1)

mccraigmccraig 2020-11-13T09:24:58.462300Z

@dharrigan (my-map :old-name) is exactly what happens after macroexpansion

dharrigan 2020-11-13T09:25:18.462700Z

right, using the get variant

mccraigmccraig 2020-11-13T09:25:23.463Z

yep

dharrigan 2020-11-13T09:25:26.463200Z

I see I see

mccraigmccraig 2020-11-13T09:26:00.463400Z

here's a keys example

mccraigmccraig 2020-11-13T09:26:23.463800Z

(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)

mccraigmccraig 2020-11-13T09:26:47.464100Z

the generated code is identical!

dharrigan 2020-11-13T09:26:58.464300Z

ah! right. digesting. starting to make sense

dharrigan 2020-11-13T09:29:22.464700Z

what a lively on-topic discussion for a Friday morning! 🙂

dharrigan 2020-11-13T09:29:25.464900Z

Thank you everyone 🙂

dharrigan 2020-11-13T09:29:29.465100Z

I will go away and study.

dharrigan 2020-11-13T09:30:14.465500Z

I don’t really use a mac, but were people here stung badly by the oscp outage yesterday?

dharrigan 2020-11-13T09:30:21.465700Z

prevented mac apps from opening

dharrigan 2020-11-13T09:30:52.466500Z

(which is diabolical anyway! - apple controls what you can open up on your computer. every bit of software calls home to apple on open)

rlj 2020-11-13T09:31:05.466800Z

I can't upgrade my new work laptop to Big Sur yet (although maybe that's a good thing)

dharrigan 2020-11-13T09:31:21.467Z

<https://twitter.com/lapcatsoftware/status/1326990296412991489>

mccraigmccraig 2020-11-13T09:34:57.467500Z

i never noticed - didn't try and install anything yesterday

rlj 2020-11-13T09:40:51.468Z

Oh, my OS upgrade is downloading now. Exciting!

dharrigan 2020-11-13T09:46:07.469Z

the outage wasn’t about installing anything

dharrigan 2020-11-13T09:46:43.469600Z

it was the ocsp server on apple being unavailable. Everytime you open an app on a mac, it calls home

dharrigan 2020-11-13T09:46:47.469800Z

every single time

dharrigan 2020-11-13T09:47:16.470500Z

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)

dharrigan 2020-11-13T09:47:56.471200Z

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.

alexlynham 2020-11-13T10:23:00.471700Z

i prefer this syntax, it's declarative and i can read it at a glance years later

alexlynham 2020-11-13T10:26:12.471900Z

@dharrigan are you sure about that? surely they must work offline

alexlynham 2020-11-13T10:26:36.472Z

also you could just block the phoning home :woman-shrugging:

alexlynham 2020-11-13T10:27:14.472100Z

also final point on the destructuring - the long form with an :as entity-type is imo the most readable

dharrigan 2020-11-13T10:28:16.472500Z

Alex, it was confirmed by multiple instances across t’interwebs

dharrigan 2020-11-13T10:28:33.472900Z

I do block it

dharrigan 2020-11-13T10:28:57.473500Z

I have 0.0.0.0 <http://ocsp.apple.com|ocsp.apple.com> in my hosts file for my mac that I use now-and-again

pithyless 2020-11-13T10:38:34.478100Z

@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.

pithyless 2020-11-13T10:42:31.478500Z

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."

alexlynham 2020-11-13T10:43:57.478600Z

so it is solvable by modifying your hosts file then? cool cool

alexlynham 2020-11-13T10:44:20.478700Z

i used to do a similar thing to stop adobe creative cloud cocking up my work laptop when i switched wifi networks

dharrigan 2020-11-13T12:25:18.479600Z

Be careful on upgrading to Big Sur

dharrigan 2020-11-13T12:25:20.479800Z

https://sneak.berlin/20201112/your-computer-isnt-yours/

dharrigan 2020-11-13T12:25:37.480300Z

looks like apple can bypass any vpn restrictions (or little snitch restrictions) you have in place

alexlynham 2020-11-13T12:50:13.481400Z

but presumably not the hostsfile?

alexlynham 2020-11-13T12:50:20.481500Z

i'm still on mojave, no plans to move atm

dominicm 2020-11-13T12:50:55.482500Z

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.

mccraigmccraig 2020-11-13T12:53:49.483500Z

do you have flakey electrics @dominicm? i've got the ethernet power plug things and i almost never lose connection

dominicm 2020-11-13T12:54:29.484200Z

@mccraigmccraig the electrics in this house haven't been checked since before I was born.

dominicm 2020-11-13T12:54:35.484400Z

So, probably.

mccraigmccraig 2020-11-13T12:57:05.485600Z

my old house was much different - definitely flakey electrics and some sockets didn't work very well, others were fine

dominicm 2020-11-13T12:58:23.486300Z

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.

dharrigan 2020-11-13T13:00:52.486800Z

I have a powerline too. Never experienced any droppage that I didn’t initiate myself.

dharrigan 2020-11-13T13:00:59.487Z

They are rock solid

dharrigan 2020-11-13T13:01:15.487200Z

a pair of dlinks

alexlynham 2020-11-13T13:02:06.487300Z

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

đź‘Ť 1
alexlynham 2020-11-13T13:02:24.487500Z

although that powerline unit was bought in errrr 2014? so possibly they're better now

dharrigan 2020-11-13T13:02:36.488Z

I have a pair of Gigabit powerlines

dominicm 2020-11-13T13:03:22.489500Z

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

Jakob Durstberger 2020-11-13T13:55:53.489700Z

morning đź‘‹

2020-11-13T15:14:52.490400Z

I think the powerline bandwidth is highly sensitive to the quality of the wiring in your house

dharrigan 2020-11-13T15:15:11.490800Z

agreed 🙂

dharrigan 2020-11-13T15:15:21.491300Z

When I was living in a shared house, I would just drop cable everywhere

2020-11-13T15:15:43.491700Z

and other electrical items perturbing the AC wave

dharrigan 2020-11-13T15:18:17.491900Z

Oh, I like that word

dharrigan 2020-11-13T15:18:20.492100Z

perturbing

dharrigan 2020-11-13T15:18:24.492300Z

haven't heard that in a while

dharrigan 2020-11-13T15:18:36.492700Z

I sense a great perturbance in the force