Prev | Current Page 307 | Next

L. McColl-Sylvester and F. Ponticelli

"Professional haXe and Neko"

n file before
executing it.
class Main
{
static function main()
{
var loader = neko.vm.Loader.local();
var module = loader.loadModule(???external???);
var classes : Dynamic = module.exportsTable().__classes;
var ob = Type.createInstance(classes.External, []);
trace(ob.say());
}
}
The module can be compiled with the following command:
> haxe -neko example.n -main Main
To execute the code in the command line, use the following command:
> neko example.n
The output will be:
Main.hs:7: Hello world!
Some explanations are required. The neko.vm.Loader is a Neko - specific class that permits the loading
and management of external libraries. The static function local returns the Loader that was used to
load the module in which the code is defined. The loadModule loads an external library defined in an
.n file, the extension is automatically appended and the file will be searched in one of the directories
accessible by the loader. The current directory and the installation directory of Neko are the default
path where modules will be searched.


Pages:
295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319