dada-lang / dada

I speak only of myself since I do not wish to convince, I have no right to drag others into my river, I oblige no one to follow me and everybody practices his art in his own way.
https://dada-lang.org
Apache License 2.0
444 stars 28 forks source link

Typed Dada #219

Open nikomatsakis opened 2 years ago

nikomatsakis commented 2 years ago

This issue is tracking ongoing work to introduce Typed Dada.

The plan

The plan roughly proceeds in 3 parts

The intent is that you can run your program even when you have static type errors and it makes sense, but it will fail if your type annotations are wrong. This lets you explore why you are getting a static type error.

Status

Here is a vague list of things that are done vs not done.

Type system

Here are some examples:

class Character(name: my Name)

fn name(c: shared Character) -> shared{c} Name {
    c.name
}

This signature indicates we take in c which is some shared Character and return a Name that was shared from c (which the code does).

class Character(name: my Name)

fn name(c: shared Character, d: shared Character) -> shared{c} Name {
    d.name
}

The return type is the same, but the function will get an error when it runs, because the name we return was shared from d, not c.

Other types at present: