@@ -107,7 +107,7 @@ For more details and troubleshooting, please visit the [vab GitHub repository](h
107
107
</td ><td width =33% valign =top >
108
108
109
109
* [ Functions 2] ( #functions-2 )
110
- * [ Pure functions by default] ( #pure-functions -by-default )
110
+ * [ Immutable function args by default] ( #immutable-function-args -by-default )
111
111
* [ Mutable arguments] ( #mutable-arguments )
112
112
* [ Variable number of arguments] ( #variable-number-of-arguments )
113
113
* [ Anonymous & higher-order functions] ( #anonymous--higher-order-functions )
@@ -343,8 +343,7 @@ the expression `T(v)` converts the value `v` to the
343
343
type ` T ` .
344
344
345
345
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.
348
347
349
348
For consistency across different code bases, all variable and function names
350
349
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
2279
2278
2280
2279
## Functions 2
2281
2280
2282
- ### Pure functions by default
2281
+ ### Immutable function args by default, mutable args have to be marked on call
2283
2282
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).
2286
2286
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.
2289
2288
2290
2289
V is not a purely functional language however.
2291
2290
@@ -3601,8 +3600,8 @@ println(compare(1.1, 1.2)) // -1
3601
3600
3602
3601
## Concurrency
3603
3602
### 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:
3606
3605
3607
3606
``` v
3608
3607
import math
@@ -3618,6 +3617,9 @@ fn main() {
3618
3617
}
3619
3618
```
3620
3619
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
+
3621
3623
Sometimes it is necessary to wait until a parallel thread has finished. This can
3622
3624
be done by assigning a * handle* to the started thread and calling the ` wait() ` method
3623
3625
to this handle later:
0 commit comments