Hacker News new | past | comments | ask | show | jobs | submit login

> should the language catch us making a type error here?

With a statically typed language, the choice is up to you. Every statically typed language is just a "dynamically typed" language with the ability to statically assign types. For example, you can type the variable as an "Int" or for more runtime flexibility, a "Variant" (if using C++).




The question here is that a type inference can assign type to a hole but may get confused if user insists on an incompatible type.

int q // q is considered a hole of int type

q <- // but we're typing "hello" there

Practicalities ask for the situation to be considered a problem - not of incorrectly plugged hole (when into "int" place you're putting "string" value), but of incorrectly previously stated type (it's the original "int q" which is wrong, should have been "string q").




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

Search: