New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TODOs #4

Open
getify opened this Issue Feb 4, 2019 · 0 comments

Comments

Projects
None yet
1 participant
@getify
Copy link
Owner

getify commented Feb 4, 2019

Keeping notes of TODOs for TypVal. This list will be updated as progress occurs.

  • Embedded External Annotations: allow annotating types/signatures for external

    "#extern foo" < int;
    var x = foo;   // x implied as 'int'
    
    "#extern SomeUtil" < func`(string, number) => bool`;
    var y = SomeUtil("hello","world");   // error on "world" not being 'number', y implied as 'bool'

    Also, we need to define a (huge) set of these external annotations (to be imported via JSON, perhaps?) for all the built-ins and natives, such as encodeURI(..), console.log(..), JSON.stringify(..), etc.

  • Cross-typing: option to collect global types/signatures from non-modules, and exported types/signatures from modules, and "export" them possibly as JSON, and then "import" them for a file as "external annotations". Allows checking multiple files together in a group.

  • Generic types for function params/signatures, by allowing signature overloading

    function foo(x = generic) {
       return x;
    }
    
    var a = foo(3);   // `a` is type 'number'
    var b = foo("abc");   // no error, since signature is overloaded, `b` is type 'string'
  • Enforce TDZ for var, as well as (separately) TDZ for let / const, as well as (separately) TDZ for function declarations

  • Function typed-shorthand:

    func`(int,string) => bool`;
    // returns a function like:
    // (x,y) => { x = int`${x}`; y = string`${y}`; return bool`false`; }
    function bar(cb = func`int => string`) {
       var x = int`0`;
       x = cb("hello");
       // reports error with "hello" not matching `int` param
       // reports error with `x` being an `int` but trying to assign a `string` to it
    }
    
    var b = func`int => string`;
  • Custom types (via scope-hoisted pragmas)

    “#define FancyArray”;
    var x = FancyArray`1,2,3`;

    Sub types:

    “#define Automobile” < “#define Car”;
    “#define Automobile” < “#define Truck”;
    var y = Automobile``;
    y = Car``;
    y = Truck``;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment