Draft
Conversation
schillic
reviewed
Mar 31, 2026
Member
schillic
left a comment
There was a problem hiding this comment.
Amazing! I know this is marked as a draft, but I already had a look. Currently, this PR is a perfect refactoring (with one exception, see my comment below).
Comment on lines
-67
to
+74
| if length(args) > 1 && @capture(args[2], x ∈ X_) | ||
| return Expr(:call, ConstrainedIdentityMap, esc(:($(dimension))), esc(:($(X)))) | ||
| else | ||
| return Expr(:call, IdentityMap, esc(:($(dimension)))) | ||
| if length(args) > 1 | ||
| X = @match args[2] begin | ||
| :($_ ∈ $X) => X | ||
| _ => nothing | ||
| end | ||
| if X !== nothing | ||
| return Expr(:call, ConstrainedIdentityMap, esc(:($(dimension))), esc(:($(X)))) | ||
| end |
Member
There was a problem hiding this comment.
This is different from the old code, which required that the constrained variable is called x. I think some cases are better now. Other cases should have been throwing an error. But this would require a more fundamental change. So I am fine with that new behavior.
julia> X = 5;
# master: ignores `y` as variable in constraint
julia> @map(y -> y, dim=2, y ∈ X)
IdentityMap(2)
julia> @map(x -> x, dim=2, y ∈ X)
IdentityMap(2)
# this branch
julia> @map(y -> y, dim=2, y ∈ X) # accepts `y` as variable
ConstrainedIdentityMap{Int64}(2, 5)
julia> @map(x -> x, dim=2, y ∈ X) # misses non-matching variable name
ConstrainedIdentityMap{Int64}(2, 5)
Comment on lines
+164
to
+165
| # like `:($lhs = $rhs)` match both `dim = 3` (parenthesized macro call, parsed | ||
| # as :kw) and `dim = 3` (unparenthesized, parsed as :(=)). |
Member
There was a problem hiding this comment.
The two occurrences of dim = 3 are identical. Did you mean something else?
| else | ||
| @match ex begin | ||
| :($x(0) ∈ $X0) => begin # COV_EXCL_LINE | ||
| # TODO? handle equality |
Member
There was a problem hiding this comment.
Suggested change
| # TODO? handle equality | |
| # TODO handle equality (x(0) = x0)? |
| @capture(expr[2], x_(0) ∈ x0_) || throw(ArgumentError("malformed epxpression")) # TODO handle equality | ||
| x0 = @match expr[2] begin | ||
| :($x(0) ∈ $X0) => X0 | ||
| _ => throw(ArgumentError("malformed epxpression")) # TODO handle equality |
Member
There was a problem hiding this comment.
Suggested change
| _ => throw(ArgumentError("malformed epxpression")) # TODO handle equality | |
| _ => throw(ArgumentError("malformed epxpression")) # TODO handle equality (x(0) = x0)? |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
No description provided.