-
Notifications
You must be signed in to change notification settings - Fork 4.9k
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
[API Proposal]: Rename INumber<T>.Create<TOther> to CreateNumber<TOther> #65921
Comments
I couldn't figure out the best area label to add to this issue. If you have write-permissions please help me learn by adding exactly one area label. |
Tagging subscribers to this area: @dotnet/area-system-numerics Issue DetailsBackground and motivationI am pleased with the Pattern established by INumber.Create which obviously allows to convert Values between different generic Implementations of INumber. But when applying two or more of this Pattern on the same Type, leads to a Name Clash. By renaming API Proposalnamespace System
{
public interface INumber<TSelf>
{
static abstract TSelf CreateNumber<TOther>(TOther other);
}
} API Usage public static T ConvertFrom<T, TN>(TN value)
where T : INumber<T>
where TN : INumber<TN> {
return T.CreateNumber(value);
} Alternative DesignsOf course you can also leave the Name ´Create´ but that makes it harder for future Developments. RisksSince the System.INumber API is not final yet, the change is unproblematic.
|
Thanks for the suggestion here. I agree that the potentially conflicting name here might be problematic and it's something I will raise with API review. |
The current proposal/implementation has the names as |
Background and motivation
I am pleased with the Pattern established by INumber.Create which obviously allows to convert Values between different generic Implementations of INumber.
But applying two or more of this Patterns (from different Interfaces than INumber< T>) on the same Type, easily leads to a Name Clash.
I therefore ask for a more descriptive Name that also conveys the Intention better.
By renaming
INumber<T>.Create<TOther>
toCreateNumber<TOther>
or even better:CreateNumberFrom<TOther>(other)
Conflicts are much less likely.API Proposal
API Usage
Alternative Designs
Of course you can also leave the Name ´Create´ but that makes it harder for future Developments.
In Fact, it is desirable to define additional new CreateXxx< TOther> Methods for smaller Sub-Interfaces of INumber< T> as proposed here.
Risks
Since the System.INumber API is not final yet, the change is unproblematic.
Since the Change will result in a Compile Error, it is very prominent and will not lead to hidden Problems.
The text was updated successfully, but these errors were encountered: