I'm getting an exception when trying to use the haxelib run command on my test Haxelib:
haxelib run haxelib-test
D:\HaxeToolkit\haxe\std/neko/vm/Thread.hx:54: characters 20-71 : Can't create thread from within a macro
Without threading everything works okay.
Haxe code:
import neko.vm.Thread;
class Main {
static function main() {
trace("starting");
var commandsThread = Thread.create(read);
trace("ending");
}
static function read() {
trace("new thread");
}
}
My haxelib.json looks like this:
{
"name": "haxelib-test",
"license": "MIT",
"tags": [],
"description": "",
"version": "0.0.1",
"classPath": "src/",
"main": "Main"
}
From the Haxelib docs you linked:
Since you're providing a
mainclass, Haxelib is trying to run your code in Haxe's built-in macro interpreter using the--interpargument.Haxe 3's macro interpreter did not support threading, hence the error. You can work around this by compiling a
run.nfile and packaging that with your library, so the script is executed in Neko VM:Haxe 4 introduced threading support for its new macro interpreter called "Eval" in the
preview.5release. Starting with that version, you can useeval.vm.Thread. However, note that this would make your Haxelib'sruncommand not work for people running older Haxe versions. So if you're going for maximum compatibility, stick to Neko for now.