Skip to content

Add clarification to Labels #6

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions site/learn/tutorials/labels.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ the `even` function, we already need the definition of `odd`, and to
compile `odd` we need the definition of `even`. So swapping the two
definitions around won't help either.

There are no "forward prototypes" in OCaml but there is a special syntax
There are no "forward prototypes" (as seen in languages descended from C) in OCaml but there is a special syntax
for defining a set of two or more mutually recursive functions, like
`odd` and `even`:

Expand All @@ -59,7 +59,7 @@ and odd n =
```
It's hard to know exactly how useful this is in practice, since I've
never had cause to write mutually recursive functions, nor have I been
able to think of a non-trivial example. However it's there. You can also
able to think of a non-trivial example. However, it's there. You can also
use similar syntax for writing mutually recursive class definitions and
modules.

Expand Down Expand Up @@ -174,8 +174,8 @@ And the type of our new `range` function with labelled arguments is:
```ocaml
range : first:int -> last:int -> int list
```
(Confusingly, the `~` (tilde) is *not* shown in the type definition, but
you need to use it everywhere else).
Confusingly, the `~` (tilde) is *not* shown in the type definition, but
you need to use it everywhere else.

With labelled arguments, it doesn't matter which order you give the
arguments anymore:
Expand Down Expand Up @@ -487,8 +487,8 @@ let f ~foo:foo ... =
The declaration `~foo:foo` creates a variable called simply `foo`, so if
you need the value just use plain `foo`.

Things, however, get complicated for two reasons: Firstly the shorthand
form `~foo` (equivalent to `~foo:foo`), and secondly when you call a
Things, however, get complicated for two reasons: first, the shorthand
form `~foo` (equivalent to `~foo:foo`), and second, when you call a
function which takes a labelled or optional argument and you use the
shorthand form.

Expand Down