Language
The Haxe language is similar to ECMAScript, although almost no ECMAScript code will run on Haxe without modifications. Unlike ECMAScript, Haxe is a compiled language. It is a general-purpose language with object-oriented programming, exceptions, and type inference with class parameters. Generic classes, reflectivity, iterators, and functional programming are built-in functionality of the language and libraries. Unusual among programming languages, Haxe contains a type system which is both strong and dynamic. The compiler will check types implicitly and give compile-time errors, but it also enables the programmer to bypass type-checking and rely on the target platform's dynamic type-handling.
Since Haxe had its origins in AS3, all of the existing Flash API can be used, although Haxe requires better-formed code and programming standards than Adobe compilers (for example, with regard to scoping and data typing).
Function parameters can be defined very precisely in Haxe:
function multipleparams (threedimensionalarray : ArrayEnumerated types are a key feature of the language; they can have parameters of their own and be recursive. They are similar to algebraic data types in languages like ML or Haskell. Enums in Haxe are not simply indexed "magic-number" values as in most languages, but are more abstract: they contain no inherent value, but can be instanced into variables as in this example:
enum Color { red; green; blue; rgb: ( r : Int, g : Int, b : Int ); } class Colors { static function toInt ( c : Color ) : Int { return switch ( c ) { case red: 0xFF0000; case green: 0x00FF00; case blue: 0x0000FF; case rgb(r, g, b): (r << 16) | (g << 8) | b; } } static function validCalls { var redint = toInt(Color.red); var rgbint = toInt(Color.rgb(100,100,100)); } }This example draws a red square using a Flash MovieClip object, and utilizes the "using" keyword.
using Colors; class Test { static function main { var mc: flash.display.MovieClip = flash.Lib.current; mc.graphics.beginFill(red.toInt); mc.graphics.moveTo(50,50); mc.graphics.lineTo(100,50); mc.graphics.lineTo(100,100); mc.graphics.lineTo(50,100); mc.graphics.endFill; } }Read more about this topic: Ha Xe
Famous quotes containing the word language:
“One who speaks a foreign language just a little takes more pleasure in it than one who speaks it well. Enjoyment belongs to those who know things halfway.”
—Friedrich Nietzsche (18441900)
“Sarcasm I now see to be, in general, the language of the Devil; for which reason I have long since as good as renounced it.”
—Thomas Carlyle (17951881)
“Whether we regard the Womens Liberation movement as a serious threat, a passing convulsion, or a fashionable idiocy, it is a movement that mounts an attack on practically everything that women value today and introduces the language and sentiments of political confrontation into the area of personal relationships.”
—Arianna Stassinopoulos (b. 1950)