cljs-dev 2025-10-15

@dnolen what do you think about folding satisfies? checks to constants, using existing type inference facilities? with this patch something like

(let [v [1 2 3]]
  (when (satisfies? IIndexed v)
    (js/console.log "here")))
compiles into (js/console.log "here")

Can you not change that in run-time, conditionally?

Is this a realistic scenario? When you you’re dealing with a vec why would the user write that satisfies check

Ah, I suppose you cannot un-extend a type/protocol.

@borkdude function calls carry return tags, so say that (do-stuff) has a return tag of cljs.core/IVector, this info can be used to optimize satisfies? check that can happens down the line

Still seems unlikely to me, usually you still know you’re dealing with a vector or whatever. Or did you into this with real code?

It does feel a bit artificial? Something more concrete would help understand how this would help in actual programs

It's also a little bit odd since the presence of satisifies? implies code that wants to handle custom extensions to primitive types - which is never that fast to begin w/

perf sensitive code would have used implements?

ah, I never remember difference between satisfies? and implements? my intention was to optimize core predicates that use satisifies? (or implements?), but that would also require forward type propagation which we don't have, so probably not worth it

oh that is some we do want in general - push information into branches after predicates

we have simple things but that would be great to generalize

I think satisfies? is tough, but not implements? it would also be useful in the case of some where we know something is not nil - though that's less about perf

you mean some? ?

sorry, yeah I just mean anything that depends on non-nil

👍 1

Got it, I’ll take a look then at both some? and implements?

really it is any nil test, i.e. seq and nil? should have the same behavior w/ predicates wrt. what you know in the branch

👍 1

(not the specific branch but how they push forward information)