ogma icon indicating copy to clipboard operation
ogma copied to clipboard

[FEATURE] Stronger guarantees about output types

Open kurtlawrence opened this issue 3 years ago • 0 comments

Description

R&D into making stronger guarantees of an expressions/blocks output type. Right now it is dependent on input type, which has to be evaluated at the hir stage. For definitions, the input type can be specified, which would make the definition be able to become an atomic unit of Input -> Output given a set of arguments?

This might make it a requirement to specify all argument types, which could jepordize how to make polymorphic higher level functions such as sum.

This is a maybe, since ogma's flexibility with typing based on the use case was one of the design strengths.


Now that #62 has landed, this can be implemented as a contraint on a def. The syntax should follow type annotation (#60). A tentative syntax proposed would look like:

def <ident> [<InputTy>][:<OutputTy>] ...

examples:
def foo Table () { .. } # constrain on Table input type

def bar Table:Num () { .. } # constrain on Table input and returns output Num

def zog :Num () { .. } # unconstrained input type, returns a Num

kurtlawrence avatar Sep 24 '21 23:09 kurtlawrence