logoalt Hacker News

sfn42today at 9:12 AM3 repliesview on HN

Lots of languages can infer types. And your last example with the colors is just a dictionary.


Replies

grumpyproletoday at 9:22 AM

Most languages have poor support for structural types though. If you try and join two records together (like a SQL join), what will your favourite language infer then?

show 1 reply
sheepttoday at 9:26 AM

dictionaries generally aren't guaranteed to contain an entry for every possible value of the key type. while you could implement the colors example with a dictionary, ideally you'd want the type system to assure that given a Color, there will be a string associated with it

show 1 reply
fuzzy2today at 9:32 AM

It's not a dictionary (type-wise). "as const" is the magic ingredient.