You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
For operator overloading, I think we could be like Rust and define traits for each operation (addition, etc.). Then types (probably just enum types) can implement traits. Traits can also have default implementations for values, and they can be used as types.
For example,
// Will probably be pre-defined by N (ie built in)traitAdd[this]{
add : this -> this -> this
}typevec2 = <vec2 float float>
implement Add[vec2]{add = [<vec2 x1 y1>:vec2<vec2 x2 y2>:vec2] -> vec2{return(x1 + x2, y1 + y2)}}print(vec2(1,2) + vec2(3,4))// vec2(3, 6)
This proposal needs more fleshing out before being implemented, hence "N Next"
The text was updated successfully, but these errors were encountered:
For operator overloading, I think we could be like Rust and define traits for each operation (addition, etc.). Then types (probably just enum types) can implement traits. Traits can also have default implementations for values, and they can be used as types.
For example,
This proposal needs more fleshing out before being implemented, hence "N Next"
The text was updated successfully, but these errors were encountered: