Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

There is a simpler solution than type inference to removing type annotations while retaining types: remove the distinction between variable and type names. The way that you handle multiple instances of a type is to define an alias for the type. In pseudocode it might look like:

  type Divisor Number
  def divide(Number, Divisor) = Number / Divisor
As compared to:

  def divide(number: Number, divisor: Number) = number / Divisor
I have implemented a compiler for a language that does this with different (less familiar) syntax. It's a bit more complicated than described above to handle local variables but it works very well for me.


> There is a simpler solution than type inference to removing type annotations while retaining types

This doesn't remove them, it just moves them.


Is that language a Forth dialect by any chance?




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: