Fork me on GitHub
#clojure
<
2018-10-20
>
roti08:10:20

so, I just learned that you can't overload functions by type, but only by arity 😋 . for some reason in my mind this was a possibility. any ideas how I can achieve the same effect, but keeping the type anotations, to avoid reflection?

dadair09:10:15

Define a protocol + extend for relevant types?

roti09:10:42

@dadair yes, that's probably the best solution. I was actually thinking about something along the lines of a static dispatch based on the type since it is known (=assumed) at compile time. but I suppose this needs to be a compiler provided construct.

raymcdermott11:10:22

have been messing around a bit more with the prepl and noticed that the outputs are sometimes still not readable

raymcdermott11:10:26

simple example

raymcdermott11:10:59

{:tag :ret, :val #object[clojure.lang.Namespace 0x7a9e38e4 "user"], :ns user, :ms 0, :form *ns*}

raymcdermott11:10:36

in this case #object will cause a reader exception (“No reader function for tag object”)

raymcdermott11:10:11

I have seen this in spec errors too

raymcdermott11:10:26

shall I raise a JIRA ticket?

alexmiller12:10:46

This is data and is readable (with an appropriate tagged literal reader).

raymcdermott12:10:33

fair enough - that is the approach I am taking

raymcdermott12:10:10

just so I know - as far as this output goes, you are saying that it’s expected behaviour?

alexmiller12:10:44

Last entry there might be interesting to you

raymcdermott12:10:15

yes, I noticed in my experiments that the vals of the unknown tags were generally readable

alexmiller12:10:56

They should always be readable

raymcdermott12:10:27

excellent - I didn’t know if that was generally the case

raymcdermott12:10:55

so is your hint at the bottom of the post a little bit of expectation setting?

alexmiller13:10:56

Just an idea we’ve kicked around

raymcdermott13:10:21

my 2c, I like having key / vals rather than a TaggedLiteral

raymcdermott13:10:22

but anything is better than exceptions

mfikes12:10:20

@raymcdermott Perhaps #clojure-dev

tristefigure12:10:05

I have a dilemma naming a function that works in a similar way to isa? except it also returns true when the record in question implements a protocol. Should I name it iskind? or looks-like? or something else ?

the2bears20:10:57

follows? might also work, at least for me protocols are something "to be followed" outside the programming realm.

noisesmith16:10:11

Clojure 1.9.0
+user=> (doc satisfies?)
-------------------------
clojure.core/satisfies?
([protocol x])
  Returns true if x satisfies the protocol
nil

tristefigure18:10:20

Thanks for the input, I'll go for "follows?", it's vague I like it, it fits well to that specific use-case. "implements?" would mix with java's jargon (typically, you extend a class and implement an interface).

the2bears20:10:25

Feeling so lucky I should buy a "Mega Millions" ticket 🙂

raymcdermott12:10:28

thanks @mfikes I will x-post

raymcdermott12:10:09

in the reply thread Alex explains that this is expected so no ticket - phew 🙂