RobertBendun / stacky

Stack based programming language
Boost Software License 1.0
4 stars 1 forks source link

Different type checking algorithm #58

Closed RobertBendun closed 2 years ago

RobertBendun commented 3 years ago

Current one is not so great when it comes to typechecking return statements. Also it cannot typecheck functions that are dynamic in their nature. Good example of one is switch from examples/switch.stacky. It requires more sophisticated type system then stacky ever will have.

https://github.com/RobertBendun/stacky/blob/d9cf84971b9fcdb08a2642ea9bf04c7055e73f7f/examples/switch.stacky#L3-L21

Also with current type system, expressing function types is impossible, making call keyword untypecheckable.

Additionaly, functions like:

two-dup fun over over end

are impossible to type check due to lack of type variables in type signatures. First solution that I have in mind is to add keyword dynamic for functions that's type are resolved at call side. Example with new syntax:

two-dup fun dynamic is over over end

Maybe shorten it to dyn. (Rust uses shorter one for different stuff)