Compute next argument on declaration #16
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.
Resolves #12
Now parameter arguments are no longer iterated between
parameterize
iterations, and always occur during, when the parameter is re-declared.This change makes argument iterator
next
calls consistent between the first declaration (which callsnext
during theparameterize
iteration), and all subsequent calls (which, before this commit, would occur betweenparameterize
iterations). This makes debugging argument issues more intuitive, enables performance profiling to highlight specific parameter properties if argument computation is slow, and lets exception call stacks trace through the call site with relevant stack frame context. None of this is possible when argument iteration is queued up and done separately behind the scenes outside ofparameterize
iterations.This change also makes the implementation easier because the arguments don't actually have to be queued up to be iterated. The logic that moves the parameters to the next argument combination was removed, instead storing the last parameter with more arguments, so that it can be changed to the next argument during the following
parameterize
iteration. This also means that theparameterize
while loop condition can be factored out and checked without side effects, in addition to the break early logic. So, nowstartNextIteration
contains all the state-changing code, and simply sets a few variables.This is a backwards-compatible change, since all code should still behave the same. Since parameters are still iterated in the same order (now it's just during the iteration), dependence between parameters isn't an issue. Since parameter iterators shouldn't have side effects, the fact argument iterating is spaced out (through a
parameterize
iteration) shouldn't make a difference. Argument iterators with side effects could have changed behavior, e.g. if an argument iterator modifies global state, it previously happened before theblock
was invoked, but now would happen during, potentially after a statement that depends on it. However, argument iterators with side effects are specifically unsupported according to theparameter(lazyArguments)
documentation, so this isn't an issue.