Base.Cartesian: add @ncallkw
and allow else
branch inside if
#51501
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 PR makes two changes to
Base.Cartesian
. Let me know if you prefer to have them separate.Allow
else
branch insideif
Currently, the following gives an error:
The reason is that the function
exprresolve
that tries to constant-evaluate expressions assumes thatif
statements always have anelse
branch. The PR fixes this.(I actually think that many of the simplifications done by
exprresolve
would otherwise be done by the compiler, including the deletion of dead branches. The only exception seems to be the evaluation of constant array references. With tuples instead of arrays, this could also be handled by the compiler.)New macro
@ncallkw
This is like
@ncall
except for adding keyword arguments. This way you don't have to define a helper function to use keyword arguments. The keywords are given as the first macro argument as inMaybe you see a better approach. I've also tried to make
@ncall
call@ncallkw
internally, but that caused problems during bootstrapping.