Hi All,
I like the recently introduced ScopedValue
type, but found myself wanting to be able to change it’s default value persistently outside of ScopedValues.with
calls.
An example for this is that in GitHub - JuliaPluto/PlutoPlotly.jl I default to converting all numbers to Float32 to speed up and reduce memory of the generated plot objects, but I want to have a flag to be able to potentially disable this behavior when higher precision is needed. (e.g. this issue Large integers are truncated · Issue #61 · JuliaPluto/PlutoPlotly.jl · GitHub)
I thought I could achieve this by combining a RefValue
and a ScopedValue
toghther in a single type and make it behave the way I want it (i.e. act in most situation as a ScopedValue
but allow o change its default value persistently).
I put my attempt into this very small package:
and I wanted to get feedback on whether:
- There is already a way to achieve this either built in or via other existing packages
- What I am doing in that package is either broken, unsafe or wrong in any other way