Anders429 / word_filter

A Word Filter for filtering text.
Apache License 2.0
1 stars 0 forks source link

Mutability #2

Closed Anders429 closed 3 years ago

Anders429 commented 3 years ago

As it stands now, WordFilter is an immutable structure, only being created once and statically the same forever after.

There is a possibility of allowing WordFilters to be mutated after creation. New matches and exceptions could be added onto root after having all current aliases applied to them. New aliases could be applied onto root and other aliases (and merged aliases could be created from them and applied similarly). New separators could be added to the separator root node. Even new Options could be provided, as each option is only used at query time. Ultimately, all of these things could combine to support a merge method, merging two WordFilters, although the semantics for handling Options in that case is unclear.

Removal may also be supportable, although much more complicated. Removing words and exceptions would involve traversing the tree and unsetting the node. Removing an alias or separator would be similar, simply removing the Return node.

This approach will support the use of standardized WordFilter implementations, allowing users the ability to modify them to their liking.

Anders429 commented 3 years ago

Dropping this, as it is superseded by the progress in #37. Static construction at the const of mutability is a good tradeoff. Most users won't want to mutate after construction anyway, and this allows construction to be done at compile time, which is great considering that construction has high temporal complexity.