mirror of
https://github.com/vlang/v.git
synced 2023-08-10 21:13:21 +03:00
fmt: reset const field align after multi line exprs (#9916)
This commit is contained in:
32
doc/docs.md
32
doc/docs.md
@@ -1384,7 +1384,7 @@ fn read_log() {
|
||||
```
|
||||
|
||||
If the function returns a value the `defer` block is executed *after* the return
|
||||
expression is evaluated:
|
||||
expression is evaluated:
|
||||
|
||||
```v
|
||||
import os
|
||||
@@ -1946,7 +1946,7 @@ const (
|
||||
b: 0
|
||||
}
|
||||
// evaluate function call at compile-time*
|
||||
blue = rgb(0, 0, 255)
|
||||
blue = rgb(0, 0, 255)
|
||||
)
|
||||
|
||||
println(numbers)
|
||||
@@ -3122,7 +3122,7 @@ each object.
|
||||
|
||||
### Control
|
||||
|
||||
You can take advantage of V's autofree engine and define a `free()` method on custom
|
||||
You can take advantage of V's autofree engine and define a `free()` method on custom
|
||||
data types:
|
||||
|
||||
```v
|
||||
@@ -3134,7 +3134,7 @@ fn (data &MyType) free() {
|
||||
}
|
||||
```
|
||||
|
||||
Just as the compiler frees C data types with C's `free()`, it will statically insert
|
||||
Just as the compiler frees C data types with C's `free()`, it will statically insert
|
||||
`free()` calls for your data type at the end of each variable's lifetime.
|
||||
|
||||
For developers willing to have more low level control, autofree can be disabled with
|
||||
@@ -3358,7 +3358,7 @@ You will get:
|
||||
[factorial.v:5] n * factorial(n - 1): 120
|
||||
120
|
||||
```
|
||||
Note that `dump(expr)` will trace both the source location,
|
||||
Note that `dump(expr)` will trace both the source location,
|
||||
the expression itself, and the expression value.
|
||||
|
||||
## Memory-unsafe code
|
||||
@@ -3648,9 +3648,9 @@ To cast a `voidptr` to a V reference, use `user := &User(user_void_ptr)`.
|
||||
|
||||
### C Declarations
|
||||
|
||||
C identifiers are accessed with the `C` prefix similarly to how module-specific
|
||||
identifiers are accessed. Functions must be redeclared in V before they can be used.
|
||||
Any C types may be used behind the `C` prefix, but types must be redeclared in V in
|
||||
C identifiers are accessed with the `C` prefix similarly to how module-specific
|
||||
identifiers are accessed. Functions must be redeclared in V before they can be used.
|
||||
Any C types may be used behind the `C` prefix, but types must be redeclared in V in
|
||||
order to access type members.
|
||||
|
||||
To redeclare complex types, such as in the following C code:
|
||||
@@ -3688,10 +3688,10 @@ struct C.SomeCStruct {
|
||||
}
|
||||
```
|
||||
|
||||
The existence of the data members is made known to V, and they may be used without
|
||||
The existence of the data members is made known to V, and they may be used without
|
||||
re-creating the original structure exactly.
|
||||
|
||||
Alternatively, you may [embed](#embedded-structs) the sub-data-structures to maintain
|
||||
Alternatively, you may [embed](#embedded-structs) the sub-data-structures to maintain
|
||||
a parallel code structure.
|
||||
|
||||
## Debugging generated C code
|
||||
@@ -3930,7 +3930,7 @@ If you do need a custom flag file, that has platform dependent code, use the
|
||||
postfix `_d_customflag.v`, and then use plaftorm dependent compile time
|
||||
conditional blocks inside it, i.e. `$if linux {}` etc.
|
||||
|
||||
- `_notd_customflag.v` => similar to _d_customflag.v, but will be used
|
||||
- `_notd_customflag.v` => similar to _d_customflag.v, but will be used
|
||||
*only* if you do NOT pass `-d customflag` to V.
|
||||
|
||||
## Compile time pseudo variables
|
||||
@@ -4085,7 +4085,7 @@ To improve safety and maintainability, operator overloading is limited:
|
||||
are auto generated when the operators are defined though they must return the same type.
|
||||
|
||||
## Inline assembly
|
||||
<!-- ignore because it doesn't pass fmt test (why?) -->
|
||||
<!-- ignore because it doesn't pass fmt test (why?) -->
|
||||
```v ignore
|
||||
a := 100
|
||||
b := 20
|
||||
@@ -4094,12 +4094,12 @@ asm amd64 {
|
||||
mov eax, a
|
||||
add eax, b
|
||||
mov c, eax
|
||||
; =r (c) as c // output
|
||||
; r (a) as a // input
|
||||
; =r (c) as c // output
|
||||
; r (a) as a // input
|
||||
r (b) as b
|
||||
}
|
||||
println('a: $a') // 100
|
||||
println('b: $b') // 20
|
||||
println('a: $a') // 100
|
||||
println('b: $b') // 20
|
||||
println('c: $c') // 120
|
||||
```
|
||||
|
||||
|
Reference in New Issue
Block a user