Prev | Current Page 218 | Next

L. McColl-Sylvester and F. Ponticelli

"Professional haXe and Neko"


To compile the previous example, save the code in a single file named Main.hx,
open the command line, go to the directory with the saved file and type the
following command:
> haxe -main Main.hx -neko main.n
A file main.n will be generated. It can be executed in the command line where the
results will be displayed, using the command:
> neko main.n
In this case, Neko is the execution target but any supported platform can be used in
its place. All the examples in this chapter are compatible with any haXe platform
unless otherwise indicated.
104
Part I: The Core Language
Static methods, like main in the previous example, will be covered later, but remember that when
executing a piece of code written in haXe, there is always the need of a class implementing a static
function named main that will be automatically executed on startup. The class containing such a
method must be specified in the compiler command line using the - main switch. Compiling without the
- main switch will build a library output; something that can be reused by other applications but that
has no use by itself.


Pages:
206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230