Haxe-like language in development

Haxe seems to lack features such as destructuring patterns (Haxe does have pattern matching expression though), generators and asynchronous functions. I want to create an incompatible ES4 dialect that covers these features and more. However, my language won’t have macros and, for now, extension methods.

These are the first goals of the dialect:

  • :white_check_mark: basic reference listing all features
  • :white_check_mark: AST
  • :white_check_mark: parser
  • :x: verifier (semantic model + symbol solver + type checker)
  • :x: bytecode import and export
  • :x: documentation generator
  • :x: built-ins
  • :x: runtime (evaluation)

Looks

Iterators:

var x = [...Number.range(0, 10).map(e -> e * e).toArray()];

Value-based tuples and records (based on a TC39 proposal). If one wants them as reference, they can wrap it into Boxed.<T>:

type T = [Boolean, Number];
var v:T = [true, 0];
v == [true, 0];

type R = {x:Number, y:undefined|Number};
var v:R = {x: 10};
v == {x: 10};

Enums:

enum Product {
    // ['smartphone', 0]
    const SMARTPHONE;
    // ['aUtOmObIlE', 1]
    const AUTOMOBILE = 'aUtOmObIlE';
    // ['kxxx', 65]
    const KEYBOARD = [65, 'kxxx'];

    function customMethod():void {
    }
}

var p:Product = 'kxxx';
var p = Product.KEYBOARD;
p.valueOf(); // 65
p.toString(); // 'kxxx'
p = 65 as! Product;
p = 'kxxx' as! Product;

Flags enums:

[Flags]
enum Permissions {
    // ['fooBlah', 1]
    const FOO_BLAH;
    // ['qux', 2]
    const QUX;
    // ['baz', 4]
    const BAZ;
}

var p:Permissions = ['fooBlah', 'qux'];
p = {fooBlah: true, baz: false};
p = p.toggle('fooBlah');
p = p.filter('qux');
p = p.include('qux');
p = p.exclude('qux');
'qux' in p;

// empty
p = undefined;
p = {};
p = [];

Strings (Python-like composition):

var s:String = '\x{10ffff}';
s.length == 1;
s.charCodeAt(0) == 0x10ffff;
s.slice(0, 1) == '\x{10ffff}';

Packages:

package qux.bar {
    // ...
}
import Qb = qux.bar;// alias

Namespaces:

namespace Temporal {
    // ...
}
namespace A = B; // alias

Other things:

  • Indexing mechanism should work like in Haxe. There is also the delete o[k]; operation.
  • C(...); is equivalent to new C(...);
  • ba = embed './foo.bin':ByteArray;
  • include './another.es'; (combines statement sequence from another script)
  • switch type

I didn’t mention everything here, but if anyone is interested, here is the GitHub repository: violent-es.

1 Like