-
Notifications
You must be signed in to change notification settings - Fork 4
Open
Labels
enhancementNew feature or requestNew feature or requesthelp wantedExtra attention is neededExtra attention is needed
Milestone
Description
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)
trait Add[this] {
add : this -> this -> this
}
type vec2 = <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"
Metadata
Metadata
Assignees
Labels
enhancementNew feature or requestNew feature or requesthelp wantedExtra attention is neededExtra attention is needed