Skip to content

Commit c17200c

Browse files
authored
doc: clear up concurrency and immutable fn args
1 parent 298dc77 commit c17200c

File tree

1 file changed

+12
-10
lines changed

1 file changed

+12
-10
lines changed

doc/docs.md

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ For more details and troubleshooting, please visit the [vab GitHub repository](h
107107
</td><td width=33% valign=top>
108108

109109
* [Functions 2](#functions-2)
110-
* [Pure functions by default](#pure-functions-by-default)
110+
* [Immutable function args by default](#immutable-function-args-by-default)
111111
* [Mutable arguments](#mutable-arguments)
112112
* [Variable number of arguments](#variable-number-of-arguments)
113113
* [Anonymous & higher-order functions](#anonymous--higher-order-functions)
@@ -343,8 +343,7 @@ the expression `T(v)` converts the value `v` to the
343343
type `T`.
344344

345345
Unlike most other languages, V only allows defining variables in functions.
346-
Global (module level) variables are not allowed. There's no global state in V
347-
(see [Pure functions by default](#pure-functions-by-default) for details).
346+
Global (module level) variables are not allowed. There's no global state in V.
348347

349348
For consistency across different code bases, all variable and function names
350349
must use the `snake_case` style, as opposed to type names, which must use `PascalCase`.
@@ -2279,13 +2278,13 @@ Note that the embedded struct arguments are not necessarily stored in the order
22792278

22802279
## Functions 2
22812280

2282-
### Pure functions by default
2281+
### Immutable function args by default, mutable args have to be marked on call
22832282

2284-
V functions are pure by default, meaning that their return values are a function of their
2285-
arguments only, and their evaluation has no side effects (besides I/O).
2283+
In V function args are immutable by default, mutable args have to be marked on call.
2284+
Since there are also no globals, that means that functions' return values are a function of their
2285+
arguments only, and their evaluation has no side effects (unless the function uses I/O).
22862286

2287-
This is achieved by a lack of global variables and all function arguments being
2288-
immutable by default, even when [references](#references) are passed.
2287+
Function arguments are immutable by default even when [references](#references) are passed.
22892288

22902289
V is not a purely functional language however.
22912290

@@ -3601,8 +3600,8 @@ println(compare(1.1, 1.2)) // -1
36013600

36023601
## Concurrency
36033602
### Spawning Concurrent Tasks
3604-
V's model of concurrency is very similar to Go's. To run `foo()` concurrently in
3605-
a different thread, just call it with `go foo()`:
3603+
V's model of concurrency is going to be very similar to Go's. For now, `go foo()` runs `foo()` concurrently in
3604+
a different thread:
36063605

36073606
```v
36083607
import math
@@ -3618,6 +3617,9 @@ fn main() {
36183617
}
36193618
```
36203619

3620+
> In V 0.4 `go foo()` will be automatically renamed via vfmt to `spawn foo()`, and there will be a way to launch
3621+
a coroutine (a lightweight thread managed by the runtime).
3622+
36213623
Sometimes it is necessary to wait until a parallel thread has finished. This can
36223624
be done by assigning a *handle* to the started thread and calling the `wait()` method
36233625
to this handle later:

0 commit comments

Comments
 (0)