-
Notifications
You must be signed in to change notification settings - Fork 1k
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
[Proposal] where expression #3701
Comments
Seems like something better solved by Shapes (#164). |
How about a little something different here cause I sorta like this... public class Foo {
public static T add<T> (T a, T b) where T : [virtual] operator(+, -, *, /, %)
return a + b;
}
}
public class Foo1 {
public static T opera<T> (T a, T b) where [virtual] operator(+, -, *, /, %)
return a + b;
}
} (the virtual can be committed and indicated derives is allowed, in or out would probably be used for that.) public class Foo {
public static T add<out T> (T a, T b) where T : operator(+, -, *, /, %)
return a + b;
}
}
public class Foo1 {
public static T opera<in T> (T a, T b) where T : operator(+, -, *, /, %)
return a + b;
}
} Beats something liek this maybe: |
Or Roles right? Definitely note Records :P |
@juliusfriedman how to recognition |
It is recommended to add a WHERE expression. The purpose of the new expression is to allow an expression in the constraint operator to be evaluated as a value.Like the usual operator (+-*/%)
Existing problem: There is no constraint that can directly make T type do mathematical operation, so it must be cast to dynamic, but cast or method directly accept dynamic type, which may make the type that cannot do mathematical operation can also be passed as a parameter, unable to check the code statically
the proposal can fix this problem
The text was updated successfully, but these errors were encountered: