Fork me on GitHub
#clojure-dev
<
2019-12-05
>
pyr08:12:18

Is it expected that satisfies? returns false for vals extending the protocol with metadata?

pyr08:12:15

Case in point:

(defprotocol A :extend-via-metadata true (a [this]))
(satisfies? A (with-meta {} {`a identity})) ;; => false

pyr08:12:28

but as expected:

pyr08:12:48

(a (with-meta {} {`a identity})) ;; => {}

orestis08:12:47

Shouldn’t the protocol opt-in to extension via metadata?

pyr08:12:06

@orestis you're right, my example misses that, fixed

pyr08:12:33

seem to cover it

pyr08:12:40

so it's considered as a fix

mpenet10:12:52

satisfies? is also quite slow

alexmiller14:12:24

there's a separate ticket for that

alexmiller14:12:42

on the downside, fixing CLJ-2426 will only hurt perf more

mpenet08:12:09

did you consider leaving the behavior of satisfies? as is and have a separate predicate for extended vals, like val-satisfies? which would be the slow, all encompassing version (checks any val, record included).

carocad17:12:15

quick question: is the syntax #^ for meta data deprecated ? I only found this commit for v1.2 to allow ^ for metadata but unfortunately the changes.md file goes up until v1.3 😅 https://github.com/clojure/clojure/commit/a5ca8243e3ea45e6387b2b00d0e9b2624d16adbf

bronsa17:12:42

#^ is a deprecated synonym of ^

carocad17:12:57

so this is “official” ? because I couldnt find anything stating it 😕

bronsa17:12:04

^ is the "preferred" way to do it now, but #^ is never going away or change

bronsa17:12:26

it's deprecated in the sense that ^ is equivalent and preferred to it

carocad17:12:02

:thumbsup::skin-tone-4:

carocad17:12:08

thanks a lot for the info

bronsa17:12:08

a long time ago ^ used to mean read-time meta and #^ was the way to do read time with-meta

dominicm17:12:31

There's some uses in the clojure source code still

dominicm17:12:50

(says the same thing as @bronsa )

mikerod17:12:43

@bronsa are there any cases where #^ supports more than ^?

mikerod17:12:47

at one point I thought there was something

mikerod17:12:04

like in the odder cases where you hint a string :tag or something?

bronsa17:12:42

no they're literally the same

bronsa17:12:21

you're thinking of something else

alexmiller18:12:04

^^ they both just invoke the MetaReader

andy.fingerhut18:12:44

I think some developers may have become accustomed to the idea that "deprecated" means "will likely go away in a future version" ? That does not seem to apply to Clojure, and not very often to Java.