Skip to content

Commit

Permalink
Merge pull request #8177 from bjorng/bjorn/doc/records/GH-8166/OTP-18995
Browse files Browse the repository at this point in the history
Update documentation about records
  • Loading branch information
bjorng authored Feb 23, 2024
2 parents 81fc1bc + d512b17 commit 9371dcb
Showing 1 changed file with 12 additions and 5 deletions.
17 changes: 12 additions & 5 deletions system/doc/reference_manual/ref_man_records.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,7 @@ limitations under the License.

A record is a data structure for storing a fixed number of elements. It has
named fields and is similar to a struct in C. Record expressions are translated
to tuple expressions during compilation. Therefore, record expressions are not
understood by the shell unless special actions are taken. For details, see the
`m:shell` manual page in STDLIB.
to tuple expressions during compilation.

More examples are provided in
[Programming Examples](`e:system:prog_ex_records.md`).
Expand All @@ -36,18 +34,27 @@ given an optional default value. If no default value is supplied, `undefined` is
used.

```erlang
-record(Name, {Field1 [= Value1],
-record(Name, {Field1 [= Expr1],
...
FieldN [= ValueN]}).
FieldN [= ExprN]}).
```

The default value for a field is an arbitrary expression, except that it must
not use any variables.

A record definition can be placed anywhere among the attributes and function
declarations of a module, but the definition must come before any usage of the
record.

If a record is used in several modules, it is recommended that the record
definition is placed in an include file.

> #### Change {: .info }
>
> Starting from Erlang/OTP 26, records can be defined in the Erlang shell
> using the syntax described in this section. In earlier releases, it was
> necessary to use the `m:shell` built-in function `rd/2`.
## Creating Records

The following expression creates a new `Name` record where the value of each
Expand Down

0 comments on commit 9371dcb

Please sign in to comment.