Readability improvements to the tour page - #3654
Conversation
Clarified explanation of expressions and types in OCaml. Added notes on bindings and the use of the `let` keyword.
There was a problem hiding this comment.
Thanks @anirudh24seven. Giving a name to the material that describes bindings is a good idea. The rest can be fixed.
More importantly, Bindings should be under Expressions And Definitions not at the same level. For consistency, it's probably better to use Definitions at both levels (in ## and ###) and explain that definition is a not-nameless binding in a sentence. Also, Expressions and Definitions can't have a single subsection, if a Definitions/Bindings section exists, an Expressions one is needed.
| ``` | ||
|
|
||
| In OCaml, everything has a value, and every value has a type. The above example says, “`50 * 50` is an expression that has type `int` (integer) and evaluates to `2500`.” Since it is an anonymous expression, the character `-` appears instead of a name. | ||
| In OCaml, everything has a value, and every value has a type. The above example says, the input “`50 * 50` is an expression that has type `int` (integer) and evaluates to `2500`.” Since it is an anonymous expression, the character `-` appears instead of a name, in the output (Note that this is different from `_` in the input that we will address later). |
There was a problem hiding this comment.
The parenthetical text does not help here. It is a forward reference, we try to avoid that.
| In OCaml, everything has a value, and every value has a type. The above example says, the input “`50 * 50` is an expression that has type `int` (integer) and evaluates to `2500`.” Since it is an anonymous expression, the character `-` appears instead of a name, in the output (Note that this is different from `_` in the input that we will address later). | |
| In OCaml, everything has a value, and every value has a type. The above example says, the input “`50 * 50` is an expression that has type `int` (integer) and evaluates to `2500`.” Since it is an anonymous expression, the character `-` appears instead of a name, in the output. |
| ``` | ||
|
|
||
| The lists' types, `int list` and `string list`, have been inferred from the type of their elements. Lists can be empty `[]` (pronounced “nil”). Note that the first list has been given a name using the `let … = …` construction, which is detailed below. The most primitive operation on lists is to add a new element at the front of an existing list. This is done using the “cons” operator, written with the double colon operator `::`. | ||
| (`let` and `val` are explained next in the [Bindings](#bindings) section) |
There was a problem hiding this comment.
A fully parenthetical and single sentence paragraph isn't correct formatting.
| The lists' types, `int list` and `string list`, have been inferred from the type of their elements. Lists can be empty `[]` (pronounced “nil”). Note that the first list has been given a name using the `let … = …` construction, which is detailed below. The most primitive operation on lists is to add a new element at the front of an existing list. This is done using the “cons” operator, written with the double colon operator `::`. | ||
| (`let` and `val` are explained next in the [Bindings](#bindings) section) | ||
|
|
||
| The lists' types, `int list` and `string list`, have been inferred from the type of their elements. Lists can be empty `[]`. Note that the first list has been given a name (u) using the `let … = …` construction. |
There was a problem hiding this comment.
Why remove pronounced “nil” Absolute newbies need that information. Also, there's a remark on name definition here, a reference to the binding section could be introduced here.
|
|
||
| Also note parentheses are not needed here, around the `if`, which is often the case in OCaml. |
There was a problem hiding this comment.
We try to avoid single sentence paragraphs.
| There is no overloading in OCaml, so inside a lexical scope, names have a single value, which only depends on its definition. | ||
| Inside a lexical scope, names have a single value (the one it was bound to with `let`). There is no ambiguity as there is no overloading in OCaml. |
There was a problem hiding this comment.
By default, we prefer stating cause first and consequence second.
I strongly believe that first party guides, docs and error messages help adoption by new users of the language. I am proposing some changes to the Tour of OCaml page so that it becomes easier to read by such beginners.
Please let me know if I can make them any better. I am willing to iterate on this.