top | item 7799675

(no title)

lignuist | 11 years ago

The idea is to be able to write code in one language and use this code in many different languages.

discuss

order

_random_|11 years ago

Does it mean that it supports only basic common denominator features of every language? I am a fan of attributes in C# - are Haxe annotations as powerful?

joneil|11 years ago

Out of the box Haxe's metadata[1] to me doesn't appear as powerful as C#'s attributes. The big difference is that they are not type safe and are not type-checked by the compiler.

You can however use any expression you want in them, and have macros read them and confirm they are correct, and do whatever you want with them. For example I do some validation on my models:

    @:validate( _.length>0 && _.indexOf(' ')==-1 )
    public var username:String;
As for the bigger question - they are limited in what they can add, but they have many features not in other languages, they just implement them in a syntax-heavy way on the languages that lack such features. Pattern matching is a good example [2].

See http://haxe.org/documentation/introduction/language-features...

[1]: http://haxe.org/manual/lf-metadata.html [2]: http://haxe.org/manual/lf-pattern-matching.html