Ocaml Pet Peeve

While I generally like Ocaml (as some of you may have guessed), there is one pet peeve of mine with the language: record fields names are module wide rather than record specific. For example:

type t = { blah : int }

The record field blah is now a module wide name so I cannot reuse it. Thus, field names that happen to be useful in two contexts are not allowed. Although, to be honest, having two record names the same is probably a sign of a refactor point.

1 Comment

Originally C behaved like this. This is why a lot of the traditional UNIX/POSIX structs have unique prefixes on their member names; for example the st_ prefix on members of struct stat.

Leave a comment

About cyocum

user-pic Celticist, Computer Scientist, Nerd, sometimes a poet…