I’d like to have the possibility to override basic operations as following
a = b + c
operator fun addition(a: Vec2, b: Vec2): Vec2 {
x = a.x + b.x
y = a.y + b.y
return this;
}
in order to save result in a
without creating any intermediate garbage result…
According to Perry Nguyen, this is possible in Scala:
[quote=“Perry Nguyen, post:6, topic:2007, full:true”]it would end up being something like a := b / c, where := would be defined as def :=(ops: Vec2Op) = a.append(ops.calculate)
and b / c
would evaluate as a Vec2Op
[/quote]