### Build Example Plugin Source: https://github.com/haxefoundation/haxe/blob/development/plugins/example/README.md Use this command to build the example plugin for your current operating system. ```bash make plugin PLUGIN=example ``` -------------------------------- ### Install Haxe on Unix Source: https://github.com/haxefoundation/haxe/blob/development/extra/BUILDING.md Install the compiled Haxe compiler on Unix-like systems using 'make install'. Ensure no conflicting Haxe installations exist and HAXE_STD_PATH is not set. ```bash sudo make install ``` -------------------------------- ### Install Neko on Windows (Cygwin) Source: https://github.com/haxefoundation/haxe/blob/development/extra/BUILDING.md Install Neko on Windows by either downloading binaries and adding to PATH, or using the Chocolatey package manager. ```bash Download the [Neko binaries](https://nekovm.org/download/), and add the extracted directory to the beginning of PATH. ``` ```bash Install the [Chocolatey Neko package](https://chocolatey.org/packages/neko). ``` -------------------------------- ### Pin and Install OCaml Dependencies Source: https://github.com/haxefoundation/haxe/blob/development/extra/BUILDING.md Use OPAM to pin the Haxe package to the local source directory and then install its OCaml dependencies. ```bash opam pin add haxe path/to/haxe --kind=path --no-action ``` ```bash opam install haxe --deps-only ``` -------------------------------- ### Install Native Libraries on Windows (Cygwin) Source: https://github.com/haxefoundation/haxe/blob/development/extra/BUILDING.md Install necessary packages via Cygwin's setup-x86_64.exe and copy DLLs to the Haxe source directory. This includes build tools and native libraries. ```bash make, git, zlib-devel, libpcre2-devel, mingw64-x86_64-gcc-core, mingw64-x86_64-zlib, and mingw64-x86_64-pcre2 ``` ```bash path/to/cygwin/usr/x86_64-w64-mingw32/sys-root/mingw/bin ``` -------------------------------- ### Install Native Libraries on Debian/Ubuntu Source: https://github.com/haxefoundation/haxe/blob/development/extra/BUILDING.md Use apt to install the required native libraries (libpcre2-dev, zlib1g-dev, libmbedtls-dev) on Debian-based systems. ```bash sudo apt install libpcre2-dev zlib1g-dev libmbedtls-dev ``` -------------------------------- ### Install Haxe on Windows Source: https://github.com/haxefoundation/haxe/blob/development/extra/BUILDING.md Install the compiled Haxe compiler on Windows by adding the checked out Haxe source directory to the beginning of the system's PATH environment variable. ```bash add the checked out Haxe source directory to the beginning of PATH. ``` -------------------------------- ### Setup Plugin as Haxe Library Source: https://github.com/haxefoundation/haxe/blob/development/plugins/example/README.md Configure your plugin as a Haxe library using 'haxelib dev' to make it accessible in your projects. ```bash haxelib dev example path/to/haxe/plugins/example ``` -------------------------------- ### Start Git Bisect Source: https://github.com/haxefoundation/haxe/wiki/Finding-breaking-commits-with-git-bisect Initiates the git bisect process to start searching for a breaking commit. ```bash git bisect start ``` -------------------------------- ### Install Native Libraries on Mac OS X Source: https://github.com/haxefoundation/haxe/blob/development/extra/BUILDING.md Use Homebrew to install the required native libraries (zlib, pcre2, mbedtls) on macOS. Ensure you use mbedTLS version 3.x. ```bash brew install zlib pcre2 mbedtls@3 ``` -------------------------------- ### Compile and Run Haxe Unit Tests Source: https://github.com/haxefoundation/haxe/blob/development/tests/README.md Compile and run Haxe unit tests for all targets. This requires dependencies to be installed and a local development server to be running. ```bash haxe compile.hxml nekotools server ``` -------------------------------- ### Arrow Function Syntax Examples Source: https://github.com/haxefoundation/haxe/wiki/Breaking-changes-in-Haxe-4.0.0 Demonstrates the new arrow function syntax in Haxe 4, covering cases with no arguments, multiple arguments, type hints, and a single argument convenience. ```haxe // no args () -> expr ``` ```haxe // with args (arg1, arg2) -> expr ``` ```haxe // args with type hints (arg1:Type1, arg2:Type2) -> expr ``` ```haxe // return type hint is not supported for arrow functions due to syntax ambiguity, one can use type-check syntax in the function expression (arg1:Type) -> (expr:ReturnType) ``` ```haxe // single-arg-no-type-hint convenience special case (no parenthesis required) arg -> expr ``` -------------------------------- ### Current Property Accessor Style Source: https://github.com/haxefoundation/haxe/wiki/What's-new-in-Haxe-4 Demonstrates the current method for defining property accessors using standard 'get' and 'set' functions. ```haxe class Test { @:isVar var myvar(get, set) : String = "Something"; static function main() { trace (new Test().get_myvar()); } public function new() {} public function get_myvar() : String { return myvar; } public function set_myvar(s:String) : String { return myvar = s; } } ``` -------------------------------- ### Access Haxe Unit Tests in Browser Source: https://github.com/haxefoundation/haxe/blob/development/tests/README.md Open this URL in your browser to access and run the Haxe unit tests after compilation and starting the development server. ```html http://localhost:2000/unit.html ``` -------------------------------- ### New Function Type Syntax Examples Source: https://github.com/haxefoundation/haxe/wiki/Breaking-changes-in-Haxe-4.0.0 Illustrates the updated syntax for specifying function types in Haxe 4, including support for argument names and mixed argument types. ```haxe // no args () -> Void ``` ```haxe // unnamed args (Int, String) -> Bool ``` ```haxe // named args (name:String) -> Void ``` ```haxe // named, unnamed and optional args mixed (arg1:Type1, ?arg2:Type2, Type3) -> Ret ``` -------------------------------- ### Transition from @:fakeEnum to Enum Abstract Source: https://github.com/haxefoundation/haxe/wiki/What's-new-in-Haxe-4 Provides an example of refactoring code that used the removed @:fakeEnum meta to the modern enum abstract syntax. ```haxe @:native("SomeClassWithStaticConsts") @:fakeEnum(String) extern enum SomeEnum { A; B; } ``` ```haxe @:native("SomeClassWithStaticConsts") extern enum abstract SomeEnum(String) { var A; var B; } ``` -------------------------------- ### Arrow Function Syntax Examples Source: https://github.com/haxefoundation/haxe/wiki/What's-new-in-Haxe-4 Illustrates the new arrow function syntax (short lambdas) in Haxe. This syntax is ideal for short callback functions, functional programming, and asynchronous code. It provides concise equivalents for traditional function declarations. ```haxe // no arguments () -> trace("Haxe is great!") // equivalent for `function() trace("Haxe is great!")` ``` ```haxe // multiple arguments (a, b) -> a + b // equivalent for `function(a, b) return a + b;` ``` ```haxe // explicit typing (a:Float, b:Int) -> a + b // equivalent for `function(a:Float, b:Int) return a + b;` ``` -------------------------------- ### Haxe 4 compatibility with Haxe 5 bind typing Source: https://github.com/haxefoundation/haxe/wiki/Breaking-changes-in-Haxe-5.0.0 This example shows how to maintain Haxe 4 compatibility with Haxe 5's stricter typing for `bind` with optional arguments. It explicitly passes `null` for optional arguments or uses a lambda. ```haxe function f(notOpt:Int, ?opt:String) {} function g(notOpt:Int, alsoNotOpt:Bool, ?opt:String) {} function foo(cb:Void->Void) {} function bar(cb:Bool->Void) {} function main() { var f1 = f.bind(1, null); $type(f1); // () -> Void foo(f1); // Ok // And if you need to skip arguments: var g1 = g.bind(1, _, null); $type(g1); // (alsoNotOpt : Bool) -> Void bar(g1); // Ok } ``` ```haxe function f(notOpt:Int, ?opt:String) {} function foo(cb:Void->Void) {} function main() { var fLambda = () -> f(1); $type(fLambda); // () -> Void foo(fLambda); // Ok } ``` -------------------------------- ### Run Haxe System Tests Source: https://github.com/haxefoundation/haxe/blob/development/tests/README.md Compile and run Haxe system tests. On Windows, comment out specific lines in `run.hxml` before execution. ```bash haxe run.hxml ``` -------------------------------- ### Compile and Run Unit Tests Source: https://github.com/haxefoundation/haxe/blob/development/tests/unit/README.md Compile the unit tests for a specific target, such as Lua, using a HXML file. Then, execute the compiled test binary. ```bash # Compile for a target (e.g., Lua) haxe --cwd tests/unit compile-lua.hxml # Run lua bin/unit.lua ``` -------------------------------- ### Extern Inline Function Source: https://github.com/haxefoundation/haxe/wiki/What's-new-in-Haxe-4 Example of an extern inline function declaration. ```haxe extern inline function f(...) {} ``` -------------------------------- ### Enum Abstract with Integer Auto-Numbering Source: https://github.com/haxefoundation/haxe/wiki/What's-new-in-Haxe-4 Demonstrates enum abstracts where values are automatically assigned integers starting from 0. ```haxe enum abstract E(Int) { var A; // 0 var B; // 1 } ``` -------------------------------- ### Build Haxe Compiler on Windows Source: https://github.com/haxefoundation/haxe/wiki/Finding-breaking-commits-with-git-bisect Commands to clean and build the Haxe compiler on Windows using a specific Makefile. ```bash make -f Makefile.win MSVC=1 clean make -f Makefile.win MSVC=1 ``` -------------------------------- ### Compile Haxe on Unix Source: https://github.com/haxefoundation/haxe/blob/development/extra/BUILDING.md Compile the Haxe compiler on Unix-like systems using the standard Makefile. ```bash make ``` -------------------------------- ### Access Plugin Functionality in Haxe Macro Source: https://github.com/haxefoundation/haxe/blob/development/plugins/example/README.md Demonstrates how to call a plugin's function from within a Haxe macro. Ensure the plugin is correctly set up as a library. ```haxe macro static public function testPlugin() { Example.plugin.hello(); return macro {} } ``` -------------------------------- ### Haxe 4 bind typing with optional arguments Source: https://github.com/haxefoundation/haxe/wiki/Breaking-changes-in-Haxe-5.0.0 In Haxe 4, trailing optional arguments are hidden when using `bind`. This example shows the resulting type signature. ```haxe function f(notOpt:Int, ?opt:String) {} function main() { var fBind = f.bind(1); $type(fBind); // () -> Void } ``` -------------------------------- ### Compile Haxe on Windows (Cygwin) Source: https://github.com/haxefoundation/haxe/blob/development/extra/BUILDING.md Compile the Haxe compiler on Windows within a Cygwin environment using the Makefile.win. ```bash make -f Makefile.win ``` -------------------------------- ### Trigger Haxe 5 bind typing in Haxe 4 Source: https://github.com/haxefoundation/haxe/wiki/Breaking-changes-in-Haxe-5.0.0 To ensure consistent behavior across Haxe 4 and 5, use explicit `_` for trailing optional arguments when using `bind`. This example demonstrates the Haxe 5 type signature. ```haxe function f(notOpt:Int, ?opt:String) {} function main() { var fBind = f.bind(1, _); $type(fBind); // (?opt : Null) -> Void } ``` -------------------------------- ### Checkout and Update for a Good Revision Source: https://github.com/haxefoundation/haxe/wiki/Finding-breaking-commits-with-git-bisect Checks out a specific tag and updates submodules to test a potentially 'good' revision. ```bash git checkout tags/v3-00 git submodule update ``` -------------------------------- ### Function Expression Parentheses Requirement Source: https://github.com/haxefoundation/haxe/wiki/Breaking-changes-in-Haxe-4.0.0 Shows how to correctly use function expressions as operands by wrapping them in parentheses to avoid syntactic ambiguities. ```haxe // Incorrect usage (ambiguous) // function() {} + 1 // Correct usage (function() {}) + 1 ``` -------------------------------- ### Clone Haxe Repository Recursively Source: https://github.com/haxefoundation/haxe/blob/development/extra/BUILDING.md Clone the Haxe repository including all its submodules. This is the recommended way to obtain the source code. ```bash git clone --recursive https://github.com/HaxeFoundation/haxe.git ``` -------------------------------- ### Run Haxe CI Tests Locally Source: https://github.com/haxefoundation/haxe/blob/development/tests/README.md Use this command to run all Haxe test suites locally. Ensure the TEST environment variable is set to your desired comma-separated list of targets (e.g., neko,macro). ```bash export TEST=neko,macro haxe RunCi.hxml ``` -------------------------------- ### Empty Map Literal Syntax Source: https://github.com/haxefoundation/haxe/wiki/What's-new-in-Haxe-4 Demonstrates the new syntax for initializing an empty Map in Haxe 4. ```haxe var map:Map = []; ```