Improve type stability of dynamic branching #1106
Merged
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.
Summary
This PR improves the type stability of dynamic branching. It changes the return values from
group()
dynamic targets and fromreadd()
, so this is technically a breaking change. However, dynamic branching is still new and this change is important enough that a little discomfort is worth it in the end. Type stability is too important, as I discuss in #1087 (comment) and #1105 (comment).Previously,
readd()
always returned a list for dynamic targets, as I demonstrated in #1105 (comment). Now, it returns the result ofvec_c()
which respects the types of the sub-targets.Created on 2019-12-10 by the reprex package (v0.3.0)
Similarly,
group()
'ed dynamic dependencies were always lists before. Now, they respect the types of the sub-targets.Created on 2019-12-10 by the reprex package (v0.3.0)
In some ways, we need to be more careful about how we aggregate targets.
drake
will no longer automatically compartmentalize sub-targets in lists for us. When we aggregate sub-targets, we may get a value we do not expect (i.e. an unexpectedly long vector) but I think this PR is still the right way to go.Created on 2019-12-10 by the reprex package (v0.3.0)
Related GitHub issues and pull requests
Checklist
drake
's code of conduct.testthat
unit tests totests/testthat
for any new functionality.