@@ -40,7 +40,7 @@ NB: You can also pass one of `-gcc`, `-msvc`, `-clang` to `make.bat` instead,
4040if you do prefer to use a different C compiler, but -tcc is small, fast, and
4141easy to install (V will download a prebuilt binary automatically).
4242
43- For C compiler downloads and more info, see
43+ For C compiler downloads and more info, see
4444[ here] ( https://github.com/vlang/v/wiki/Installing-a-C-compiler-on-Windows ) .
4545
4646It is recommended to add this folder to the PATH of your environment variables.
@@ -843,7 +843,7 @@ println(nums.cap) // "3" or greater
843843nums = [] // The array is now empty
844844println(nums.len) // "0"
845845```
846- ` data ` is a field (of type ` voidptr ` ) with the address of the first
846+ ` data ` is a field (of type ` voidptr ` ) with the address of the first
847847element. This is for low-level [ ` unsafe ` ] ( #memory-unsafe-code ) code.
848848
849849Note that the fields are read-only and can't be modified by the user.
@@ -892,7 +892,7 @@ for i in 0 .. 1000 {
892892```
893893Note: The above code uses a [ range ` for ` ] ( #range-for ) statement.
894894
895- You can initialize the array by accessing the ` it ` variable which gives
895+ You can initialize the array by accessing the ` it ` variable which gives
896896the index as shown here:
897897
898898``` v
@@ -1022,7 +1022,7 @@ upper_fn := words.map(fn (w string) string {
10221022println(upper_fn) // ['HELLO', 'WORLD']
10231023```
10241024
1025- ` it ` is a builtin variable which refers to the element currently being
1025+ ` it ` is a builtin variable which refers to the element currently being
10261026processed in filter/map methods.
10271027
10281028Additionally, ` .any() ` and ` .all() ` can be used to conveniently test
@@ -1035,8 +1035,8 @@ println(nums.all(it >= 2)) // false
10351035```
10361036
10371037There are further built-in methods for arrays:
1038- * ` a.repeat(n) ` concatenates the array elements ` n ` times
1039- * ` a.insert(i, val) ` inserts a new element ` val ` at index ` i ` and
1038+ * ` a.repeat(n) ` concatenates the array elements ` n ` times
1039+ * ` a.insert(i, val) ` inserts a new element ` val ` at index ` i ` and
10401040 shifts all following elements to the right
10411041* ` a.insert(i, [3, 4, 5]) ` inserts several elements
10421042* ` a.prepend(val) ` inserts a value at the beginning, equivalent to ` a.insert(0, val) `
@@ -1052,7 +1052,7 @@ There are further built-in methods for arrays:
10521052* ` a.pop() ` removes the last element and returns it
10531053* ` a.reverse() ` makes a new array with the elements of ` a ` in reverse order
10541054* ` a.reverse_in_place() ` reverses the order of elements in ` a `
1055- * ` a.join(joiner) ` concatenates an array of strings into one string
1055+ * ` a.join(joiner) ` concatenates an array of strings into one string
10561056 using ` joiner ` string as a separator
10571057
10581058See also [ vlib/arrays] ( https://modules.vlang.io/arrays.html ) .
@@ -1185,7 +1185,7 @@ println(b) // [7, 3]
11851185
11861186V supports array and string slices with negative indexes.
11871187Negative indexing starts from the end of the array towards the start,
1188- for example ` -3 ` is equal to ` array.len - 3 ` .
1188+ for example ` -3 ` is equal to ` array.len - 3 ` .
11891189Negative slices have a different syntax from normal slices, i.e. you need
11901190to add a ` gate ` between the array name and the square bracket: ` a#[..-3] ` .
11911191The ` gate ` specifies that this is a different type of slice and remember that
@@ -2223,7 +2223,7 @@ button.Size = Size{
22232223If multiple embedded structs have methods or fields with the same name, or if methods or fields
22242224with the same name are defined in the struct, you can call methods or assign to variables in
22252225the embedded struct like ` button.Size.area() ` .
2226- When you do not specify the embedded struct name, the method of the outermost struct will be
2226+ When you do not specify the embedded struct name, the method of the outermost struct will be
22272227targeted.
22282228
22292229## Unions
@@ -2951,7 +2951,7 @@ a convenience for writing `s.xyz()` instead of `xyz(s)`.
29512951N.B. This feature is NOT a "default implementation" like in C#.
29522952
29532953For example, if a struct ` cat ` is wrapped in an interface ` a ` , that has
2954- implemented a method with the same name ` speak ` , as a method implemented by
2954+ implemented a method with the same name ` speak ` , as a method implemented by
29552955the struct, and you do ` a.speak() ` , * only* the interface method is called:
29562956
29572957``` v
@@ -3491,13 +3491,13 @@ Above, `http.get` returns a `?http.Response`. `resp` is only in scope for the fi
34913491
34923492## Custom error types
34933493
3494- V gives you the ability to define custom error types through the ` IError ` interface.
3495- The interface requires two methods: ` msg() string ` and ` code() int ` . Every type that
3496- implements these methods can be used as an error.
3494+ V gives you the ability to define custom error types through the ` IError ` interface.
3495+ The interface requires two methods: ` msg() string ` and ` code() int ` . Every type that
3496+ implements these methods can be used as an error.
34973497
3498- When defining a custom error type it is recommended to embed the builtin ` Error ` default
3499- implementation. This provides an empty default implementation for both required methods,
3500- so you only have to implement what you really need, and may provide additional utility
3498+ When defining a custom error type it is recommended to embed the builtin ` Error ` default
3499+ implementation. This provides an empty default implementation for both required methods,
3500+ so you only have to implement what you really need, and may provide additional utility
35013501functions in the future.
35023502
35033503``` v
@@ -4112,8 +4112,8 @@ memory manually. (See [attributes](#attributes)).
41124112_ Note: right now autofree is hidden behind the -autofree flag. It will be enabled by
41134113default in V 0.3. If autofree is not used, V programs will leak memory._
41144114
4115- Note 2: Autofree is still WIP. Until it stabilises and becomes the default, please
4116- compile your long running processes with ` -gc boehm ` , which will use the
4115+ Note 2: Autofree is still WIP. Until it stabilises and becomes the default, please
4116+ compile your long running processes with ` -gc boehm ` , which will use the
41174117Boehm-Demers-Weiser conservative garbage collector, to free the memory, that your
41184118programs leak, at runtime.
41194119
@@ -4702,7 +4702,7 @@ Modules are up to date.
47024702 at the top of all files in your module. For `mymodule.v`:
47034703 ```v
47044704 module mymodule
4705-
4705+
47064706 pub fn hello_world() {
47074707 println('Hello World!')
47084708 }
@@ -5745,11 +5745,11 @@ fn main() {
57455745```
57465746
57475747Build this example with ` v -live message.v ` .
5748-
5749- You can also run this example with ` v -live run message.v ` .
5750- Make sure that in command you use a path to a V's file,
5751- ** not** a path to a folder (like ` v -live run . ` ) -
5752- in that case you need to modify content of a folder (add new file, for example),
5748+
5749+ You can also run this example with ` v -live run message.v ` .
5750+ Make sure that in command you use a path to a V's file,
5751+ ** not** a path to a folder (like ` v -live run . ` ) -
5752+ in that case you need to modify content of a folder (add new file, for example),
57535753 because changes in * message.v* will have no effect.
57545754
57555755Functions that you want to be reloaded must have ` [live] ` attribute
@@ -5978,10 +5978,15 @@ fn custom_allocations() {
59785978struct C.Foo {
59795979}
59805980
5981- // Used in Win32 API code when you need to pass callback function
5982- [windows_stdcall]
5981+ // Used to add a custom calling convention to a function, available calling convention: stdcall, fastcall and cdecl.
5982+ // This list aslo apply for type aliases (see below).
5983+ [callconv: "stdcall"]
59835984fn C.DefWindowProc(hwnd int, msg int, lparam int, wparam int)
59845985
5986+ // Used to add a custom calling convention to a function type aliases.
5987+ [callconv: "fastcall"]
5988+ type FastFn = fn (int) bool
5989+
59855990// Windows only:
59865991// If a default graphics library is imported (ex. gg, ui), then the graphical window takes
59875992// priority and no console window is created, effectively disabling println() statements.
0 commit comments