3 ms·
A better example of what I'm thinking (assuming these interfaces are in java.lang to allow for safe operator overloading): interface Summable { sta
by yarg 4y ago
A better example of what I'm thinking (assuming these interfaces are in java.lang to allow for safe operator overloading):
interface Summable {
static This sum(This v0, This v1);
}
interface Subtractable {
static This difference(This v0, This v1);
}
interface Divisible {
static This quotient(This v0, This v1);
}
interface Mulitiplicable {
static This product(This v0, This v1);
}
interface Number extends Summable, Subtractable, Divisible, Multiplicable;
void <N extends Number> doThings(N v0, N v1){
N sum = v0 + v1;
}
- evntdrvn 4y agoThe .NET team just added static interface members in C# 11, because they themselves had this need in order to create System.Numerics: https://learn.microsoft.com/en-us/dotnet/csharp/whats-new/tutorials/static-virtual-interface-members https://learn.microsoft.com/en-us/dotnet/csharp/whats-new/tu... https://learn.microsoft.com/en-us/dotnet/api/system.numerics?view=net-7.0#interfaces https://learn.microsoft.com/en-us/dotnet/api/system.numerics...