Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
switch on/off deprecation warning on running.
Yuichi Motoyama 2015
This is distributed under the Boost Software License Version 1.0
@enum DepwarnFlag DepwarnOff=0 DepwarnOn=1 DepwarnError=2
- `switch_depwarn!(flag :: Bool)`
- `switch_depwarn!(flag :: DepwarnFlag)`
Enable/Disable deprecation warning.
- `DepwarnOff` or `false` : switch off deprecation warning
- `DepwarnOn` or `true` : switch on deprecation warning
- `DepwarnError` : turn deprecation warning into error
switch_depwarn!(flag :: Bool) = switch_depwarn!(flag ? DepwarnOn : DepwarnOff)
function switch_depwarn!(flag :: DepwarnFlag)
old_opt = Base.JLOptions()
params = map(fieldnames(Base.JLOptions)) do name
name == :depwarn ? Int(flag) : getfield(old_opt, name)
new_opt = Base.JLOptions(params...)
unsafe_store!(cglobal(:jl_options, Base.JLOptions), new_opt)
# one-liner
# unsafe_store!(cglobal(:jl_options, Base.JLOptions), Base.JLOptions(map(fieldnames(Base.JLOptions)) do name; name==:depwarn?0:getfield(Base.JLOptions(), name) end...))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment