Skip to content

Commit 9c2f595

Browse files
authored
Merge pull request #71 from pedropark99/spelling-fixes
Fix multiple spelling errors
2 parents 7ce5cb5 + 6729ee7 commit 9c2f595

File tree

43 files changed

+211
-200
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

43 files changed

+211
-200
lines changed

Chapters/01-base64.qmd

+3-3
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,7 @@ But the input string does not have enough bytes to create a fourth 6-bit group.
184184
Every time this happens, where an entire group of 6 bits is empty,
185185
this group becomes a "padding group". Every "padding group" is mapped to
186186
the character `=` (equal sign), which represents "null", or, the end
187-
of meaninful characters in the sequence. Hence, everytime that the algorithm produces a
187+
of meaningful characters in the sequence. Hence, everytime that the algorithm produces a
188188
"padding group", this group is automatically mapped to `=`.
189189

190190
As another example, if you give the string "0" as input to a base64 encoder, this string is
@@ -221,7 +221,7 @@ summarized these transformations as "Some bit shifting and additions ..." in the
221221
will be described in depth later.
222222

223223
Besides that, if you look again at @fig-base64-algo2, you will notice that the character `=` was completely
224-
ignored by the algorithm. Remember, this is just a special character that marks the end of meaninful characters
224+
ignored by the algorithm. Remember, this is just a special character that marks the end of meaningful characters
225225
in the base64 sequence. So, every `=` character in a base64 encoded sequence should be ignored by a base64 decoder.
226226

227227

@@ -738,7 +738,7 @@ Notice that the output byte is the sequence `ABCDEFGH`, which is the original by
738738

