Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This function makes a good-faith effort to mutate, but provides no guarantee. That's unlike
freeze!
, and unlike Base functions, which guarantee they will mutate. There's some convention that!!
means this, e.g. from https://github.com/JuliaFolds/BangBang.jl, so this PR renames it.Doing so opens the door to having a new
update!
in v0.3 which does guarantee to mutate, else fails with an error.That would be nice for Flux, where otherwise there's an awkward transition: v0.13's Flux.Optimise assumes everything mutates. If you upgrade to Optimisers.jl's
update!
, and discard what it returns, your model will work fine right now as all old models are mutable. But it will also now silently ignore and new immutable parameters. We can't check that you didn't discard the output.Doing this also opens the door to simplifying the interface. There is no need for
update!
to return the state tree, since this is sure to be mutated. And it's confusing to return two things & have to know the order. So perhaps it should return only the model? Or will it be too confusing compared toupdate
which must return both?The must-mutate
update!
could returnnothing
, to emphasise its difference. Code which goesmodel, tree = update!(...)
will fail loudly and clearly withnothing
. It may fail in very strange ways if this returns only the model. That's a reason to have 0 or 2 returns, never 1.