elect
03/16/2018, 10:57 AMVec3t<Number>
implemented as Float
, Int
, etc..
Of course methods differing only for a different type (i.e: dot(v: Vec3t<Number>)
and dot(v: Vec3t<Float>)
) have the same signature, but if I try to call:
val vert = Vec3() // Vert3 : Vec3t<Float>
vert.dot(fromTo) // error, none of the following functions can be called. Note that dot is dot(v: Vec3t<Number>)
I have to either change dot
to dot(v: Vec3t<Float>)
or create a new set of interfaces, where I have Vec3tNumber
and Vec3tFloat
and so on..
What do you think?Andreas Sinz
03/16/2018, 11:03 AMinterface Vec3t
?elect
03/16/2018, 11:05 AMAndreas Sinz
03/16/2018, 11:12 AMT
but you are actually using Number
everywhere. Is there a specific reason for that?elect
03/16/2018, 11:23 AMAndreas Sinz
03/16/2018, 11:59 AMelect
03/16/2018, 12:03 PMAndreas Sinz
03/16/2018, 12:34 PMplus
, minus
etcabstract class Vec3t<T: Number>(...) {
abstract protected inline fun createInstance(): Vec3t<T>
operator fun plus(t: T) = plus(createInstance(), this, t, t, t)
operator fun plus(t: Vec3t<T>) = plus(createInstance(), this, t.x, t.y, t.z)
}
createInstance
inside your Vec3i
and you get plus operator for freeelect
03/16/2018, 5:51 PM"inline" modifier is not allowed on virtual members
Andreas Sinz
03/16/2018, 6:09 PMinline
from createInstance
, its not needed