Join GitHub today
GitHub is home to over 20 million developers working together to host and review code, manage projects, and build software together.
do not cache function sets #16
The problem is that if you create multiple sets then each time you create a new one crdt checks whether it has it already.
The problem is that with filter functions there is no notion of "has it already" where as with createSet("key", "value") there is. With the latter it's save to just return the set because it contains the same thing.
WIth a filter function it's not save to cache or return a cached set. This is because there is no way to translate a function into the set of items it contains. A pure function could be translated but an impure function can't be cached.
The way the current implementation in this PR fixes this issue is by simply not caching sets which are defined by functions
@dominictarr impure means "when given same inputs as arguments to function does not produce same outputs".
Which means it has state basically.
The fact that it may cause a side effect but always return same output is an example of an impure function that's safe to cache but that doesn't matter because it's not safe to cache all functions.