Are there any plans to support “as” and “is” as first class operators like all the modern programming languages? (ie. AS3, C#, etc)
Currently we have cast(x, Sprite) and Std.is(x, Sprite) but these are somewhat clunky compared to the much easier to read syntax that x as Sprite allows.
If you know you can do an unsafe cast, then instead of cast (instance, Sprite) you can use cast instance which should feel more compact.
I believe some of the concept behind it is that runtime methods (such as checking the type of the object) should translate cleanly from the Haxe code to the target language. Not all languages support an “is” keyword, or work the way a Haxe “is” check would. It also allows for overrides, which is nice, such was the case recently when we overrode the behavior of Std.is in order to better support certain versions of Safari. While we wait for the next release of Haxe (which includes the patch) we can include the improvements, which I think a static keyword would not allow.
I suppose I can say as well, that when I first came to Haxe, this felt a little clunky. Now I prefer the differences between the two cast types (and enjoy being able to just put in “cast” rather than naming the type, like when passing an argument into a function, foo (cast param);) and I don’t hardly use Std.is, just the way I write my code now, given Haxe’s slant toward type safety