Learning about OCaml's OO features today.
It rather reminds me of Go: you don't need to do up-front design of what common methods your objects have. Its type is just its methods (structural typing AIUI).
You don't even need to define classes at all! Just return an object.
miniblog.
Related Posts
I'm looking at adding bitwise AND and OR to my programming language. Do I add & and | operators, methods x.and(y) or a library bitwise::and(x, y)?
My inclination is to add infix operators (concise and familiar) but syntax is such precious real estate.
I'm writing a Path type in my programming language but not sure what methods belong on a Path.
Should I have some_path.read_string() or fs::read_string(some_path) instead?
I love .method() for IDE completion, but I don't want Path to be cluttered. I'm also trying to avoid UFCS.
Should code completion offer private methods/fields?
If the user chooses a private method, you can offer a quickfix to change its visibility. It's clutter though.
I frequently find myself wanting fields that I haven't exposed yet, and frustrated that the IDE hides them.