masoodahm
masoodahm

Reputation: 305

Ocaml record & type definition syntaxes

What is the difference between following two syntaxes.

(* First *)
type named = < age :int ;name :string  >;;

(* Second *)
type named = {
  age: int;
  name: string
};;

I know the second one is a record but what is the first one, I just need to know a name that I can search online to learn more.

Upvotes: 1

Views: 62

Answers (1)

glennsl
glennsl

Reputation: 29146

The first definition is an object type. The most significant difference is that objects are structural and late bound while records are nominal and early bound.

See the manual entries for records and objects for more details.

Upvotes: 2

Related Questions