-
Notifications
You must be signed in to change notification settings - Fork 424
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
Should the compiler be able to infer implied operations? #17200
Comments
My overarching philosophy on this question is that it would be nice for the compiler to help with such cases if it felt sufficiently like a "no brainer". Where I think the criteria for no-brainer are: (1) there isn't any significant overhead or downside introduced via the compiler-provided rewrite; (2) it doesn't increase the confusion for the type author or user; (3) it helps relieve pain on the type author's part by preventing them from thinking "Oh man, I can't believe I'm stamping out this pattern again to achieve all 4 tiers of conversions." For me, the |
thanks @bradcray . I'm just noting here that @bradcray and @lydia-duncan expressed support for automatically using |
This part came up in the List module review meeting in trying to answer Michael's design question here: https://github.com/Cray/chapel-private/issues/1451 Currently we can write both |
Issue #17199 discusses how we might like to not have to write both |
This issue is a spin-off from issue #15838.
We have an idea that conversions between types come in 4 levels and a programmer should be able to access any of these 4 levels, but the higher levels imply the lower ones.
Additionally even for the same type, we have the property that assign implies that an init= is available (because some of the assigns will convert to initialization according to split init).
PR #17092 makes it a compilation error to have an init= function with a different RHS type unless there is also a cast function. PR #14956 made it an error to have an assignment function without a corresponding = function (or vice versa).
We made these cases into compilation errors partly under the argument that inferring any implied operations from the operations provided would not be a breaking change.
Should we relax one or more of these cases?
In particular:
init=
to implement cast between typesIt would also be possible for the compiler to infer assign from init= (by deiniting the LHS and then moving in the result of init=). This case is slightly different though because it would not be an error according to the above rules to have init= but not assign and in fact we expect that such a behavior is useful in some cases (possibly with sync variables).
The text was updated successfully, but these errors were encountered: