Skip to content

Commit 42141b2

Browse files
authored
Merge pull request #55 from pedropark99/revision-7
Add revision for Chapter 7
2 parents 24b6540 + a77a580 commit 42141b2

18 files changed

+230
-237
lines changed

Chapters/01-memory.qmd

+4-4
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ knitr::opts_chunk$set(
2020

2121

2222
In this chapter, we will talk about memory. How does Zig controls memory? What
23-
commom tools are used? Are there any important aspect that makes memory
23+
common tools are used? Are there any important aspect that makes memory
2424
different/special in Zig? You will find the answers here.
2525

2626
Every computer needs memory. Is by having memory that computers can temporarily store
@@ -153,7 +153,7 @@ probably have heard of the "duel" between Stack vs Heap. These are two different
153153
or different memory spaces, which are both available in Zig.
154154

155155
These two types of memory don't actually duel with
156-
each other. This is a commom mistake that beginners have, when seeing "x vs y" styles of
156+
each other. This is a common mistake that beginners have, when seeing "x vs y" styles of
157157
tabloid headlines. These two types of memory are actually complementary to each other.
158158
So, in almost every Zig program that you ever write, you will likely use a combination of both.
159159
I will describe each memory space in detail over the next sections. But for now, I just want to
@@ -461,7 +461,7 @@ a space in the stack is reserved for this function call. But the stack
461461
have a key limitation which is: every object stored in the stack have a
462462
known fixed length.
463463

464-
But in reality, there are two very commom instances where this "fixed length limitation" of the stack is a deal braker:
464+
But in reality, there are two very common instances where this "fixed length limitation" of the stack is a deal braker:
465465

466466
1. the objects that you create inside your function might grow in size during the execution of the function.
467467

@@ -473,7 +473,7 @@ stack. However, if this object is stored in the heap, then, you can return a poi
473473
end of the function. Because you (the programmer) control the lyfetime of any heap memory that you allocate. You decide
474474
when this memory get's destroyed/freed.
475475

476-
These are commom situations where the stack is not good for.
476+
These are common situations where the stack is not good for.
477477
That is why you need a different memory management strategy to
478478
store these objects inside your function. You need to use
479479
a memory type that can grow together with your objects, or that you

Chapters/01-zig-weird.qmd

+3-3
Original file line numberDiff line numberDiff line change
@@ -765,15 +765,15 @@ _ = ns; _ = ls;
765765
Is worth noting that these are static arrays, meaning that
766766
they cannot grow in size.
767767
Once you declare your array, you cannot change the size of it.
768-
This is very commom in low level languages.
768+
This is very common in low level languages.
769769
Because low level languages normally wants to give you (the programmer) full control over memory,
770770
and the way in which arrays are expanded is tightly related to
771771
memory management.
772772

773773

774774
### Selecting elements of the array {#sec-select-array-elem}
775775

776-
One very commom activity is to select specific portions of an array
776+
One very common activity is to select specific portions of an array
777777
you have in your source code.
778778
In Zig, you can select a specific element from your
779779
array, by simply providing the index of this particular
@@ -1302,7 +1302,7 @@ got codepoint E382AB
13021302
```
13031303

13041304

1305-
### Some useful functions for strings
1305+
### Some useful functions for strings {#sec-strings-useful-funs}
13061306

13071307
In this section, I just want to quickly describe some functions from the Zig Standard Library
13081308
that are very useful to use when working with strings. Most notably:

Chapters/03-structs.qmd

+3-3
Original file line numberDiff line numberDiff line change
@@ -804,7 +804,7 @@ of an existing object.
804804
If the compiler do find such type annotation, then, it will use this
805805
type in your literal struct.
806806

807-
Anonymous structs are very commom to be used as inputs to function arguments in Zig.
807+
Anonymous structs are very common to be used as inputs to function arguments in Zig.
808808
One example that you have seen already constantly, is the `print()`
809809
function from the `stdout` object.
810810
This function takes two arguments.
@@ -1073,7 +1073,7 @@ as you would expect from a traditional strongly typed language, such as C and C+
10731073

10741074
In some situations, the `zig` compiler can use type inference to solves the data types for you, easing some of
10751075
the burden that you carry as a developer.
1076-
The most commom way this happens is through function arguments that receives struct objects
1076+
The most common way this happens is through function arguments that receives struct objects
10771077
as input.
10781078

10791079
In general, type inference in Zig is done by using the dot character (`.`).
@@ -1089,7 +1089,7 @@ This type inference is done by looking for some minimal hint of the correct data
10891089
You could say that the `zig` compiler looks for any neighbouring type annotation that might tell him
10901090
what would be the correct type.
10911091

1092-
Another commom place where we use type inference in Zig is at switch statements (which we talk about at @sec-switch).
1092+
Another common place where we use type inference in Zig is at switch statements (which we talk about at @sec-switch).
10931093
I also gave some other examples of type inference at @sec-switch, where we were inferring the data types of enum values listed inside
10941094
of switch statements (e.g. `.DE`).
10951095
But as another example, take a look at this `fence()` function reproduced below,

Chapters/03-unittests.qmd

+1-1
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,7 @@ Test [1/1] leak_memory.test.memory leak...
175175

176176
## Testing errors
177177

178-
One commom style of unit tests are those that look for
178+
One common style of unit tests are those that look for
179179
specific errors in your functions. In other words, you write
180180
a unit test that tries to assert if a specific function call
181181
returns any error, or a specific type of error.

0 commit comments

Comments
 (0)