Proposal: kinds, abilities, subtyping, and operators

Simple subtyping seems to be the best way to implement operator overloading (e.g. + over int and float), but we want to make sure that anything scrapscript returns is also a valid program. Is there any way implement all of this with kinds, abilities, or custom operators?

you can get away without subtyping even across multiple numerical types if you just special case + (ie int+float => float)

kinds introduce a lot of complexity into the type system (3 universes feels excessive)

the easiest way to allow custom operators would just be to let functions with two arguments be called as infixes

in some languages, there’s a policy that un-performant actions should ‘smell’ (be visibly different, and somewhat harder to use). in the case of a library biginteger type, it’d ‘smell’ by having it’s own arithmetic operations rather than overloading the standards.

however, this is not always the case. array addition is quite performant, but without adding it as a overload, it’d also ‘smell’.

1 Like