This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2018-11-26
Channels
- # adventofcode (2)
- # announcements (9)
- # bangalore-clj (1)
- # beginners (158)
- # calva (32)
- # cider (2)
- # clara (4)
- # cljdoc (40)
- # cljs-dev (3)
- # cljsrn (6)
- # clojure (45)
- # clojure-brasil (2)
- # clojure-dev (35)
- # clojure-europe (9)
- # clojure-italy (7)
- # clojure-nl (2)
- # clojure-uk (29)
- # clojurescript (144)
- # code-reviews (3)
- # core-logic (9)
- # cursive (11)
- # datascript (8)
- # datomic (9)
- # duct (1)
- # figwheel (6)
- # fulcro (11)
- # hyperfiddle (27)
- # kaocha (23)
- # luminus (1)
- # off-topic (7)
- # onyx (2)
- # pathom (3)
- # re-frame (61)
- # reagent (12)
- # remote-jobs (10)
- # shadow-cljs (40)
- # spacemacs (4)
- # sql (27)
- # tools-deps (6)
- # unrepl (3)
- # vim (47)
A question related to records: records implement most of the maps functionalities: get, assoc, keys etc… but they cannot be called as functions like maps Is there a special reason for this “limitation” of records?
@viebel I’m not an authority on this at all, but there are a couple of things that jump out for me: 1) records can implement protocols, so this already means there’s a variety of semantics associated w/ a record (not just get/assoc/et al). 2) More generally, it’s unclear what the semantics of invoking an arbitrary type should be.
Records are information structures so designed to optimize keyword lookup
They are not generic key to value lookup tables like generic maps
Which is the use case for IFn
makes sense @alexmiller
How would you explain the main conceptual differences between a Clojure Record and a Java (or other OOP language) object?
But records have also methods
e.g. this seems like a pretty stateful thing, like a Java object: https://github.com/ptaoussanis/carmine/blob/master/src/taoensso/carmine/connections.clj#L29
https://clojure.org/reference/datatypes#_why_have_both_deftype_and_defrecord and https://clojure.org/reference/datatypes#_datatypes_and_protocols_are_opinionated are pretty good at explaining the rationale
What about the component library? It uses defrecord for information from the program domain.
Great question @borkdude
component defrecords are immutable things (which is why start and stop have to return the updated component) where subparts can be updated in dependency order (which exists but isn't often used in practice), it could invent its own abstraction to cover that kind of thing, but it would just be another definition of a map interface
so it seems the question is not: is it domain or program information, but do you need something map-like
with a little bit of retro fitting, you can make component use regular maps, which is great, I would prefer those to defrecords, but things get kind of messy when you want to define interfaces between things without protocols, you end up rolling your own thing with collections of functions, or groups of multimethods, each of which have there own downsides (collections of functions might not actually be that bad, but multimethods are global things which makes them a pain for things like testing)
is it data or not? dependencies between parts of your program is data, your socket connection to a database is maybe not
Actually now that I looked to that code the issue was something else: records without ext in pixie so systems had to be maps etc etc. Totally different
@mpenet can you give an example of “usage of meta when necessary”?
component support maps so nothing special. But if you d wanted to fork it and make it work without records you could abuse meta to store "type" info, which is similar to the new protocols with metadata dispatch we have now