Fork me on GitHub
#clojure-dev
<
2018-11-27
>
gfredericks00:11:06

Alex's response to the "Why not IFn?" question reminds me of a viewpoint on clj maps I've had for a while but haven't heard anybody else articulate (you could apply this to other dynamic languages too) that their use falls into two disjoint patterns A) homogeneous maps, which are unbounded in size and have keys of one specific type and values of another specific type (i.e., s/map-of) B) heterogeneous maps, which have keys that are names taken from a known and probably very small set, and the values are arbitrary but typed specific to individual keys (i.e., s/keys) so my interpretation of alex's comment about defrecord is that "defrecord is only for type B"

💯 4
Alex Miller (Clojure team)01:11:05

In Rich speak, “mechanism vs information”

gfredericks00:11:14

and also I would say that the IFn interface is only for type A

gfredericks00:11:40

I think of IFn on map (and get) being for type A, while IFn on keywords is for type B

Alex Miller (Clojure team)01:11:39

Instead of IFn for keywords, I would call it ILookup

gfredericks00:11:23

ILookup is the interface the arg is expected to satisfy, right?

gfredericks16:11:48

okay, so I was talking about (:foo m) calls; it's true that m satisfies ILookup in this case, but it's the fact that the keyword is being called as a function that I want to highlight, so I can't see why talking about "IFn for keywords" doesn't accomplish that

gfredericks16:11:21

I assume the ILookup comment also applies to (get m :foo), so it wouldn't seem to distinguish the case I'm trying to

gfredericks00:11:17

there's a parallel distinction you could make for sequential structures; sequences vs tuples, or something of that sort

gfredericks01:11:00

most statically typed languages have totally different constructs for the different cases, so distinguishing them isn't as useful

gfredericks01:11:44

can also be interesting to note that JSON seems aimed at a paradigm where type A doesn't exist -- that's why its maps can only have string keys

hiredman01:11:18

or structs vs. maps

gfredericks01:11:33

Woah does defstruct still exist

gfredericks01:11:48

I haven't thought about it in like seven years

bronsa01:11:57

and it's not even deprecated!

gfredericks01:11:53

Does it compile to a special class?

bronsa01:11:08

no it's got no special compiler support

bronsa01:11:19

just a regular data structure impl, but I have no idea how it works :)

Yehonathan Sharvit15:11:03

I am reading the datatype official material at https://clojure.org/reference/datatypes#_deftype_and_defrecord And it mentions “host-in-parens constructs” What is the meaning of “host-in-parens constructs” in this context? ” They support, in a relatively clean manner, access to the highest-performance primitive representation and polymorphism mechanisms of the host. N.B. that they are not merely host-in-parens constructs. ”

dpsutton15:11:55

i take this to mean they are not merely host constructs "parenified". ie, they aren't just java classes written with parens instead of {

Alex Miller (Clojure team)16:11:44

They are exactly the same as if you invoked a java object through a polymorphic method in Java (there is no extra Clojure var overhead or anything)

Yehonathan Sharvit16:11:39

You mean from a performance perspective?

Alex Miller (Clojure team)16:11:42

From all perspectives :)

Alex Miller (Clojure team)16:11:54

But yes, the implication is perf

Yehonathan Sharvit16:11:05

So conceptually, they are different: they are opiniated , they are the Clojure way of doing OO but there are no performance penalties for that. In short: We benefit from the best of both worlds metal

Alex Miller (Clojure team)17:11:41

fast case is fast, “slow” case is open (still fast due to cache)

martinklepsch18:11:32

is it expected that AOT compiled namespaces lose metadata?

martinklepsch18:11:47

$ clj -Sdeps '{:deps {datascript {:mvn/version "0.16.8"}}}'
Clojure 1.9.0
user=> (require 'datascript.arrays)
nil
user=> (find-ns 'datascript.arrays)
#object[clojure.lang.Namespace 0x76911385 "datascript.arrays"]
user=> (meta (find-ns 'datascript.arrays))
nil

hiredman18:11:27

I was going to say "expected in that it is a known issue" but it looks like maybe it should be fixed, it may depend on the version of clojure the ns was aot compiled with

hiredman18:11:46

also, what makes you think that is an aot compiled namespace?

hiredman18:11:40

if datascript artifacts contain aot compiled code I am going to be so sad

bronsa18:11:43

and it looks like it's compiled with 1.7

bronsa18:11:45

which explains the bug

hiredman18:11:47

those jerks

hiredman18:11:22

now my beautiful code is tied to the 1.7 abi, wonderful

bronsa18:11:15

(holy shit 1.8 was 3 years ago, what is happening to time)

andy.fingerhut19:11:54

Time did not change, bronsa, you got older 🙂

😛 12
lol 4