Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

#162 #145 #165 - add macro to restore old array type behavior #236

Merged
merged 6 commits into from
Feb 24, 2018

Conversation

schillic
Copy link
Member

@schillic schillic commented Feb 11, 2018

Closes #162 and closes #145 and closes #165.

@schillic schillic changed the title [WIP #162] add macro to restore old array type behavior #162 - add macro to restore old array type behavior Feb 12, 2018
@schillic schillic requested a review from mforets February 12, 2018 21:26
@schillic schillic changed the title #162 - add macro to restore old array type behavior #162 #145 - add macro to restore old array type behavior Feb 12, 2018
@schillic schillic added this to the v1.2.0 milestone Feb 13, 2018
@schillic schillic changed the title #162 #145 - add macro to restore old array type behavior #162 #145 #165 - add macro to restore old array type behavior Feb 13, 2018
@mforets
Copy link
Member

mforets commented Feb 20, 2018

i fail to see what is the logic for these blocks:

...
        # if the array set type has already been defined, create combinations
        if isdefined(:array_constructor) &&
                method_exists(array_constructor, (Type{$SET},))
            @eval(@array_neutral($(esc(SET)),
                                 $(esc(NEUT)),
                                 array_constructor($(esc(SET)))))
        elseif isdefined(:is_array_constructor) &&
                method_exists(is_array_constructor, (Type{$SET},))
            @eval(@array_neutral($(esc(SET)),
                                 $(esc(NEUT)),
                                 $(esc(SET))))
        end

why is there an if clause? what is the difference between array_constructor and is_array_constructor?

@schillic
Copy link
Member Author

schillic commented Feb 20, 2018

This is needed so that you can use the macros @neutral, @absorbing and @declare_array_version in any order. The if clauses make sure that the functions are defined only once.
array_constructor(MinkowskiSum) == MinkowskiSumArray
is_array_constructor(MinkowskiSum) == false, and is_array_constructor(MinkowskiSumArray) == true

@mforets
Copy link
Member

mforets commented Feb 24, 2018

This is needed so that you can use the macros @neutral, @Absorbing and @declare_array_version in any order.

ok

The if clauses make sure that the functions are defined only once.

i guess my confusion arises from the fact that both array_constructor and is_array_constructor are defined in the same place (declare_array_version). how is that we have two @eval's? isn't it used only the first one? thanks

@schillic
Copy link
Member Author

Okay, I admit that it is overengineered :)

We have @neutral two times, once for the normal type and once for the array type.

@neutral(MinkowskiSum, ZeroSet)
@neutral(MinkowskiSumArray, ZeroSet)

Those calls to the macro should have a slightly different behavior. I use the two functions to detect which one.

Copy link
Member

@mforets mforets left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

alright, thanks for the details!

@schillic schillic merged commit debde7d into master Feb 24, 2018
@schillic schillic deleted the schillic/162 branch February 24, 2018 21:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants