COMMUNITY

How to use abstract Operator Overloading with extern together?

there are some condition I want to use abstract and extern together

like this

var v1=new Point(1,1);
var v2=new Point(0,0);;
var v3=v2-v1;//here I have confusing how to implement with extern class

extern class Point

{
@:overload(function (values:Array) : Void{})
@:overload(function (object:Dynamic) : Void{})
@:overload(function (size:Size) : Void{})
@:overload(function (point:Point) : Void{})
function new(x:Float, y:Float) : Void;
}

here I know we can write another abstarct class for Operator Overloading,

Operator Overloading

but how to use

@:overload in abstract class ?

Unfortunately, Haxe doesn’t support operator overloading for classes, even for extern, so you’ll have to go with an additional abstract. Here’s how I do it in hxdefold: https://github.com/hxdefold/hxdefold/blob/master/src/defold/types/Vector3.hx