Skip to content

Latest commit

 

History

History
70 lines (68 loc) · 1.99 KB

TODO.org

File metadata and controls

70 lines (68 loc) · 1.99 KB

Type inference on functions

We need to apply all the constraints to the AST tree. Easiest way is probably to make all the nodes mutable

Reimplement type_resolver

Remove Type_graph_v1

Imports

Prelude-based operators and c compat

Implement Anonymous Tuples / lists

let p = (1, 2.0, "foobar")

[3/4] Named Tuples

type Pt = {x: Float64, y:Float64}
let p = Pt(10.0, 20.0)
let q = Pt(x=10.0, y=20.0)
let x = p.x
let y = q.y

named tuple declaration

named tuple constructor

named tuple constructor (keywords)

let x = Point3(1, 2, 3) let x = Point3(x=1, z=3, y=2)

named tuple field access

[0/3] Named Unions

type Day = {WeekDay: Int8 + Saturday + Sunday}
let p = Day.Saturday
let q = Day.Sunday
let v = match p:
  Weekday(n): n
  Saturday: 6
  Sunday: 7

syntax for union declaration

syntax for union case-constructors

syntax for match expressions

[0/4] Arrays

Declare a sized and typed array

Extract item from array

Insert item into array

Pass by reference or value

[0/3] Pointers

Declare a type of pointer-to-x

addrof : T -> Ptr[T]: take an address of a variable

deref : Ptr[T] -> T: take the value of a pointer

Pointer addition and subtraction

size_t and ptrdiff_t stuff

Anonymous Unions

let p : {Int32 | String} = if rand_bool () { 1 } else { "zero" }
p + 3 # TypeError: (p:Int32|String) + Int32
let result = match p:
  (n:Int32): n + 3
  (n:String): int s + 3

[1/1] Implement Overloaded functions on types

let p = Pt(3.0, 4.0)
let s = "asdf"
length s
length p

Step 2: Implement with Union-based parameter type inference

Project: PCRE-based regex library

Flesh out some required features by creating a library that wraps libpcre2