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

The common bias against structural typing is that there might be types with the same structure but subtly different semantics, e.g. coordinate systems. Same structural type, different semantic:

  struct carthesian_coords { int x; int y; }
  struct polar_coords      { int r; int theta; }


Most of the structural typing systems I've seen count the names of fields as part of the type, not just the types of the fields. So, those two structs would have incompatible types in such a system.




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

Search: