VOID Language operators

Operators that compose.
Generic math without runtime magic.

VOID completes user-defined unary and binary operators through its normal overload/conversion machinery, then carries those contracts into static interfaces and constrained generic code that specializes to ordinary concrete operations.

Completed operator foundation

One operator model from concrete types to constrained generics.

Concrete operator declarations, static-interface requirements, constrained generic dispatch, compound targets, nullable/value interaction, and iterator lowering all reuse existing semantic binding. The compiler does not introduce a runtime generic operator dispatcher.

Unary operators

User-defined unary operators participate in normal overload/type resolution across classes and structs, with conversions, generics, nullable interaction where applicable, and focused diagnostics.

Binary operators

User-defined arithmetic, comparison, equality, and relevant compound-operation paths share normal conversion ranking and overload resolution instead of separate operator-specific rules.

Static interface contracts

Interfaces can require supported static operators. Implementing types are validated through the same static-interface contract system used by other static members.

Constrained generic dispatch

A generic method constrained by an operator-bearing interface can use that operator through T. Monomorphization resolves the operation to the concrete implementation.

Iterator-safe provenance

When constrained generic locals are promoted into iterator state-machine fields, VOID preserves their generic origin and constraint metadata so operator legality survives suspension and resume.

Stable diagnostics

User-facing diagnostics describe the language rule or invalid construct itself rather than exposing historical internal milestone labels.

Semantic ownership

Generic operators are proven before code generation.

Static-interface operator constraints authorize the operation in generic source. Specialization then lowers that already-valid operation to the concrete operator. Iterator and closure transformations preserve the semantic provenance instead of asking later stages to rediscover why the operation was legal.

Constrained operator across yield
public static IEnumerable<T> Accumulate<T>(T sum, T other)
    where T : IAdd<T>
{
    yield return sum;
    sum += other;
    yield return sum;
}
Static interface operator contract
public interface IAdd<T>
{
    static T operator +(T left, T right);
}

public static T Add<T>(T left, T right)
    where T : IAdd<T>
{
    return left + right;
}
Concrete operators
public struct Int2
{
    public int X;
    public int Y;

    public static Int2 operator +(Int2 left, Int2 right)
    {
        return new Int2 { X = left.X + right.X, Y = left.Y + right.Y };
    }

    public static Int2 operator -(Int2 value)
    {
        return new Int2 { X = -value.X, Y = -value.Y };
    }
}