This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2023-01-10
Channels
- # babashka (17)
- # beginners (57)
- # calva (19)
- # cider (1)
- # clj-kondo (21)
- # clojure (36)
- # clojure-austin (15)
- # clojure-australia (1)
- # clojure-china (1)
- # clojure-europe (35)
- # clojure-filipino (1)
- # clojure-hk (1)
- # clojure-indonesia (1)
- # clojure-japan (1)
- # clojure-korea (2)
- # clojure-my (1)
- # clojure-nl (1)
- # clojure-norway (5)
- # clojure-sg (1)
- # clojure-spec (6)
- # clojure-taiwan (1)
- # clojure-uk (3)
- # clojurescript (7)
- # clr (9)
- # community-development (5)
- # cursive (14)
- # datalevin (1)
- # emacs (5)
- # events (5)
- # exercism (2)
- # figwheel-main (2)
- # fulcro (6)
- # funcool (3)
- # introduce-yourself (2)
- # joyride (7)
- # leiningen (4)
- # london-clojurians (9)
- # malli (3)
- # membrane (1)
- # missionary (54)
- # music (1)
- # nbb (2)
- # pathom (5)
- # pedestal (55)
- # rdf (13)
- # re-frame (10)
- # reitit (3)
- # shadow-cljs (17)
- # vim (58)
- # web-security (12)
is https://clojure.atlassian.net/browse/CLJ-2123 the closest we have to reference documentation on how :as-alias
works right now?
including that excerpt from (doc require)
here in case others are curious:
> (doc require)
...
Recognized options:
:as takes a symbol as its argument and makes that symbol an alias to the
lib's namespace in the current namespace.
:as-alias takes a symbol as its argument and aliases like :as, however
the lib will not be loaded. If the lib has not been loaded, a new
empty namespace will be created (as with create-ns).
:refer takes a list of symbols to refer from the namespace or the :all
keyword to bring in all public vars.
and here's a small example.
$ clj
Clojure 1.11.1
user=> (require '[nextjournal.clerk :as-alias clerk])
nil
user=> clerk/serve!
Syntax error compiling at (REPL:0:0).
No such var: clerk/serve!
user=> ::clerk
:user/clerk
user=> ::clerk/thing
:nextjournal.clerk/thing
user=> `clerk/thing
nextjournal.clerk/thing
1. :as-alias
was introduced in Clojure 1.11
2. vars are not available
3. but namespaced keywords and sharp-quoted symbols resolve their namespaceI added a doc issue to expand coverage on clojure site https://github.com/clojure/clojure-site/issues/632
not sure "large" (size) is relevant
granularity or "complexity of update" is probably more relevant
atoms protect updates to state so there is a tradeoff in granularity / amount of state vs contention to update - that's usually the important thing to consider
The updates should all be happening within my Clojure2d drawing thread. I don't expect contention there.
@U02UHTG2YH5 what are you putting into your atom that you thought perhaps size would be an issue?
The largest is probably a set of lines to draw, usually 20ish lines. And then 30 of those sets.
I would start with one thing until that's not sufficient :)
Another point. Size kinda doesnโt matter. But one thing that tracks with size is the number of code paths that try to update the atom because it holds all the data. If 15 threads all hit the atom and change independent parts, you can get into high contention. But by itself the size of the data in the atom is irrelevant.
and the two main techniques for dealing with it once it's not sufficient are changing atom of map --> map of atoms (for uncoordinated state) or map of refs (for coordinated state)
this was actually surprising:
user> {(random-uuid) 1 (random-uuid) 2}
Syntax error reading source at (REPL:146:66).
Duplicate key: (random-uuid)
I guess it's just better to use hash-map
in that case
(hash-map (random-uuid) 1 (random-uuid) 2)
(because it tells you that it happened during the read phase, before the compiler attempts to evaluate forms.)