RobertBendun / stacky

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

Basic type system #44

Closed RobertBendun closed 3 years ago

RobertBendun commented 3 years ago

Program is compile time evaluated. Evaluation starts with empty type stack. All operations consume and/or produce values and place their types onto type stack. Illegal are:

Operations can have different meaning and result according to types that are on stack. Stack manipulation operations (like drop or swap are supported by all operations).

Types

Type system should support following types:

Casting syntax is as(bool), as(ptr) ...

Control flow

if blocks

Value consumed by if for determining which branch to execute known as condition should be bool.

while blocks

Stack after consuming condition in do should match this before while. Stack after loop body execution should match this before while.

functions

On each return (including function end) state of stack should be the same. if return is embeded into while or if, it should change behaviour of given block checking.

Operations and their types

Operations on u64

Basically almost all. Excluded are:

Operations on ptr

Related

Different size and "signedness" of types: #46 Function type specification: #47