Records are special type of class, originally introduced by C# 9.0.

From Microsoft's documentation:

Records are distinct from classes in that record types use value-based equality. Two variables of a record type are equal if the record type definitions are identical, and if for every field, the values in both records are equal. ... Value-based equality implies other capabilities you'll probably want in record types. The compiler generates many of those members when you declare a record instead of a class.

Symmetrical to C#, Mercury lets you use the Record keyword, replacing Class in the type declaration, to mark a class as record. (In all languages, you can use the Record aspect to achieve the same).

Records can only descend from classes also records (or the base Object, of course), and any descendents from a record must also be records.

Public Record Foo 
  Inherits Bar

  Public Property Name As String
End Record

Equivalent using the aspect:

Public Class Foo 
  Inherits Bar

  Public Property Name As String
End Class

See Also