cljs-dev

Roman Liutikov 2025-10-15T14:16:42.426459Z

@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")

p-himik 2025-10-15T14:18:19.751449Z

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

borkdude 2025-10-15T14:18:30.589609Z

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

p-himik 2025-10-15T14:18:47.058709Z

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

Roman Liutikov 2025-10-15T14:21:41.406919Z

@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

borkdude 2025-10-15T14:26:57.987509Z

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?

dnolen 2025-10-15T14:45:16.763359Z

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

dnolen 2025-10-15T14:45:52.018639Z

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/

dnolen 2025-10-15T14:46:06.579969Z

perf sensitive code would have used implements?

Roman Liutikov 2025-10-15T15:04:55.107259Z

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

dnolen 2025-10-15T15:19:03.115479Z

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

dnolen 2025-10-15T15:19:44.583029Z

we have simple things but that would be great to generalize

dnolen 2025-10-15T15:21:03.740069Z

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

Roman Liutikov 2025-10-15T15:59:55.612079Z

you mean some? ?

dnolen 2025-10-15T17:51:01.558839Z

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

👍 1
Roman Liutikov 2025-10-15T18:03:17.740289Z

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

dnolen 2025-10-15T18:57:09.108959Z

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
dnolen 2025-10-15T18:57:28.176239Z

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