Skip to content

Commit 690e7ac

Browse files
KarboniteKreamjosevalim
authored andcommitted
Fix grammar in the Guide (elixir-lang#1022)
1 parent 6cc7414 commit 690e7ac

25 files changed

+87
-87
lines changed

getting-started/alias-require-and-import.markdown

+2-2
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ end
4040

4141
The original `List` can still be accessed within `Stats` by the fully-qualified name `Elixir.List`.
4242

43-
> Note: All modules defined in Elixir are defined inside a main `Elixir` namespace. However, for convenience, you can omit "Elixir." when referencing them.
43+
> Note: All modules defined in Elixir are defined inside the main `Elixir` namespace. However, for convenience, you can omit "Elixir." when referencing them.
4444
4545
Aliases are frequently used to define shortcuts. In fact, calling `alias` without an `:as` option sets the alias automatically to the last part of the module name, for example:
4646

@@ -222,4 +222,4 @@ From Elixir v1.2, it is possible to alias, import or require multiple modules at
222222
alias MyApp.{Foo, Bar, Baz}
223223
```
224224

225-
With this we have finished our tour of Elixir modules. The last topic to cover is module attributes.
225+
With this, we have finished our tour of Elixir modules. The last topic to cover is module attributes.

getting-started/basic-types.markdown

+2-2
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ iex> 1.0e-10
6666
1.0e-10
6767
```
6868

69-
Floats in Elixir are 64 bit double precision.
69+
Floats in Elixir are 64-bit double precision.
7070

7171
You can invoke the `round` function to get the closest integer to a given float, or the `trunc` function to get the integer part of a float.
7272

@@ -385,6 +385,6 @@ iex> elem(tuple, 1)
385385

386386
When counting the elements in a data structure, Elixir also abides by a simple rule: the function is named `size` if the operation is in constant time (i.e. the value is pre-calculated) or `length` if the operation is linear (i.e. calculating the length gets slower as the input grows). As a mnemonic, both "length" and "linear" start with "l".
387387

388-
For example, we have used 4 counting functions so far: `byte_size/1` (for the number of bytes in a string), `tuple_size/1` (for tuple size), `length/1` (for list length) and `String.length/1` (for the number of graphemes in a string). We use `byte_size` to get the number of bytes in a string -- a cheap operation. Retrieving the number of unicode characters, on the other hand, uses `String.length`, and may be expensive as it relies on a traversal of the entire string.
388+
For example, we have used 4 counting functions so far: `byte_size/1` (for the number of bytes in a string), `tuple_size/1` (for tuple size), `length/1` (for list length) and `String.length/1` (for the number of graphemes in a string). We use `byte_size` to get the number of bytes in a string -- a cheap operation. Retrieving the number of Unicode characters, on the other hand, uses `String.length`, and may be expensive as it relies on a traversal of the entire string.
389389

390390
Elixir also provides `Port`, `Reference`, and `PID` as data types (usually used in process communication), and we will take a quick look at them when talking about processes. For now, let's take a look at some of the basic operators that go with our basic types.

getting-started/case-cond-and-if.markdown

+1-1
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,7 @@ iex> if true, do: 1 + 2
179179
3
180180
```
181181

182-
Notice how the example above has a comma between `true` and `do:`, that's because it is using Elixir's regular syntax where each argument is separated by comma. We say this syntax is using *keyword lists*. We can pass `else` using keywords too:
182+
Notice how the example above has a comma between `true` and `do:`, that's because it is using Elixir's regular syntax where each argument is separated by a comma. We say this syntax is using *keyword lists*. We can pass `else` using keywords too:
183183

184184
```iex
185185
iex> if false, do: :this, else: :that

getting-started/comprehensions.markdown

+3-3
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,11 @@ iex> for n <- [1, 2, 3, 4], do: n * n
1616
[1, 4, 9, 16]
1717
```
1818

19-
A comprehension is made of three parts: generators, filters and collectables.
19+
A comprehension is made of three parts: generators, filters, and collectables.
2020

2121
## Generators and filters
2222

23-
In the expression above, `n <- [1, 2, 3, 4]` is the **generator**. It is literally generating values to be used in the comprehension. Any enumerable can be passed in the right-hand side of the generator expression:
23+
In the expression above, `n <- [1, 2, 3, 4]` is the **generator**. It is literally generating values to be used in the comprehension. Any enumerable can be passed on the right-hand side of the generator expression:
2424

2525
```iex
2626
iex> for n <- 1..4, do: n * n
@@ -135,7 +135,7 @@ iex> for <<c <- " hello world ">>, c != ?\s, into: "", do: <<c>>
135135
"helloworld"
136136
```
137137

138-
Sets, maps and other dictionaries can also be given to the `:into` option. In general, `:into` accepts any structure that implements the `Collectable` protocol.
138+
Sets, maps, and other dictionaries can also be given to the `:into` option. In general, `:into` accepts any structure that implements the `Collectable` protocol.
139139

140140
A common use case of `:into` can be transforming values in a map, without touching the keys:
141141

getting-started/enumerables-and-streams.markdown

+1-1
Original file line numberDiff line numberDiff line change
@@ -121,4 +121,4 @@ The example above will fetch the first 10 lines of the file you have selected. T
121121

122122
The amount of functionality in the [`Enum`](https://hexdocs.pm/elixir/Enum.html) and [`Stream`](https://hexdocs.pm/elixir/Stream.html) modules can be daunting at first, but you will get familiar with them case by case. In particular, focus on the `Enum` module first and only move to `Stream` for the particular scenarios where laziness is required, to either deal with slow resources or large, possibly infinite, collections.
123123

124-
Next we'll look at a feature central to Elixir, Processes, which allows us to write concurrent, parallel and distributed programs in an easy and understandable way.
124+
Next, we'll look at a feature central to Elixir, Processes, which allows us to write concurrent, parallel and distributed programs in an easy and understandable way.

getting-started/erlang-libraries.markdown

+4-4
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,10 @@ title: Erlang libraries
99

1010
Elixir provides excellent interoperability with Erlang libraries. In fact,
1111
Elixir discourages simply wrapping Erlang libraries in favor of directly
12-
interfacing with Erlang code. In this section we will present some of the
12+
interfacing with Erlang code. In this section, we will present some of the
1313
most common and useful Erlang functionality that is not found in Elixir.
1414

15-
As you grow more proficient in Elixir, you may want to explore the Erlang
15+
As you grow more proficient in Elixir, you may want to explore the Erlang
1616
[STDLIB Reference Manual](http://erlang.org/doc/apps/stdlib/index.html) in more
1717
detail.
1818

@@ -77,8 +77,8 @@ end
7777
[The digraph module](http://erlang.org/doc/man/digraph.html) (as well as
7878
[digraph_utils](http://erlang.org/doc/man/digraph_utils.html)) contains
7979
functions for dealing with directed graphs built of vertices and edges.
80-
After constructing the graph, the algorithms in there will help finding
81-
for instance the shortest path between two vertices, or loops in the graph.
80+
After constructing the graph, the algorithms in there will help finding,
81+
for instance, the shortest path between two vertices, or loops in the graph.
8282

8383
Given three vertices, find the shortest path from the first to the last.
8484

getting-started/introduction.markdown

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ redirect_from: /getting_started/1.html
1010

1111
Welcome!
1212

13-
In this tutorial we are going to teach you the Elixir foundation, the language syntax, how to define modules, how to manipulate the characteristics of common data structures, and more. This chapter will focus on ensuring Elixir is installed and that you can successfully run Elixir's Interactive Shell, called IEx.
13+
In this tutorial, we are going to teach you the Elixir foundation, the language syntax, how to define modules, how to manipulate the characteristics of common data structures, and more. This chapter will focus on ensuring Elixir is installed and that you can successfully run Elixir's Interactive Shell, called IEx.
1414

1515
Our requirements are:
1616

getting-started/io-and-the-file-system.markdown

+5-5
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ iex> Path.expand("~/hello")
9898

9999
Using functions from the `Path` module as opposed to directly manipulating strings is preferred since the `Path` module takes care of different operating systems transparently. Finally, keep in mind that Elixir will automatically convert slashes (`/`) into backslashes (`\`) on Windows when performing file operations.
100100

101-
With this we have covered the main modules that Elixir provides for dealing with IO and interacting with the file system. In the next sections, we will discuss some advanced topics regarding IO. Those sections are not necessary in order to write Elixir code, so feel free to skip them, but they do provide a nice overview of how the IO system is implemented in the <abbr title="Virtual Machine">VM</abbr> and other curiosities.
101+
With this, we have covered the main modules that Elixir provides for dealing with IO and interacting with the file system. In the next sections, we will discuss some advanced topics regarding IO. Those sections are not necessary in order to write Elixir code, so feel free to skip them, but they do provide a nice overview of how the IO system is implemented in the <abbr title="Virtual Machine">VM</abbr> and other curiosities.
102102

103103
## Processes and group leaders
104104

@@ -133,7 +133,7 @@ iex> IO.read(pid, 2)
133133
"he"
134134
```
135135

136-
By modelling IO devices with processes, the Erlang <abbr title="Virtual Machine">VM</abbr> allows different nodes in the same network to exchange file processes in order to read/write files in between nodes. Of all IO devices, there is one that is special to each process: the **group leader**.
136+
By modeling IO devices with processes, the Erlang <abbr title="Virtual Machine">VM</abbr> allows different nodes in the same network to exchange file processes in order to read/write files in between nodes. Of all IO devices, there is one that is special to each process: the **group leader**.
137137

138138
When you write to `:stdio`, you are actually sending a message to the group leader, which writes to the standard-output file descriptor:
139139

@@ -150,9 +150,9 @@ The group leader can be configured per process and is used in different situatio
150150

151151
## `iodata` and `chardata`
152152

153-
In all of the examples above, we used binaries when writing to files. In the chapter ["Binaries, strings and char lists"](/getting-started/binaries-strings-and-char-lists.html), we mentioned how strings are made of bytes while char lists are lists with unicode codepoints.
153+
In all of the examples above, we used binaries when writing to files. In the chapter ["Binaries, strings and char lists"](/getting-started/binaries-strings-and-char-lists.html), we mentioned how strings are made of bytes while char lists are lists with Unicode codepoints.
154154

155-
The functions in `IO` and `File` also allow lists to be given as arguments. Not only that, they also allow a mixed list of lists, integers and binaries to be given:
155+
The functions in `IO` and `File` also allow lists to be given as arguments. Not only that, they also allow a mixed list of lists, integers, and binaries to be given:
156156

157157
```iex
158158
iex> IO.puts 'hello world'
@@ -163,7 +163,7 @@ hello world
163163
:ok
164164
```
165165

166-
However, using list in IO operations requires some attention. A list may represent either a bunch of bytes or a bunch of characters and which one to use depends on the encoding of the IO device. If the file is opened without encoding, the file is expected to be in raw mode, and the functions in the `IO` module starting with `bin*` must be used. Those functions expect an `iodata` as argument; i.e., they expect a list of integers representing bytes and binaries to be given.
166+
However, using lists in IO operations requires some attention. A list may represent either a bunch of bytes or a bunch of characters and which one to use depends on the encoding of the IO device. If the file is opened without encoding, the file is expected to be in raw mode, and the functions in the `IO` module starting with `bin*` must be used. Those functions expect an `iodata` as an argument; i.e., they expect a list of integers representing bytes and binaries to be given.
167167

168168
On the other hand, `:stdio` and files opened with `:utf8` encoding work with the remaining functions in the `IO` module. Those functions expect a `char_data` as an argument, that is, a list of characters or strings.
169169

getting-started/meta/domain-specific-languages.markdown

+3-3
Original file line numberDiff line numberDiff line change
@@ -39,9 +39,9 @@ Of all the approaches above, the first is definitely the most flexible. If our d
3939

4040
The second approach uses function calls which better suits more complex APIs (for example, if you need to pass many options) and reads nicely in Elixir thanks to the pipe operator.
4141

42-
The third approach, uses macros, and is by far the most complex. It will take more lines of code to implement, it is hard and expensive to test (compared to testing simple functions), and it limits how the user may use the library since all validations need to be defined inside a module.
42+
The third approach uses macros, and is by far the most complex. It will take more lines of code to implement, it is hard and expensive to test (compared to testing simple functions), and it limits how the user may use the library since all validations need to be defined inside a module.
4343

44-
To drive the point home, imagine you want to validate a certain attribute only if a given condition is met. We could easily achieve it with the first solution, by manipulating the data structure accordingly, or with the second solution by using conditionals (if/else) before invoking the function. However it is impossible to do so with the macros approach unless its DSL is augmented.
44+
To drive the point home, imagine you want to validate a certain attribute only if a given condition is met. We could easily achieve it with the first solution, by manipulating the data structure accordingly, or with the second solution by using conditionals (if/else) before invoking the function. However, it is impossible to do so with the macros approach unless its DSL is augmented.
4545

4646
In other words:
4747

@@ -119,7 +119,7 @@ iex> defmodule MyTest do
119119
...> end
120120
```
121121

122-
For now we don't have a mechanism to run tests, but we know that a function named "test hello" was defined behind the scenes. When we invoke it, it should fail:
122+
For now, we don't have a mechanism to run tests, but we know that a function named "test hello" was defined behind the scenes. When we invoke it, it should fail:
123123

124124
```iex
125125
iex> MyTest."test hello"()

getting-started/meta/macros.markdown

+2-2
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ title: Macros
1111

1212
Even though Elixir attempts its best to provide a safe environment for macros, the major responsibility of writing clean code with macros falls on developers. Macros are harder to write than ordinary Elixir functions and it's considered to be bad style to use them when they're not necessary. So write macros responsibly.
1313

14-
Elixir already provides mechanisms to write your every day code in a simple and readable fashion by using its data structures and functions. Macros should only be used as a last resort. Remember that **explicit is better than implicit**. **Clear code is better than concise code.**
14+
Elixir already provides mechanisms to write your everyday code in a simple and readable fashion by using its data structures and functions. Macros should only be used as a last resort. Remember that **explicit is better than implicit**. **Clear code is better than concise code.**
1515

1616
## Our first macro
1717

@@ -208,7 +208,7 @@ Take note of the second argument to `Macro.var/2`. This is the context being use
208208

209209
When calling `Macro.expand_once/2` earlier in this chapter, we used the special form `__ENV__`.
210210

211-
`__ENV__` returns an instance of the `Macro.Env` struct which contains useful information about the compilation environment, including the current module, file and line, all variables defined in the current scope, as well as imports, requires and so on:
211+
`__ENV__` returns an instance of the `Macro.Env` struct which contains useful information about the compilation environment, including the current module, file, and line, all variables defined in the current scope, as well as imports, requires and so on:
212212

213213
```iex
214214
iex> __ENV__.module

getting-started/meta/quote-and-unquote.markdown

+2-2
Original file line numberDiff line numberDiff line change
@@ -154,8 +154,8 @@ iex> Macro.escape(map)
154154

155155
Macros receive quoted expressions and must return quoted expressions. However, sometimes during the execution of a macro, you may need to work with values and making a distinction between values and quoted expressions will be required.
156156

157-
In other words, it is important to make a distinction between a regular Elixir value (like a list, a map, a process, a reference, etc) and a quoted expression. Some values, such as integers, atoms and strings, have a quoted expression equal to the value itself. Other values, like maps, need to be explicitly converted. Finally, values like functions and references cannot be converted to a quoted expression at all.
157+
In other words, it is important to make a distinction between a regular Elixir value (like a list, a map, a process, a reference, etc) and a quoted expression. Some values, such as integers, atoms, and strings, have a quoted expression equal to the value itself. Other values, like maps, need to be explicitly converted. Finally, values like functions and references cannot be converted to a quoted expression at all.
158158

159159
You can read more about `quote` and `unquote` in the [`Kernel.SpecialForms` module](https://hexdocs.pm/elixir/Kernel.SpecialForms.html). Documentation for `Macro.escape/1` and other functions related to quoted expressions can be found in the [`Macro` module](https://hexdocs.pm/elixir/Macro.html).
160160

161-
In this introduction we have laid the groundwork to finally write our first macro, so let's move to the next chapter.
161+
In this introduction, we have laid the groundwork to finally write our first macro, so let's move to the next chapter.

getting-started/mix-otp/agent.markdown

+2-2
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ Elixir is an immutable language where nothing is shared by default. If we want t
2020
* Processes
2121
* [ETS (Erlang Term Storage)](http://www.erlang.org/doc/man/ets.html)
2222

23-
We covered processes in the Getting Started guide. <abbr title="Erlang Term Storage">ETS</abbr> is a new topic that will explore on later chapters. When it comes to processes though, we rarely hand-roll our own, instead we use the abstractions available in Elixir and <abbr title="Open Telecom Platform">OTP</abbr>:
23+
We covered processes in the Getting Started guide. <abbr title="Erlang Term Storage">ETS</abbr> is a new topic that will explore in later chapters. When it comes to processes though, we rarely hand-roll our own, instead we use the abstractions available in Elixir and <abbr title="Open Telecom Platform">OTP</abbr>:
2424

2525
* [Agent](https://hexdocs.pm/elixir/Agent.html) - Simple wrappers around state.
2626
* [GenServer](https://hexdocs.pm/elixir/GenServer.html) - "Generic servers" (processes) that encapsulate state, provide sync and async calls, support code reloading, and more.
@@ -197,4 +197,4 @@ end
197197

198198
When a long action is performed on the server, all other requests to that particular server will wait until the action is done, which may cause some clients to timeout.
199199

200-
In the next chapter we will explore GenServers, where the segregation between clients and servers is made more apparent.
200+
In the next chapter, we will explore GenServers, where the segregation between clients and servers is made more apparent.

0 commit comments

Comments
 (0)