abstract-statics

Macros for abstract static methods + static method forwarding
https://github.com/c-g-dev/abstract-statics

To install, run:

haxelib install abstract-statics 1.0.0 

See using Haxelib in Haxelib documentation for more information.

README.md

(Haxe) abstract-statics

Abstract static method constraints + Forward static methods to children

The feature that everybody wants but no language ever implements. They will say stuff like "it doesn't make since with the way polymorphism works blah blah blah dogmatist garbage blah blah blah". Well here it is you dumb liars -- simple and easy.

Installation

haxelib install abstract-statics

Usage

Abstract static methods

//force implementation to have static method named parse
@:build(EnableAbstractStatic.build())
interface TestInterface {
    @:abstractStatic 
    public function parse(s:String):Int; //annotate with @:abstractStatic (don't make this method static)
}


class TestImplementationA implements TestInterface {} //compiler error

class TestImplementationB implements TestInterface { 
    public static function parse(s:String):Int { //success
        return Std.parseInt(s);
    }
}

Forward static method to children

 //unfortunately need both build and autoBuild
@:build(EnableForwardStatic.build())
@:autoBuild(EnableForwardStatic.build())
class TestParent {
    @:forwardStatic 
    public static function parse(s:String):Int {
        return Std.parseInt(s);
    }
}


class TestChild extends TestParent {}

trace(TestChild.parse("123")); //success!
Contributors
cgdev
Version
1.0.0
Published
1 year ago
License
MIT

All libraries are free

Every month, more than a thousand developers use Haxelib to find, share, and reuse code — and assemble it in powerful new ways. Enjoy Haxe; It is great!

Explore Haxe

Haxe Manual

Haxe Code Cookbook

Haxe API documentation

You can try Haxe in the browser! try.haxe.org

Join us on GitHub!

Haxe is being developed on GitHub. Feel free to contribute or report issues to our projects.

Haxe on GitHub