739739
![How the 1st byte in the decoder output is produced from the 1st byte (dark purple) and the 2nd byte (orange) of the input](../Figures/base64-decoder-bit-shift.png){#fig-decoder-bitshift}
740740

741-
The @tbl-6bit-decode presents how the three steps described ealier translate into Zig code:
741+
The @tbl-6bit-decode presents how the three steps described earlier translate into Zig code:
742742

743743

744744

Chapters/01-memory.qmd

+2-2
Original file line numberDiff line numberDiff line change
@@ -467,14 +467,14 @@ But in reality, there are two very common instances where this "fixed length lim
467467
Also, there is another instance where you might want to use an allocator, which is when you want to write a function that returns a pointer
468468
to a local object. As I described at @sec-stack, you cannot do that if this local object is stored in the
469469
stack. However, if this object is stored in the heap, then, you can return a pointer to this object at the
470-
end of the function. Because you (the programmer) control the lyfetime of any heap memory that you allocate. You decide
470+
end of the function. Because you (the programmer) control the lifetime of any heap memory that you allocate. You decide
471471
when this memory get's destroyed/freed.
472472

473473
These are common situations where the stack is not good for.
474474
That is why you need a different memory management strategy to
475475
store these objects inside your function. You need to use
476476
a memory type that can grow together with your objects, or that you
477-
can control the lyfetime of this memory.
477+
can control the lifetime of this memory.
478478
The heap fit this description.
479479

480480
Allocating memory on the heap is commonly known as dynamic memory management. As the objects you create grow in size

Chapters/01-zig-weird.qmd

+5-5
Original file line numberDiff line numberDiff line change
@@ -847,7 +847,7 @@ As we discussed before, in Zig, you can select specific portions of an existing
847847
array. This is called *slicing* in Zig [@zigguide], because when you select a portion
848848
of an array, you are creating a slice object from that array.
849849

850-
A slice object is essentially a pointer object accompained by a length number.
850+
A slice object is essentially a pointer object accompanied by a length number.
851851
The pointer object points to the first element in the slice, and the
852852
length number tells the `zig` compiler how many elements there are in this slice.
853853

@@ -1071,7 +1071,7 @@ have problems in Zig.
10711071
[^libiconv]: <https://www.gnu.org/software/libiconv/>
10721072

10731073
Let’s take for example the word "Hello". In UTF-8, this sequence of characters (H, e, l, l, o)
1074-
is represented by the sequence of decimal numbers 72, 101, 108, 108, 111. In xecadecimal, this
1074+
is represented by the sequence of decimal numbers 72, 101, 108, 108, 111. In hexadecimal, this
10751075
sequence is `0x48`, `0x65`, `0x6C`, `0x6C`, `0x6F`. So if I take this sequence of hexadecimal values,
10761076
and ask Zig to print this sequence of bytes as a sequence of characters (i.e. a string), then,
10771077
the text "Hello" will be printed into the terminal:
@@ -1123,7 +1123,7 @@ your trying to access memory that does not belong to you.
11231123

11241124
To achieve this same kind of safety in C, you have to do a lot of work that kind of seems pointless.
11251125
So getting this kind of safety is not automatic and much harder to do in C. For example, if you want
1126-
to track the length of your string troughout your program in C, then, you first need to loop through
1126+
to track the length of your string throughout your program in C, then, you first need to loop through
11271127
the array of bytes that represents this string, and find the null element (`'\0'`) position to discover
11281128
where exactly the array ends, or, in other words, to find how much elements the array of bytes contain.
11291129

@@ -1418,7 +1418,7 @@ N of replacements: 1
14181418
## Safety in Zig
14191419

14201420
A general trend in modern low-level programming languages is safety. As our modern world
1421-
become more interconnected with techology and computers,
1421+
become more interconnected with technology and computers,
14221422
the data produced by all of this technology becomes one of the most important
14231423
(and also, one of the most dangerous) assets that we have.
14241424

@@ -1466,7 +1466,7 @@ The tools listed below are related to memory safety. That is, they help you to a
14661466
memory safety in your Zig code:
14671467

14681468
- `defer` allows you to keep free operations phisically close to allocations. This helps you to avoid memory leaks, "use after free", and also "double-free" problems. Furthermore, it also keeps free operations logically tied to the end of the current scope, which greatly reduces the mental overhead about object lifetime.
1469-
- `errdefer` helps you to garantee that your program frees the allocated memory, even if a runtime error occurs.
1469+
- `errdefer` helps you to guarantee that your program frees the allocated memory, even if a runtime error occurs.
14701470
- pointers and objects are non-nullable by default. This helps you to avoid memory problems that might arise from de-referencing null pointers.
14711471
- Zig offers some native types of allocators (called "testing allocators") that can detect memory leaks and double-frees. These types of allocators are widely used on unit tests, so they transform your unit tests into a weapon that you can use to detect memory problems in your code.
14721472
- arrays and slices in Zig have their lengths embedded in the object itself, which makes the `zig` compiler very effective on detecting "index out-of-range" type of errors, and avoiding buffer overflows.

Chapters/03-structs.qmd

+2-2
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,7 @@ This is what "exhaust all existing possibilities" means. The switch statement co
163163
every possible case.
164164

165165
Therefore, you cannot write a switch statement in Zig, and leave an edge case
166-
with no expliciting action to be taken.
166+
with no explicit action to be taken.
167167
This is a similar behaviour to switch statements in Rust, which also have to
168168
handle all possible cases.
169169

@@ -794,7 +794,7 @@ _ = eu;
794794
```
795795

796796
However, in Zig, we can also write an anonymous struct literal. That is, you can write a
797-
struct literal, but not especify explicitly the type of this particular struct.
797+
struct literal, but not specify explicitly the type of this particular struct.
798798
An anonymous struct is written by using the syntax `.{}`. So, we essentially
799799
replaced the explicit type of the struct literal with a dot character (`.`).
800800

Chapters/04-http-server.qmd

+6-6
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,7 @@ a separate Zig module. I will name it `config.zig`.
166166

167167
In Zig, we can create a web socket using
168168
the `std.posix.socket()` function, from the Zig Standard Library.
169-
As I meantioned earlier at @sec-http-how-impl, every socket object that we create
169+
As I mentioned earlier at @sec-http-how-impl, every socket object that we create
170170
represents a communication channel, and we need to bind this channel to a specific address.
171171
An "address" is defined as an IP address, or, more specifically, an IPv4 address^[It can be also an IPv6 address. But normally, we use a IPv4 address for that.].
172172
Every IPv4 address is composed by two components. The first component is the host,
@@ -178,7 +178,7 @@ The sequence of 4 numbers (i.e. the host) identifies the machine (i.e. the compu
178178
this socket will live in. Every computer normally have multiple "doors" available inside of him, because
179179
this allows the computer to receive and work with multiple connections at the same time.
180180
He simply use a single door for each connection. So the port number, is
181-
essentially a number that identifies the specific door in the computer that will be resposible
181+
essentially a number that identifies the specific door in the computer that will be responsible
182182
for receiving the connection. That is, it identifies the "door" in the computer that the socket will use
183183
to receive incoming connections.
184184

@@ -374,8 +374,8 @@ we have provided as input.
374374
Notice that I'm using the connection object that we created to read
375375
the message from the client. I first access the `reader` object that lives inside the
376376
connection object. Then, I call the `read()` method of this `reader` object
377-
to effectivelly read and save the data sent by the client into the buffer object
378-
that we created earlier. I'm discarting the return value
377+
to effectively read and save the data sent by the client into the buffer object
378+
that we created earlier. I'm discarding the return value
379379
of the `read()` method, by assigning it to the underscore character (`_`),
380380
because this return value is not useful for us right now.
381381

@@ -493,7 +493,7 @@ needs to represent one of the primary colors, you can create an enum
493493
that represents one of these colors.
494494
In the example below, we are creating the enum `PrimaryColorRGB`, which
495495
represents a primary color from the RGB color system. By using this enum,
496-
I am garanteed that the `acolor` object for example, will contain
496+
I am guaranteed that the `acolor` object for example, will contain
497497
one of these three values: `RED`, `GREEN` or `BLUE`.
498498

499499
```{zig}
@@ -727,7 +727,7 @@ or a `Method` object as result. Since `GET` is currently the only value in our `
727727
structure, it means that, the `init()` method will most likely return the value `Method.GET` as result.
728728

729729
Also notice that, in the `is_supported()` method, we are using the optional value returned
730-
by the `get()` method from our `MethodMap` object. The if statement unwrapes the optional value
730+
by the `get()` method from our `MethodMap` object. The if statement unwraps the optional value
731731
returned by this method, and returns `true` in case this optional value is a not-null value.
732732
Otherwise, it simply returns `false`.
733733

Chapters/05-pointers.qmd

+8-8
Original file line numberDiff line numberDiff line change
@@ -239,17 +239,17 @@ you always get a single-item pointer as result.
239239

240240

241241

242-
## Pointer arithmethic
242+
## Pointer arithmetic
243243

244-
Pointer arithmethic is available in Zig, and they work the same way they work in C.
244+
Pointer arithmetic is available in Zig, and they work the same way they work in C.
245245
When you have a pointer that points to an array, the pointer usually points to
246-
the first element in the array, and you can use pointer arithmethic to
246+
the first element in the array, and you can use pointer arithmetic to
247247
advance this pointer and access the other elements in the array.
248248

249249

250250
Notice in the example below, that initially, the `ptr` object was pointing
251251
to the first element in the array `ar`. But then, I started to walk through the array, by advancing
252-
the pointer with simple pointer arithmethic.
252+
the pointer with simple pointer arithmetic.
253253

254254
```{zig}
255255
#| eval: false
@@ -269,15 +269,15 @@ try stdout.print("{d}\n", .{ptr.*});
269269
```
270270

271271
Although you can create a pointer to an array like that, and
272-
start to walk through this array by using pointer arithmethic,
272+
start to walk through this array by using pointer arithmetic,
273273
in Zig, we prefer to use slices, which were presented at @sec-arrays.
274274

275275
Behind the hood, slices already are pointers,
276276
and they also come with the `len` property, which indicates
277277
how many elements are in the slice. This is good because the `zig` compiler
278278
can use it to check for potential buffer overflows, and other problems like that.
279279

280-
Also, you don't need to use pointer arithmethic to walk through the elements
280+
Also, you don't need to use pointer arithmetic to walk through the elements
281281
of a slice. You can simply use the `slice[index]` syntax to directly access
282282
any element you want in the slice.
283283
As I mentioned at @sec-arrays, you can get a slice from an array by using
@@ -433,7 +433,7 @@ inside the if block.
433433
Using the example below as a reference, if the object `num` is null,
434434
then, the code inside the if statement is not executed. Otherwise,
435435
the if statement will unwrap the object `num` into the `not_null_num`
436-
object. This `not_null_num` object is garanteed to be not null inside
436+
object. This `not_null_num` object is guaranteed to be not null inside
437437
the scope of the if statement.
438438

439439
```{zig}
@@ -472,7 +472,7 @@ to this null value, and the most logic and sane path is to simply panic
472472
and raise a loud error in your program when this null value is encountered,
473473
you can use the `?` method of your optional object.
474474

475-
In essence, when you use this `?` method, the optional object is unwraped.
475+
In essence, when you use this `?` method, the optional object is unwrapped.
476476
If a not-null value is found in the optional object, then, this not-null value is used.
477477
Otherwise, the `unreachable` keyword is used. You can read more about this
478478
[`unreacheable` keyword at the official documentation](https://ziglang.org/documentation/master/#unreachable)[^un-docs].

Chapters/07-build-system.qmd

+1-1
Original file line numberDiff line numberDiff line change
@@ -694,7 +694,7 @@ that defines the binary file that we want to compile.
694694
As an example, I will build the project as a static library file using the `addStaticLibrary()` method
695695
to create the target object.
696696
Also, since FreeType is a C library, I will also link the library
697-
against `libc` through the `linkLibC()` method, to garantee that any use
697+
against `libc` through the `linkLibC()` method, to guarantee that any use
698698
of the C Standard Library is covered in the compilation process.
699699

700700

Chapters/09-data-structures.qmd

+3-3
Original file line numberDiff line numberDiff line change
@@ -301,7 +301,7 @@ and understand how they work.
301301
Some professionals know this type of data structure by different terms, like "map",
302302
"hashmap" or "associative arrays". But the most common term used is *hashtable*.
303303
Every programming language normally have some implementation of a hashtable in their
304-
stardard libraries. Python have `dict()`, C++ have `std::map` and `std::unordered_map`, Rust
304+
standard libraries. Python have `dict()`, C++ have `std::map` and `std::unordered_map`, Rust
305305
have `HashMap`, Javascript have `Object()` and `Map()`, etc.
306306

307307

@@ -328,7 +328,7 @@ This is how a key identifies a specific position (or location) inside the hashta
328328
structure.
329329

330330
Therefore, you provide a key to the hashtable, and this key identifies a specific location
331-
inside the hastable, then, the hashtable takes the input value that you provided,
331+
inside the hashtable, then, the hashtable takes the input value that you provided,
332332
and stores this value in the location identified by this input key.
333333
You could say that the key maps to the value stored in the hashtable. You find
334334
the value, by using the key that identifies the location where the value is stored.
@@ -778,7 +778,7 @@ and an `insertAfter()` (for `next`) methods available.
778778

779779
Thus, if we have used a doubly linked list, we can use the `insertBefore()` method
780780
to store the pointer to the input node in the `prev` attribute. This would put the input
781-
node as the "previous node", or, the node before the current node. In constrast, the `insertAfter()` method
781+
node as the "previous node", or, the node before the current node. In contrast, the `insertAfter()` method
782782
puts the pointer created to the input node in the `next` attribute of the current node,
783783
and as result, the input node becomes the "next node" of the current node.
784784

Chapters/09-error-handling.qmd

+6-6
Original file line numberDiff line numberDiff line change
@@ -384,7 +384,7 @@ into the `number` object.
384384

385385
This means that, if the `parseU64()` expression returns a valid value, this value becomes available
386386
inside the scope of this "if branch" (i.e. the "true branch") through the object that we listed inside the pair
387-
of pipe charactes (`|`), which is the object `number`.
387+
of pipe character (`|`), which is the object `number`.
388388

389389
If an error occurs, we can use an "else branch" (or the "false branch") of the if statement
390390
to handle the error. In the example below, we are using the `else` in the if statement
@@ -429,7 +429,7 @@ if (add_tasks_to_queue(&queue, tasks)) |_| {
429429
// do something
430430
},
431431
error.QueueNotFound => {
432-
// do somethimg
432+
// do something
433433
},
434434
// and all the other error options ...
435435
}
@@ -440,7 +440,7 @@ if (add_tasks_to_queue(&queue, tasks)) |_| {
440440

441441
A common pattern in C programs in general, is to clean resources when an error occurs during
442442
the execution of the program. In other words, one common way to handle errors, is to perform
443-
"cleanup actions" before we exit our program. This garantees that a runtime error does not make
443+
"cleanup actions" before we exit our program. This guarantees that a runtime error does not make
444444
our program to leak resources of the system.
445445

446446

@@ -475,7 +475,7 @@ fn create_user(db: Database, allocator: Allocator) !User {
475475
```
476476

477477
By using `errdefer` to destroy the `user` object that we have just created,
478-
we garantee that the memory allocated for this `user` object
478+
we guarantee that the memory allocated for this `user` object
479479
get's freed, before the execution of the program stops.
480480
Because if the expression `try db.add(user)` returns an error value,
481481
the execution of our program stops, and we lose all references and control over the memory
@@ -506,7 +506,7 @@ In other words, the allocated memory for the `user` object does not get
506506
freed inside the `create_user()` function, if it returns successfully.
507507
So, if an error does not occur inside this function, the `user` object
508508
is returned from the function, and probably, the code that runs after
509-
this `create_user()` function will be responsible for freeying
509+
this `create_user()` function will be responsible for freeing
510510
the memory of the `user` object.
511511

512512
But what if an error occurs inside the `create_user()` function? What happens then?
@@ -515,7 +515,7 @@ function, and, as a consequence, the code that runs after this `create_user()`
515515
function would simply not run, and, as a result, the memory of the `user` object
516516
would not be freed before your program stops.
517517

518-
This is the perfect scenario for `errdefer`. We use this keyword to garantee
518+
This is the perfect scenario for `errdefer`. We use this keyword to guarantee
519519
that our program will free the allocated memory for the `user` object,
520520
even if an error occurs inside the `create_user()` function.
521521

Chapters/10-stack-project.qmd

+2-2
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@ what exactly data type that is. We will talk more about this at @sec-generics.
162162

163163
### Applying over an expression
164164

165-
When you apply the `comptime` keyword over an expression, then, it is garanteed that the `zig` compiler will
165+
When you apply the `comptime` keyword over an expression, then, it is guaranteed that the `zig` compiler will
166166
execute this expression at compile-time. If for some reason, this expression cannot be executed at compile-time
167167
(e.g. for example, maybe this expression depends on a value that is only known at runtime), then, the `zig` compiler
168168
will raise a compilation error.
@@ -201,7 +201,7 @@ We have talked about this at @sec-compile-time.
201201

202202
But when you use the `comptime` keyword on an expression, there is no "it might be executed
203203
at compile-time" anymore. With the `comptime` keyword you are ordering the `zig` compiler
204-
to execute this expression at compile-time. You are imposing this rule, it is garanteed
204+
to execute this expression at compile-time. You are imposing this rule, it is guaranteed
205205
that the compiler will always execute it at compile-time. Or, at least, the compiler
206206
will try to execute it. If the compiler cannot execute the expression for whatever reason,
207207
the compiler will raise a compilation error.

0 commit comments

Comments
 (0)