COMMUNITY

Haxe 4.0.0-preview.4 is released


(Phil Chertok) #1

Dear Community,

On behalf of the Haxe Foundation, we are proud to announce the official release of the Haxe 4.0.0-preview.4! It is available along with the changelog at https://haxe.org/download/version/4.0.0-preview.4/.

As a preview release, it should not be considered stable. However, we appreciate anyone testing this version which will help us with the real Haxe 4 release. Please report any issues here:

https://github.com/HaxeFoundation/haxe/issues.

Thank you very much for your help!

The following is a list of major additions and changes.

Improved compiler display services
Our focus for this release has been compiler display services. We implemented a new, JSON-RPC-based protocol which is utilized by the vshaxe Visual Studio Code Extension to provide a variety of new features:

  • Support for auto-import
  • Completion on override |
  • Completion for structure field names
  • Support for auto-generating structure declarations, functions, switches and more
  • Context-aware, sorted toplevel completion
  • Reference finding which explores modules that are not necessarily part of the compilation

Improved enum abstracts
Enum abstracts now get the treatment they deserve with a proper enum abstract syntax. Furthermore, values can now be omitted if the enum abstract is defined over Int or String:


enum abstract MyEnum(String) {
    var MyValue; // implicit = "MyValue"
}

enum abstract MyOtherEnum(Int) {
    var MyValue0; // implicit = 0
    var MyValue1; // implicit = 1
    var MyValue5 = 5;
    var MyValue6; // implicit = 6
}

Various syntactic improvements

  • extern is now recognized as a field-level modifier and can be used instead of @:extern
  • Metadata names can now use dots, e.g. @:haxe.json becomes a metadata entry named “haxe.json”
  • Structure fields now consistently allow var ?x and final ?x, meaning the same as @:optional var x
  • Type1 & Type2 is now a recognized syntax for intersection types. For the time being, it is only supported to merge structures (replacing the { >Type1, >Type2, } syntax) and for type parameter constraints (replacing T:(Type1, Type2) which has been removed from the language).

Lots of bugfixes
See the changelog for more!


… But wait there is more!

We did several improvements on the haxelib website too.
There is a new updates page which has nice detailed overview of what is new on haxelib.

The project page of haxelib is also updated, the overview now has stats graph. It is displayed when you have more than one release.

And we dropped the tag cloud in favor for a more elegant tag overview


(Mark) #4

Congrats on this release, super hyped now!

Question, if your abstract enum doest have a number, will it auto enumerate like this (??)

enum abstract MyOtherEnum(Int) {
    var MyValueA; // implicit = 0
    var MyValueB; // implicit = 1
    var MyValueC = 5;
    var MyValueD; // implicit = 2
}

(Dmitry Hryppa) #5

Hello, I’ve just tested it:

package;
class MyApp {
    public static function main() {
        trace(MyOtherEnum.MyValueA);
        trace(MyOtherEnum.MyValueB);
        trace(MyOtherEnum.MyValueC);
    }
}

enum abstract MyOtherEnum(Int) {
    var MyValueA; // implicit = 0
    var MyValueB = 5;
    var MyValueC; // implicit = 2
}

And here’s what I’ve got:

(function () { "use strict";
var $hxEnums = {};
var MyApp = function() { };
MyApp.main = function() {
	console.log("src/MyApp.hx:5:",0);
	console.log("src/MyApp.hx:6:",5);
	console.log("src/MyApp.hx:7:",6);
};
MyApp.main();
})();

(Andy Li) #6

It uses C’s enum numbering. Basically, the value is the previous one’s + 1, unless it is the first one (0), or explicitly assigned.

enum abstract MyOtherEnum(Int) {
    var MyValueA; // implicit = 0
    var MyValueB; // implicit = 1
    var MyValueC = 5;
    var MyValueD; // implicit = 6
}

(Mark) #7

Check out this nice video about this release!