logoalt Hacker News

pxeger1last Friday at 5:24 PM0 repliesview on HN

I think you mean structural typing; nominal typing is the opposite, where field names are lexically scoped.

Anyway, row polymorphism can technically be used with nominal typing, it's just that it usually makes sense to use structural typing instead.

The key benefit of row polymorphism is a bit of an implementation detail - it lets you get something resembling (a limited form of) subtyping in your language, without needing as complicated a type inference algorithm as fully-general subtyping requires.

Row polymorphism can be (IMO should usually be) made opt-in, so you can avoid problems like the scenario you describe.