{"id":16696768,"url":"https://github.com/atry/hoo","last_synced_at":"2026-02-02T20:07:01.598Z","repository":{"id":6266730,"uuid":"7500042","full_name":"Atry/hoo","owner":"Atry","description":"Haxe Operator Overloading","archived":false,"fork":false,"pushed_at":"2023-02-03T01:09:03.000Z","size":36,"stargazers_count":15,"open_issues_count":0,"forks_count":1,"subscribers_count":6,"default_branch":"master","last_synced_at":"2025-01-20T22:13:14.776Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Haxe","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Atry.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2013-01-08T10:57:04.000Z","updated_at":"2023-02-03T01:09:07.000Z","dependencies_parsed_at":"2023-02-18T02:01:20.483Z","dependency_job_id":null,"html_url":"https://github.com/Atry/hoo","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Atry%2Fhoo","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Atry%2Fhoo/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Atry%2Fhoo/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Atry%2Fhoo/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Atry","download_url":"https://codeload.github.com/Atry/hoo/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243515567,"owners_count":20303258,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-10-12T17:44:46.004Z","updated_at":"2026-02-02T20:07:01.553Z","avatar_url":"https://github.com/Atry.png","language":"Haxe","funding_links":[],"categories":[],"sub_categories":[],"readme":"Hoo\n=================\n\n**Haxe Operator Overloading** (\u003cwbr/\u003e**Hoo**), is a library that enables [operator overloading](https://en.wikipedia.org/wiki/Operator_overloading)\nfor [Haxe](http://www.haxe.org/).\n\nHoo has built-in overloaded operators for `haxe.Int64`. Here's an example:\n\n    var i64 = Int64.ofInt(123456789);\n\n    // Output: 12345678900000123\n    trace(i64 * 100000000 + 123);\n\n## Installation\n\nI have uploaded Hoo to [haxelib](http://lib.haxe.org/p/hoo). To install it, run\nthis in the shell:\n\n    haxelib install hoo\n\nNow you can use Hoo in your code.\n\nYou can compile to JavaScript:\n\n    haxe -lib hoo -main Your.hx -js your-output.js\n\n, or SWF:\n\n    haxe -lib hoo -main Your.hx -swf your-output.swf\n\n, or any other platform that Haxe supports.\n\nNote that Hoo requires Haxe 2.10.\n\n## Usage\n\nIn the following example, we'll overload the concatenation operator for Arrays.\n\n### Step 1: Enable operator overloading\n\nCreate `Sample.hx` with the following content:\n\n    @:build(com.dongxiguo.hoo.OperatorOverloading.enableByMeta(\":hoo\"))\n    class Sample\n    {\n      @:hoo public static function main()\n      {\n        var stringArray = [\"H\", \"el\", \"lo, \"] + [ \"Wo\", \"rld!\" ];\n        trace(stringArray.join(\"\"));\n      }\n    }\n\nTo enable operator overloading, you must add `@:build(com.dongxiguo.hoo.OperatorOverloading.enableByMeta(\":hoo\"))`\nfor classes that use overloaded operators, and add `@:hoo` for methods that use overloaded operators.\n\nThe operator `+` will be replaced to a function call to `evaluate`.\nIf you compile `Sample.hx`, Haxe will complain that it cannot find the field `evaluate`.\n\n### Step 2: Implement the overloading function\n\nCreate `ArrayConcatenationEvaluator.hx` with the following content:\n\n    import com.dongxiguo.hoo.selector.BinaryOperatorSelector;\n    import com.dongxiguo.hoo.selector.binopTag.AddTag;\n    class ArrayConcatenationEvaluator\n    {\n      public static function evaluate\u003cT\u003e(\n        selector: BinaryOperatorSelector\u003cAddTag, Array\u003cT\u003e, Array\u003cT\u003e\u003e,\n        left:Array\u003cT\u003e, right:Array\u003cT\u003e):Array\u003cT\u003e\n      {\n        return left.concat(right);\n      }\n    }\n\n### Step 3: Use `ArrayConcatenationEvaluator`\n\nAdd `using ArrayConcatenationEvaluator;` to your `Sample.hx`:\n\n    using ArrayConcatenationEvaluator;\n    @:build(com.dongxiguo.hoo.OperatorOverloading.enableByMeta(\":hoo\"))\n    class Sample\n    {\n      @:hoo public static function main()\n      {\n        // stringArray is [\"H\", \"el\", \"lo, \", \"wo\", \"rld!\" ];\n        var stringArray = [\"H\", \"el\", \"lo, \"] + [\"wo\", \"rld!\"];\n        trace(stringArray.join(\"\"));\n      }\n    }\n\n### Step 4: Run it!\n\n    haxe -x Sample.hx\n\nNow you will see it outputs `Hello, world!`.\n\n## Built-in overloads\n\nThere are built-in overloaded operators for `haxe.Int64` and native types.\nTo enable them, type `using com.dongxiguo.hoo.Int64Evaluators;` and/or\n`using com.dongxiguo.hoo.NativeEvaluators;`:\n\n    #if (haxe_211 || haxe3)\n    using com.dongxiguo.hoo.NativeEvaluators;\n    using com.dongxiguo.hoo.Int64Evaluators;\n    #else\n    using com.dongxiguo.hoo.Int64Evaluators;\n    using com.dongxiguo.hoo.NativeEvaluators;\n    #end\n    @:build(com.dongxiguo.hoo.OperatorOverloading.enableByMeta(\":hoo\"))\n    class Sample\n    {\n      @:hoo public static function main()\n      {\n        var i64 = Int64.ofInt(123456789);\n\n        // Output: 12345678900000123\n        trace(i64 * 100000000 + 123);\n      }\n    }\n\nIf you want to overload `==` for `haxe.Int64`, you must:\n * Put `using Int64Evaluators;` before `using NativeEvaluators;` for Haxe 2.10;\n * Put `using NativeEvaluators;` before `using Int64Evaluators;` for Haxe 2.11.\n\n## License\n\nSee https://github.com/Atry/hoo/blob/master/LICENSE\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fatry%2Fhoo","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fatry%2Fhoo","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fatry%2Fhoo/lists"}