jmeaster30 / ocean

A C-like programming language (get it like sea-like like an ocean lol)
GNU General Public License v3.0
0 stars 0 forks source link

Contracts for types #103

Open jmeaster30 opened 9 months ago

jmeaster30 commented 9 months ago

I want contracts or constraints to declare invariants that certain types must follow.

I am thinking they need to be followed on the function boundary incase it takes intermediate steps to make the constraint satisfied. But ideally it would be at the statement level .

But the contract block consists of a list of boolean expressions that must remain true at all times. These constraints must also be validatable at compile time and not require runtime checks

pack Test {
    a: String[]
    b: i32[]
}

contract Test {
    a.len() == b.len()
    a.len() < 10000
}