latexify_py icon indicating copy to clipboard operation
latexify_py copied to clipboard

[add] config

Open chunibyo-wly opened this issue 3 years ago • 1 comments

But I don't know why we need to freeze a config object? It's looked weired forcing use merge to update configuration?

chunibyo-wly avatar Nov 14 '22 17:11 chunibyo-wly

Ref: #66

@chunibyo-wly Thanks!

Just a comment about "why we need to freeze": it is basically because immutability keeps ease of maintenance and reproduction. Always generating a fresh struct keeps the entire library unchaged, i.e., we can guarantee latexify.function has no side effect and we could get exactly the same result every time we called latexify.function even it is invoked from multiple threads. Immutability is also applied in the entire process of this library, especially tree transformation chains in get_latex: all transformers always return a new AST (with references to possibly old subtrees for efficiency).

We may add some functionality to override the "global" config in the future. This kind of functionality should be explicitly mentioned that "invoking this method causes side effect and not thread safe."

odashi avatar Nov 14 '22 18:11 odashi

By the way, there are several pull requests that may affect config so there would be some collisions when merging. I guess it is better to merge this pull request first, and request others to merge main after merging this one.

odashi avatar Nov 16 '22 22:11 odashi

@chunibyo-wly Hi, I like this change, and would like to merge it soon! If you could resolve the comments above, I'd really appreciate it.

odashi avatar Nov 21 '22 00:11 odashi

sorry, I forgot to check my email

chunibyo-wly avatar Nov 21 '22 04:11 chunibyo-wly

@ZibingZhang ~Yeah, but it could be processed after merging this PR.~ We need to apply the change (because it affects the interface of get_latex.

odashi avatar Nov 21 '22 23:11 odashi

I applied a monkey patch to remain expand_functions as is to merge this PR. After fixing the linter error I will merge it.

odashi avatar Nov 21 '22 23:11 odashi

@chunibyo-wly Thanks for your work! I think this is a very important change for this repository.

odashi avatar Nov 21 '22 23:11 odashi