This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2022-06-21
Channels
- # announcements (3)
- # aws (8)
- # babashka (14)
- # beginners (39)
- # biff (22)
- # cider (5)
- # clj-kondo (1)
- # cljs-dev (12)
- # cljsjs (4)
- # clojure (16)
- # clojure-europe (47)
- # clojure-germany (6)
- # clojure-uk (2)
- # clojurescript (36)
- # core-async (29)
- # cursive (19)
- # datalevin (14)
- # etaoin (10)
- # helix (1)
- # hyperfiddle (6)
- # introduce-yourself (5)
- # kaocha (43)
- # keechma (1)
- # lsp (7)
- # nbb (68)
- # new-channels (1)
- # off-topic (12)
- # pathom (11)
- # quil (14)
- # rdf (3)
- # re-frame (5)
- # reitit (6)
- # shadow-cljs (88)
I created a couple of new channels • #performance • #idioms Please join if you are interested!
Looking at the source of clojure.zip, https://github.com/clojure/clojure/blob/35bd89f05f8dc4aec47001ca10fe9163abc02ea6/src/clj/clojure/zip.clj#L32
{:added "1.0"}
[branch? children make-node root]
^{:zip/branch? branch? :zip/children children :zip/make-node make-node}
[root nil])
It uses metadata to store the information such as branch function and such. Isn’t using defrecord
to define a newtype to be more straightforward?defrecord
was added in 1.2, zip
in 1.0 🙂
If it were written today, is using meta still a more sensible choice compared with defrecord?
Hard to say. Actually my first approach would be to just use a map. But other than Rich I did not study any literature on zippers, maybe it is more natural to represent it as a tuple?
The zipper structure seems to have two aspects: “Static” definition functions, stored in the metadata, and a state/cursor in the tree. The metadata never changes. So this could be an elegant solution, and allows you to print the “state” without the clutter (metadata)
Not sure if metadata would be the way to go if clojure.zip were written now, it is not the most performant solution. There are several alternative zipper libraries based on deftype with better perf, like https://github.com/akhudek/fast-zip
I don't think there's really a consensus about what you should and shouldn't do with metadata. I wouldn't say this is typical, and as pointed out there are more performant ways to do this now. Metadata is always a bit of a gray zone... It can be a convenient escape hatch, but a bunch of caveats apply.
@U07FP7QJ0 Unrelated to this, and a little bit off topic. I watched the clojure.zip video you presented back in 2018. Great presentation skills. Any advice/recommendation on how to practice these skills?
Oof that's a tough one... I've been doing these things for so long. Local user groups are great for practicing presentation skills. Even better if you can get a more experienced speaker to help you prepare and give feedback.
I think so. Reading books might not help, only first-hand practice makes a more difference.
Yeah I can really recommend finding a mentor, I've been part of some conferences that assign a mentor to each speaker. They help brainstorm the talk, help structure the slides, and then finally provide a test audience that can give you feedback. All of those kinds of input are valuable.