Skip to content

Commit 334f48a

Browse files
committed
doc: cleanup grammar issues in doc/docs.md
1 parent 2f2efb7 commit 334f48a

File tree

1 file changed

+22
-21
lines changed

1 file changed

+22
-21
lines changed

doc/docs.md

Lines changed: 22 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -921,16 +921,16 @@ f2 := 456e+2 // 45600
921921

922922
An array is a collection of data elements of the same type. An array literal is a
923923
list of expressions surrounded by square brackets. An individual element can be
924-
accessed using an *index* expression. Indexes start from `0`:
924+
accessed using an *index* expression. Indexing starts from `0`.
925925

926926
```v
927-
mut nums := [1, 2, 3]
928-
println(nums) // `[1, 2, 3]`
929-
println(nums[0]) // `1`
930-
println(nums[1]) // `2`
927+
mut nums := [10, 20, 30]
928+
println(nums) // `[10, 20, 30]`
929+
println(nums[0]) // `10`
930+
println(nums[1]) // `20`
931931
932932
nums[1] = 5
933-
println(nums) // `[1, 5, 3]`
933+
println(nums) // `[10, 5, 30]`
934934
```
935935

936936
<a id='array-operations'></a>
@@ -4214,8 +4214,8 @@ fn pass_time(w World) {
42144214

42154215
### Option/Result types and error handling
42164216

4217-
Option types are for types which may represent `none`. Result types may
4218-
represent an error returned from a function.
4217+
Option types can represent a value or `none`. Result types may
4218+
represent a value, or an error returned from a function.
42194219

42204220
`Option` types are declared by prepending `?` to the type name: `?Type`.
42214221
`Result` types use `!`: `!Type`.
@@ -4467,9 +4467,9 @@ post := posts_repo.find_by_id(1)? // find_by_id[Post]
44674467
```
44684468

44694469
Currently generic function definitions must declare their type parameters, but in
4470-
future V will infer generic type parameters from single-letter type names in
4471-
runtime parameter types. This is why `find_by_id` can omit `[T]`, because the
4472-
receiver argument `r` uses a generic type `T`.
4470+
future versions, V will infer generic type parameters from single-letter type names in
4471+
runtime parameter types. This is why the `find_by_id(1)` calls above can omit `[T]`,
4472+
because the receiver argument `r` in the method declaration, uses a generic type `T`.
44734473

44744474
Another example:
44754475

@@ -5135,10 +5135,11 @@ Remaining small percentage of objects is freed via GC. The developer doesn't nee
51355135
anything in their code. "It just works", like in Python, Go, or Java, except there's no
51365136
heavy GC tracing everything or expensive RC for each object.
51375137

5138-
For developers willing to have more low level control, memory can be managed manually with
5138+
For developers willing to have more low-level control, memory can be managed manually with
51395139
`-gc none`.
51405140

5141-
Arena allocation is available via v `-prealloc`.
5141+
Arena allocation is available via a `-prealloc` flag. Note: currently this mode is only
5142+
suitable to speed up short lived, single-threaded, batch-like programs (like compilers).
51425143

51435144
### Control
51445145

@@ -5159,7 +5160,7 @@ Just as the compiler frees C data types with C's `free()`, it will statically in
51595160

51605161
Autofree can be enabled with an `-autofree` flag.
51615162

5162-
For developers willing to have more low level control, autofree can be disabled with
5163+
For developers willing to have more low-level control, autofree can be disabled with
51635164
`-manualfree`, or by adding a `[manualfree]` on each function that wants to manage its
51645165
memory manually. (See [attributes](#attributes)).
51655166

@@ -5232,7 +5233,7 @@ be stored:
52325233

52335234
#### V's default approach
52345235

5235-
Due to performance considerations V tries to put objects on the stack if possible
5236+
Due to performance considerations V tries to put objects on the stack if possible,
52365237
but allocates them on the heap when obviously necessary. Example:
52375238

52385239
```v
@@ -7410,7 +7411,7 @@ rm pgo_gen
74107411
74117412
## Atomics
74127413
7413-
V has no special support for atomics, yet, nevertheless it's possible to treat variables as atomics
7414+
V has no special support for atomics yet, nevertheless it's possible to treat variables as atomics
74147415
by [calling C](#v-and-c) functions from V. The standard C11 atomic functions like `atomic_store()`
74157416
are usually defined with the help of macros and C compiler magic to provide a kind of
74167417
*overloaded C functions*.
@@ -7499,7 +7500,7 @@ will hang &ndash; dependent on the compiler optimization used.)
74997500
75007501
## Global Variables
75017502
7502-
By default V does not allow global variables. However, in low level applications they have their
7503+
By default V does not allow global variables. However, in low-level applications they have their
75037504
place so their usage can be enabled with the compiler flag `-enable-globals`.
75047505
Declarations of global variables must be surrounded with a `__global ( ... )`
75057506
specification &ndash; as in the example [above](#atomics).
@@ -7550,7 +7551,7 @@ namespaced globals).
75507551
75517552
Note: their use is discouraged too, for reasons similar to why globals
75527553
are discouraged. The feature is supported to enable translating existing
7553-
low level C code into V code, using `v translate`.
7554+
low-level C code into V code, using `v translate`.
75547555
75557556
Note: the function in which you use a static variable, has to be marked
75567557
with @[unsafe]. Also unlike using globals, using static variables, do not
@@ -7603,7 +7604,7 @@ v -os freebsd .
76037604
> Cross-compiling a Windows binary on a Linux machine requires the GNU C compiler for
76047605
> MinGW-w64 (targeting Win64) to first be installed.
76057606
7606-
For Ubuntu/Debian based distributions:
7607+
For Ubuntu/Debian-based distributions:
76077608
76087609
```shell
76097610
sudo apt install gcc-mingw-w64-x86-64
@@ -7632,7 +7633,7 @@ To debug issues in the generated binary (flag: `-b c`), you can pass these flags
76327633
- `-g` - produces a less optimized executable with more debug information in it.
76337634
V will enforce line numbers from the .v files in the stacktraces, that the
76347635
executable will produce on panic. It is usually better to pass -g, unless
7635-
you are writing low level code, in which case use the next option `-cg`.
7636+
you are writing low-level code, in which case use the next option `-cg`.
76367637
- `-cg` - produces a less optimized executable with more debug information in it.
76377638
The executable will use C source line numbers in this case. It is frequently
76387639
used in combination with `-keepc`, so that you can inspect the generated
@@ -7645,7 +7646,7 @@ To debug issues in the generated binary (flag: `-b c`), you can pass these flags
76457646
compilation. Also keep using the same file path, so it is more stable,
76467647
and easier to keep opened in an editor/IDE.
76477648
7648-
For best debugging experience if you are writing a low level wrapper for an existing
7649+
For best debugging experience if you are writing a low-level wrapper for an existing
76497650
C library, you can pass several of these flags at the same time:
76507651
`v -keepc -cg -showcc yourprogram.v`, then just run your debugger (gdb/lldb) or IDE
76517652
on the produced executable `yourprogram`.

0 commit comments

Comments
 (0)