ordered icon indicating copy to clipboard operation
ordered copied to clipboard

Use private not-found var

Open NoahTheDuke opened this issue 3 years ago • 2 comments
trafficstars

Problem: When determining if a key exists in the backing map, we rely on matching the value against :flatland.ordered.map/not-found, which probably won't be in backing map but could. By relying on a derivable value, hard to discover bugs can sneak in.

Potential solutions:

  1. Leave as-is. Easiest, probably won't break anything.
  2. Use a more complicated keyword. Further decreases the likelihood of a match.
  3. Create a gensym within the function. Impossible to derive, but requires creation on every call which is slow.
  4. Create a private var that holds a stable gensym. Impossible to derive, quite fast.
  5. Create a private Java Object. Impossible to derive, quite fast, less meaningful than gensym.

Chosen solution: I went with 4, which combines the meaningful information of the original namespaced keyword with a unique gensym symbol.

NoahTheDuke avatar Dec 20 '21 15:12 NoahTheDuke

I'm not the official maintainer. But... I think it would be good if you provided: 1) a problem statement, 2) suggestion of how to solve the problem (+ alternatives), 3) a patch, 4) a test which protects against future regressions of the issue stated in 1).

borkdude avatar Dec 20 '21 15:12 borkdude

Sure! The patch is covered by this PR (I don't see anything in this repo or in the meta repo about using a clojure.core patch set up), but I can provide more information as desired.

NoahTheDuke avatar Dec 20 '21 16:12 NoahTheDuke