-
-
Save ds300/e999180e504c81bae0f3 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
; So given this: | |
(def cellcell (cell (cell 5))) | |
; My question boils down to whether there is any way to make a cell which | |
; contains the value of the inner cell of cellcell regardless of whether we do | |
; things like | |
(reset! cellcell (cell 10)) | |
; or | |
(reset! @cellcell 15) | |
; the naive thing is | |
(def value (cell= @cellcell)) | |
; but that doesn't work for the latter case because only cellcell is | |
; hooked up to the propagation graph. | |
; So by 'Can formula cells have dynamic set of inputs?' I mean: | |
; Can the propagation graph structure be influenced by the contents of cells? | |
; Or is it fixed at the point when the 'lifted' functions returned by `formula` | |
; are invoked? |
Will WeakMap and its polyfills help us?
@ul sadly no... WeakMap is only really suitable for caching, or similar scenarios where the consumer supplies the key. Since they're not iterable, they're not suitable for general weak storage, which is how we would want to use them - to store a weak collection cell references that could be iterated through. WeakReference really is the thing we want, since we could make them values in our priority map, and the propagator could discard entries nulled by the GC.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
That's right. If we had weak references, the JavaScript GC could deem such cells unreachable/immutable for us, and formulas would be collected automatically. Unfortunately, it doesn't look like JavaScript will get them anytime soon, if ever.