1
0
mirror of https://github.com/vlang/v.git synced 2023-08-10 21:13:21 +03:00

all: replace "NB:" with "Note:" (docs/comments)

This commit is contained in:
Alexander Medvednikov 2022-03-06 20:01:22 +03:00
parent f74b65b63f
commit 36ec47cd20
131 changed files with 209 additions and 209 deletions

View File

@ -5,7 +5,7 @@ fn main() {
}
println('
NB: `tcc` was not used, so unless you install it yourself, your backend
Note: `tcc` was not used, so unless you install it yourself, your backend
C compiler will be `cc`, which is usually either `clang`, `gcc` or `msvc`.
These C compilers, are several times slower at compiling C source code,

View File

@ -452,7 +452,7 @@ pub fn prepare_test_session(zargs string, folder string, oskipped []string, main
mut skipped := oskipped.clone()
next_file: for f in files {
fnormalised := f.replace('\\', '/')
// NB: a `testdata` folder, is the preferred name of a folder, containing V code,
// Note: a `testdata` folder, is the preferred name of a folder, containing V code,
// that you *do not want* the test framework to find incidentally for various reasons,
// for example module import tests, or subtests, that are compiled/run by other parent tests
// in specific configurations, etc.

View File

@ -75,7 +75,7 @@ pub fn prepare_vc_source(vcdir string, cdir string, commit string) (string, stri
}
pub fn clone_or_pull(remote_git_url string, local_worktree_path string) {
// NB: after clone_or_pull, the current repo branch is === HEAD === master
// Note: after clone_or_pull, the current repo branch is === HEAD === master
if os.is_dir(local_worktree_path) && os.is_dir(os.join_path_single(local_worktree_path, '.git')) {
// Already existing ... Just pulling in this case is faster usually.
scripting.run('git -C "$local_worktree_path" checkout --quiet master')

View File

@ -57,7 +57,7 @@ fn (mut c Context) compile_oldv_if_needed() {
c.vgcontext.compile_oldv_if_needed()
c.commit_v_hash = c.vgcontext.commit_v__hash
if !os.exists(c.vgcontext.vexepath) && c.cmd_to_run.len > 0 {
// NB: 125 is a special code, that git bisect understands as 'skip this commit'.
// Note: 125 is a special code, that git bisect understands as 'skip this commit'.
// it is used to inform git bisect that the current commit leads to a build failure.
exit(125)
}

View File

@ -152,7 +152,7 @@ fn (mut context Context) parse_options() ? {
mut fp := flag.new_flag_parser(os.args)
fp.application(os.file_name(os.executable()))
fp.version('0.0.1')
fp.description('Repeat command(s) and collect statistics. NB: you have to quote each command, if it contains spaces.')
fp.description('Repeat command(s) and collect statistics. Note: you have to quote each command, if it contains spaces.')
fp.arguments_description('CMD1 CMD2 ...')
fp.skip_executable()
fp.limit_free_args_to_at_least(1) ?
@ -161,7 +161,7 @@ fn (mut context Context) parse_options() ? {
context.warmup = fp.int('warmup', `w`, 2, 'Warmup runs. These are done *only at the start*, and are ignored.')
context.show_help = fp.bool('help', `h`, false, 'Show this help screen.')
context.use_newline = fp.bool('newline', `n`, false, 'Use \\n, do not overwrite the last line. Produces more output, but easier to diagnose.')
context.show_output = fp.bool('output', `O`, false, 'Show command stdout/stderr in the progress indicator for each command. NB: slower, for verbose commands.')
context.show_output = fp.bool('output', `O`, false, 'Show command stdout/stderr in the progress indicator for each command. Note: slower, for verbose commands.')
context.verbose = fp.bool('verbose', `v`, false, 'Be more verbose.')
context.fail_on_maxtime = fp.int('max_time', `m`, max_time, 'Fail with exit code 2, when first cmd takes above M milliseconds (regression).')
context.fail_on_regress_percent = fp.int('fail_percent', `f`, max_fail_percent, 'Fail with exit code 3, when first cmd is X% slower than the rest (regression).')

View File

@ -4,7 +4,7 @@ import os
import testing
import v.util
// NB: tools like vdoc are compiled in their own subfolder
// Note: tools like vdoc are compiled in their own subfolder
// => cmd/tools/vdoc/vdoc.exe
// Usually, they have several top level .v files in the subfolder,
// that cannot be compiled separately, but instead, the whole folder,

View File

@ -17,7 +17,7 @@ import vhelp
struct FormatOptions {
is_l bool
is_c bool // NB: This refers to the '-c' fmt flag, NOT the C backend
is_c bool // Note: This refers to the '-c' fmt flag, NOT the C backend
is_w bool
is_diff bool
is_verbose bool
@ -25,7 +25,7 @@ struct FormatOptions {
is_debug bool
is_noerror bool
is_verify bool // exit(1) if the file is not vfmt'ed
is_worker bool // true *only* in the worker processes. NB: workers can crash.
is_worker bool // true *only* in the worker processes. Note: workers can crash.
is_backup bool // make a `file.v.bak` copy *before* overwriting a `file.v` in place with `-w`
}

View File

@ -225,7 +225,7 @@ fn print_welcome_screen() {
]
help_text := [
'Welcome to the V REPL (for help with V itself, type $cmd_exit, then run $cmd_help).',
'NB: the REPL is highly experimental. For best V experience, use a text editor, ',
'Note: the REPL is highly experimental. For best V experience, use a text editor, ',
'save your code in a $file_main file and execute: $cmd_run',
version.full_v_version(false),
'Use Ctrl-C or ${term.highlight_command('exit')} to exit, or ${term.highlight_command('help')} to see other available commands',
@ -387,7 +387,7 @@ fn run_repl(workdir string, vrepl_prefix string) {
}
}
}
// NB: starting a line with 2 spaces escapes the println heuristic
// Note: starting a line with 2 spaces escapes the println heuristic
if oline.starts_with(' ') {
is_statement = true
}

View File

@ -173,7 +173,7 @@ fn get_all_commands() []Command {
}
res << Command{
line: '$vexe $vargs -progress test-fmt'
okmsg: 'All .v files can be processed with `v fmt`. NB: the result may not always be compilable, but `v fmt` should not crash.'
okmsg: 'All .v files can be processed with `v fmt`. Note: the result may not always be compilable, but `v fmt` should not crash.'
}
res << Command{
line: '$vexe $vargs -progress test-self'
@ -201,7 +201,7 @@ fn get_all_commands() []Command {
okmsg: '`v -usecache -cg` works.'
rmfile: 'examples/hello_world'
}
// NB: test that a program that depends on thirdparty libraries with its
// Note: test that a program that depends on thirdparty libraries with its
// own #flags (tetris depends on gg, which uses sokol) can be compiled
// with -usecache:
res << Command{

View File

@ -103,7 +103,7 @@ fn process_cli_args() &Context {
fp.description('Test the V parser, by parsing each .v file in each PATH,\n' +
'as if it was typed character by character by the user.\n' +
'A PATH can be either a folder, or a specific .v file.\n' +
'NB: you *have to quote* the PATH, if it contains spaces/punctuation.')
'Note: you *have to quote* the PATH, if it contains spaces/punctuation.')
fp.arguments_description('PATH1 PATH2 ...')
fp.skip_executable()
context.is_help = fp.bool('help', `h`, false, 'Show help/usage screen.')

View File

@ -156,8 +156,8 @@ const (
]
)
// NB: musl misses openssl, thus the http tests can not be done there
// NB: http_httpbin_test.v: fails with 'cgen error: json: map_string_string is not struct'
// Note: musl misses openssl, thus the http tests can not be done there
// Note: http_httpbin_test.v: fails with 'cgen error: json: map_string_string is not struct'
fn main() {
vexe := pref.vexe_path()
vroot := os.dir(vexe)

View File

@ -82,7 +82,7 @@ fn show_usage() {
println(' B)')
println(' v test file_test.v : run test functions in a given test file.')
println(' v -stats test file_test.v : as above, but with more stats.')
println(' NB: you can also give many and mixed folder/ file_test.v arguments after `v test` .')
println(' Note: you can also give many and mixed folder/ file_test.v arguments after `v test` .')
println('')
}

View File

@ -67,7 +67,7 @@ fn (app App) update_from_master() {
}
fn (app App) recompile_v() {
// NB: app.vexe is more reliable than just v (which may be a symlink)
// Note: app.vexe is more reliable than just v (which may be a symlink)
opts := if app.is_prod { '-prod' } else { '' }
vself := '${os.quoted_path(app.vexe)} $opts self'
app.vprintln('> recompiling v itself with `$vself` ...')

View File

@ -76,7 +76,7 @@ fn main() {
eprintln(vt.e2string(err))
}
if vfmt_err_count > 0 {
eprintln('NB: You can run `v fmt -w file.v` to fix these errors automatically')
eprintln('Note: You can run `v fmt -w file.v` to fix these errors automatically')
}
if vt.errors.len > 0 {
exit(1)

View File

@ -50,7 +50,7 @@ fn get_scan_timeout_seconds() int {
// workers, thus it does not leak much.
//
// b) A worker process, doing the actual monitoring/polling.
// NB: *workers are started with the --vwatchworker option*
// Note: *workers are started with the --vwatchworker option*
//
// Worker processes will run for a limited number of iterations, then
// they will do exit(255), and then the parent will start a new worker.

View File

@ -40,7 +40,7 @@ fn main() {
mut fetcher_pool := pool.new_pool_processor(
callback: worker_fetch
)
// NB: if you do not call set_max_jobs, the pool will try to use an optimal
// Note: if you do not call set_max_jobs, the pool will try to use an optimal
// number of threads, one per each core in your system, which in most
// cases is what you want anyway... You can override the automatic choice
// by setting the VJOBS environment variable too.

View File

@ -88,7 +88,7 @@ fn (mut p Player) free() {
// http://www.lightlink.com/tjweber/StripWav/WAVE.html
// http://www.lightlink.com/tjweber/StripWav/Canon.html
// https://tools.ietf.org/html/draft-ema-vpim-wav-00
// NB: > The chunks MAY appear in any order except that the Format chunk
// Note: > The chunks MAY appear in any order except that the Format chunk
// > MUST be placed before the Sound data chunk (but not necessarily
// > contiguous to the Sound data chunk).
struct RIFFHeader {

View File

@ -8,7 +8,7 @@ struct Node {
right Tree
}
// NB: a match expression, infers the type of its result
// Note: a match expression, infers the type of its result
// from the type of the return value in the first branch,
// => it needs an explicit int(0) cast here:
fn size(tree Tree) int {

View File

@ -24,7 +24,7 @@ pub fn (mut app App) index() vweb.Result {
fn (mut app App) sse() vweb.Result {
mut session := sse.new_connection(app.conn)
// NB: you can setup session.write_timeout and session.headers here
// Note: you can setup session.write_timeout and session.headers here
session.start() or { return app.server_error(501) }
session.send_message(data: 'ok') or { return app.server_error(501) }
for {

View File

@ -283,7 +283,7 @@ pub fn (mut a array) delete_many(i int, size int) {
panic('array.delete: index out of range (i == $i$endidx, a.len == $a.len)')
}
}
// NB: if a is [12,34], a.len = 2, a.delete(0)
// Note: if a is [12,34], a.len = 2, a.delete(0)
// should move (2-0-1) elements = 1 element (the 34) forward
old_data := a.data
new_size := a.len - size
@ -400,7 +400,7 @@ pub fn (mut a array) pop() voidptr {
new_len := a.len - 1
last_elem := unsafe { &byte(a.data) + new_len * a.element_size }
a.len = new_len
// NB: a.cap is not changed here *on purpose*, so that
// Note: a.cap is not changed here *on purpose*, so that
// further << ops on that array will be more efficient.
return unsafe { memdup(last_elem, a.element_size) }
}

View File

@ -169,7 +169,7 @@ fn (mut a array) pop_noscan() voidptr {
new_len := a.len - 1
last_elem := unsafe { &byte(a.data) + new_len * a.element_size }
a.len = new_len
// NB: a.cap is not changed here *on purpose*, so that
// Note: a.cap is not changed here *on purpose*, so that
// further << ops on that array will be more efficient.
return unsafe { memdup_noscan(last_elem, a.element_size) }
}

View File

@ -23,11 +23,11 @@ fn vcommithash() string {
// panic_debug private function that V uses for panics, -cg/-g is passed
// recent versions of tcc print nicer backtraces automatically
// NB: the duplication here is because tcc_backtrace should be called directly
// Note: the duplication here is because tcc_backtrace should be called directly
// inside the panic functions.
[noreturn]
fn panic_debug(line_no int, file string, mod string, fn_name string, s string) {
// NB: the order here is important for a stabler test output
// Note: the order here is important for a stabler test output
// module is less likely to change than function, etc...
// During edits, the line number will change most frequently,
// so it is last
@ -387,7 +387,7 @@ pub fn v_realloc(b &byte, n int) &byte {
// bytes. `old_data` must be a pointer to an existing memory block, previously
// allocated with `malloc`, `v_calloc` or `vcalloc`, of size `old_data`.
// realloc_data returns a pointer to the new location of the block.
// NB: if you know the old data size, it is preferable to call `realloc_data`,
// Note: if you know the old data size, it is preferable to call `realloc_data`,
// instead of `v_realloc`, at least during development, because `realloc_data`
// can make debugging easier, when you compile your program with
// `-d debug_realloc`.
@ -400,7 +400,7 @@ pub fn realloc_data(old_data &byte, old_size int, new_size int) &byte {
return unsafe { prealloc_realloc(old_data, old_size, new_size) }
}
$if debug_realloc ? {
// NB: this is slower, but helps debugging memory problems.
// Note: this is slower, but helps debugging memory problems.
// The main idea is to always force reallocating:
// 1) allocate a new memory block
// 2) copy the old to the new

View File

@ -117,7 +117,7 @@ fn print_backtrace_skipping_top_frames_linux(skipframes int) bool {
output = ''
}
// See http://wiki.dwarfstd.org/index.php?title=Path_Discriminators
// NB: it is shortened here to just d. , just so that it fits, and so
// Note: it is shortened here to just d. , just so that it fits, and so
// that the common error file:lineno: line format is enforced.
output = output.replace(' (discriminator', ': (d.')
eprintln('${output:-55s} | ${addr:14s} | $beforeaddr')

View File

@ -2,7 +2,7 @@ module builtin
// Just define the C functions, so that V does not error because of the missing definitions.
// NB: they will NOT be used, since calls to them are wrapped with `$if gcboehm ? { }`
// Note: they will NOT be used, since calls to them are wrapped with `$if gcboehm ? { }`
fn C.GC_MALLOC(n usize) voidptr

View File

@ -174,9 +174,9 @@ fn test_float_point_formatting_rounding() {
assert '${239.5:0.0f}' == '240'
assert '${239.55:0.1f}' == '239.6'
assert '${239.555:0.2f}' == '239.56'
assert '${239.5555:0.3f}' == '239.555' // NB: 5 ?
assert '${239.5555:0.3f}' == '239.555' // Note: 5 ?
assert '${239.55555:0.4f}' == '239.5556'
assert '${239.555555:0.5f}' == '239.55555' // NB: 5 ?
assert '${239.555555:0.5f}' == '239.55555' // Note: 5 ?
assert '${239.5555555:0.6f}' == '239.555556' // after this, it is all ending in 6
assert '${239.55555555:0.7f}' == '239.5555556'
assert '${239.555555555:0.8f}' == '239.55555556'

View File

@ -533,7 +533,7 @@ pub fn (b []byte) clone() []byte {
}
// bytestr produces a string from *all* the bytes in the array.
// NB: the returned string will have .len equal to the array.len,
// Note: the returned string will have .len equal to the array.len,
// even when some of the array bytes were `0`.
// If you want to get a V string, that contains only the bytes till
// the first `0` byte, use `tos_clone(&byte(array.data))` instead.

View File

@ -11,7 +11,7 @@ module builtin
// The goal of all this is to amortize the cost of calling libc's malloc,
// trading higher memory usage for a compiler (or any single threaded batch
// mode program), for a ~8-10% speed increase.
// NB: `-prealloc` is NOT safe to be used for multithreaded programs!
// Note: `-prealloc` is NOT safe to be used for multithreaded programs!
// size of the preallocated chunk
const prealloc_block_size = 16 * 1024 * 1024
@ -74,7 +74,7 @@ fn prealloc_vinit() {
[unsafe]
fn prealloc_vcleanup() {
$if prealloc_stats ? {
// NB: we do 2 loops here, because string interpolation
// Note: we do 2 loops here, because string interpolation
// in the first loop may still use g_memory_block
// The second loop however should *not* allocate at all.
mut nr_mallocs := i64(0)

View File

@ -6,7 +6,7 @@ module builtin
import strconv
/*
NB: A V string should be/is immutable from the point of view of
Note: A V string should be/is immutable from the point of view of
V user programs after it is first created. A V string is
also slightly larger than the equivalent C string because
the V string also has an integer length attached.
@ -96,7 +96,7 @@ pub fn tos_clone(s &byte) string {
}
// tos creates a V string, given a C style pointer to a 0 terminated block.
// NB: the memory block pointed by s is *reused, not copied*!
// Note: the memory block pointed by s is *reused, not copied*!
// It will panic, when the pointer `s` is 0.
// See also `tos_clone`.
[unsafe]
@ -111,7 +111,7 @@ pub fn tos(s &byte, len int) string {
}
// tos2 creates a V string, given a C style pointer to a 0 terminated block.
// NB: the memory block pointed by s is *reused, not copied*!
// Note: the memory block pointed by s is *reused, not copied*!
// It will calculate the length first, thus it is more costly than `tos`.
// It will panic, when the pointer `s` is 0.
// It is the same as `tos3`, but for &byte pointers, avoiding callsite casts.
@ -128,7 +128,7 @@ pub fn tos2(s &byte) string {
}
// tos3 creates a V string, given a C style pointer to a 0 terminated block.
// NB: the memory block pointed by s is *reused, not copied*!
// Note: the memory block pointed by s is *reused, not copied*!
// It will calculate the length first, so it is more costly than tos.
// It will panic, when the pointer `s` is 0.
// It is the same as `tos2`, but for &char pointers, avoiding callsite casts.
@ -145,7 +145,7 @@ pub fn tos3(s &char) string {
}
// tos4 creates a V string, given a C style pointer to a 0 terminated block.
// NB: the memory block pointed by s is *reused, not copied*!
// Note: the memory block pointed by s is *reused, not copied*!
// It will calculate the length first, so it is more costly than tos.
// It returns '', when given a 0 pointer `s`, it does NOT panic.
// It is the same as `tos5`, but for &byte pointers, avoiding callsite casts.
@ -162,7 +162,7 @@ pub fn tos4(s &byte) string {
}
// tos5 creates a V string, given a C style pointer to a 0 terminated block.
// NB: the memory block pointed by s is *reused, not copied*!
// Note: the memory block pointed by s is *reused, not copied*!
// It will calculate the length first, so it is more costly than tos.
// It returns '', when given a 0 pointer `s`, it does NOT panic.
// It is the same as `tos4`, but for &char pointers, avoiding callsite casts.
@ -179,8 +179,8 @@ pub fn tos5(s &char) string {
}
// vstring converts a C style string to a V string.
// NB: the memory block pointed by `bp` is *reused, not copied*!
// NB: instead of `&byte(arr.data).vstring()`, do use `tos_clone(&byte(arr.data))`.
// Note: the memory block pointed by `bp` is *reused, not copied*!
// Note: instead of `&byte(arr.data).vstring()`, do use `tos_clone(&byte(arr.data))`.
// Strings returned from this function will be normal V strings beside that,
// (i.e. they would be freed by V's -autofree mechanism, when they are no longer used).
// See also `tos_clone`.
@ -193,7 +193,7 @@ pub fn (bp &byte) vstring() string {
}
// vstring_with_len converts a C style 0 terminated string to a V string.
// NB: the memory block pointed by `bp` is *reused, not copied*!
// Note: the memory block pointed by `bp` is *reused, not copied*!
// This method has lower overhead compared to .vstring(), since it
// does not need to calculate the length of the 0 terminated string.
// See also `tos_clone`.
@ -207,11 +207,11 @@ pub fn (bp &byte) vstring_with_len(len int) string {
}
// vstring converts a C style string to a V string.
// NB: the memory block pointed by `bp` is *reused, not copied*!
// Note: the memory block pointed by `bp` is *reused, not copied*!
// Strings returned from this function will be normal V strings beside that,
// (i.e. they would be freed by V's -autofree mechanism, when they are
// no longer used).
// NB: instead of `&byte(a.data).vstring()`, use `tos_clone(&byte(a.data))`.
// Note: instead of `&byte(a.data).vstring()`, use `tos_clone(&byte(a.data))`.
// See also `tos_clone`.
[unsafe]
pub fn (cp &char) vstring() string {
@ -223,7 +223,7 @@ pub fn (cp &char) vstring() string {
}
// vstring_with_len converts a C style 0 terminated string to a V string.
// NB: the memory block pointed by `bp` is *reused, not copied*!
// Note: the memory block pointed by `bp` is *reused, not copied*!
// This method has lower overhead compared to .vstring(), since it
// does not calculate the length of the 0 terminated string.
// See also `tos_clone`.
@ -237,7 +237,7 @@ pub fn (cp &char) vstring_with_len(len int) string {
}
// vstring_literal converts a C style string to a V string.
// NB: the memory block pointed by `bp` is *reused, not copied*!
// Note: the memory block pointed by `bp` is *reused, not copied*!
// NB2: unlike vstring, vstring_literal will mark the string
// as a literal, so it will not be freed by -autofree.
// This is suitable for readonly strings, C string literals etc,
@ -254,7 +254,7 @@ pub fn (bp &byte) vstring_literal() string {
}
// vstring_with_len converts a C style string to a V string.
// NB: the memory block pointed by `bp` is *reused, not copied*!
// Note: the memory block pointed by `bp` is *reused, not copied*!
// This method has lower overhead compared to .vstring_literal(), since it
// does not need to calculate the length of the 0 terminated string.
// See also `tos_clone`.
@ -268,7 +268,7 @@ pub fn (bp &byte) vstring_literal_with_len(len int) string {
}
// vstring_literal converts a C style string char* pointer to a V string.
// NB: the memory block pointed by `bp` is *reused, not copied*!
// Note: the memory block pointed by `bp` is *reused, not copied*!
// See also `byteptr.vstring_literal` for more details.
// See also `tos_clone`.
[unsafe]
@ -282,7 +282,7 @@ pub fn (cp &char) vstring_literal() string {
// vstring_literal_with_len converts a C style string char* pointer,
// to a V string.
// NB: the memory block pointed by `bp` is *reused, not copied*!
// Note: the memory block pointed by `bp` is *reused, not copied*!
// This method has lower overhead compared to .vstring_literal(), since it
// does not need to calculate the length of the 0 terminated string.
// See also `tos_clone`.
@ -1881,7 +1881,7 @@ pub fn (s string) strip_margin_custom(del byte) string {
}
// match_glob matches the string, with a Unix shell-style wildcard pattern.
// NB: wildcard patterns are NOT the same as regular expressions.
// Note: wildcard patterns are NOT the same as regular expressions.
// They are much simpler, and do not allow backtracking, captures, etc.
// The special characters used in shell-style wildcards are:
// `*` - matches everything

View File

@ -1,14 +1,14 @@
module builtin
// NB: this file will be removed soon
// Note: this file will be removed soon
// byteptr.vbytes() - makes a V []byte structure from a C style memory buffer. NB: the data is reused, NOT copied!
// byteptr.vbytes() - makes a V []byte structure from a C style memory buffer. Note: the data is reused, NOT copied!
[unsafe]
pub fn (data byteptr) vbytes(len int) []byte {
return unsafe { voidptr(data).vbytes(len) }
}
// vstring converts a C style string to a V string. NB: the string data is reused, NOT copied.
// vstring converts a C style string to a V string. Note: the string data is reused, NOT copied.
// strings returned from this function will be normal V strings beside that (i.e. they would be
// freed by V's -autofree mechanism, when they are no longer used).
[unsafe]
@ -20,7 +20,7 @@ pub fn (bp byteptr) vstring() string {
}
// vstring_with_len converts a C style string to a V string.
// NB: the string data is reused, NOT copied.
// Note: the string data is reused, NOT copied.
[unsafe]
pub fn (bp byteptr) vstring_with_len(len int) string {
return string{
@ -31,7 +31,7 @@ pub fn (bp byteptr) vstring_with_len(len int) string {
}
// vstring converts C char* to V string.
// NB: the string data is reused, NOT copied.
// Note: the string data is reused, NOT copied.
[unsafe]
pub fn (cp charptr) vstring() string {
return string{
@ -42,7 +42,7 @@ pub fn (cp charptr) vstring() string {
}
// vstring_with_len converts C char* to V string.
// NB: the string data is reused, NOT copied.
// Note: the string data is reused, NOT copied.
[unsafe]
pub fn (cp charptr) vstring_with_len(len int) string {
return string{
@ -53,7 +53,7 @@ pub fn (cp charptr) vstring_with_len(len int) string {
}
// vstring_literal converts a C style string to a V string.
// NB: the string data is reused, NOT copied.
// Note: the string data is reused, NOT copied.
// NB2: unlike vstring, vstring_literal will mark the string
// as a literal, so it will not be freed by autofree.
// This is suitable for readonly strings, C string literals etc,
@ -69,7 +69,7 @@ pub fn (bp byteptr) vstring_literal() string {
}
// vstring_with_len converts a C style string to a V string.
// NB: the string data is reused, NOT copied.
// Note: the string data is reused, NOT copied.
[unsafe]
pub fn (bp byteptr) vstring_literal_with_len(len int) string {
return string{
@ -81,7 +81,7 @@ pub fn (bp byteptr) vstring_literal_with_len(len int) string {
// vstring_literal converts C char* to V string.
// See also vstring_literal defined on byteptr for more details.
// NB: the string data is reused, NOT copied.
// Note: the string data is reused, NOT copied.
[unsafe]
pub fn (cp charptr) vstring_literal() string {
return string{
@ -93,7 +93,7 @@ pub fn (cp charptr) vstring_literal() string {
// vstring_literal_with_len converts C char* to V string.
// See also vstring_literal_with_len defined on byteptr.
// NB: the string data is reused, NOT copied.
// Note: the string data is reused, NOT copied.
[unsafe]
pub fn (cp charptr) vstring_literal_with_len(len int) string {
return string{

View File

@ -89,7 +89,7 @@ fn test_match_glob_with_complex_patterns() {
}
fn test_match_glob_search_is_linear() {
// NB: these are pathological cases, when matches are performed
// Note: these are pathological cases, when matches are performed
// using the exponential recursive approach, that can take many
// seconds, even minutes, but take usually only microseconds,
// using the linear approach from https://research.swtch.com/glob

View File

@ -1,6 +1,6 @@
module main
// NB: this should be in vlib/crypto/ed25519/ed25519_test.v
// Note: this should be in vlib/crypto/ed25519/ed25519_test.v
// but is currently one folder below, because of a V parser/symbol registration bug.
// TODO: move this test back to vlib/crypto/ed25519/ed25519_test.v
import os

View File

@ -37,7 +37,7 @@ pub fn new(key []byte, data []byte, hash_func fn ([]byte) []byte, blocksize int)
}
// equal compares 2 MACs for equality, without leaking timing info.
// NB: if the lengths of the 2 MACs are different, probably a completely different
// Note: if the lengths of the 2 MACs are different, probably a completely different
// hash function was used to generate them => no useful timing information.
pub fn equal(mac1 []byte, mac2 []byte) bool {
return subtle.constant_time_compare(mac1, mac2) == 1

View File

@ -13,7 +13,7 @@ pub fn (err ReadError) msg() string {
}
// bytes returns an array of `bytes_needed` random bytes.
// NB: this call can block your program for a long period of time,
// Note: this call can block your program for a long period of time,
// if your system does not have access to enough entropy.
// See also rand.bytes(), if you do not need really random bytes,
// but instead pseudo random ones, from a pseudo random generator

View File

@ -100,7 +100,7 @@ pub mut:
// free frees the resources allocated for the given FlagParser instance.
// It should be called manually in functions that use it, and that are
// marked with `[manualfree]`, otherwise, it is called automatically
// in programs, compiled with `-autofree`. NB: you should NOT use the
// in programs, compiled with `-autofree`. Note: you should NOT use the
// instance over which you have called .free() for anything after the call.
[unsafe]
fn (mut f FlagParser) free() {

View File

@ -9,7 +9,7 @@ pub enum MouseButton {
invalid = 256
}
// NB: unlike the MouseButton enum from above,
// Note: unlike the MouseButton enum from above,
// the [flag]-ed enum here can have combined states,
// representing several pressed buttons at once.

View File

@ -500,7 +500,7 @@ fn (mut ctx Context) set_scale() {
}
}
}
// NB: on older X11, `Xft.dpi` from ~/.Xresources, that sokol uses,
// Note: on older X11, `Xft.dpi` from ~/.Xresources, that sokol uses,
// may not be set which leads to sapp.dpi_scale reporting incorrectly 0.0
if s < 0.1 {
s = 1.0
@ -522,7 +522,7 @@ pub fn dpi_scale() f32 {
$if android {
s *= android_dpi_scale()
}
// NB: on older X11, `Xft.dpi` from ~/.Xresources, that sokol uses,
// Note: on older X11, `Xft.dpi` from ~/.Xresources, that sokol uses,
// may not be set which leads to sapp.dpi_scale reporting incorrectly 0.0
if s < 0.1 {
s = 1.0

View File

@ -112,7 +112,7 @@ pub fn (ctx &Context) draw_image(x f32, y f32, width f32, height f32, img_ &Imag
// new_streaming_image returns a cached `image_idx` of a special image, that
// can be updated *each frame* by calling: gg.update_pixel_data(image_idx, buf)
// ... where buf is a pointer to the actual pixel data for the image.
// NB: you still need to call app.gg.draw_image after that, to actually draw it.
// Note: you still need to call app.gg.draw_image after that, to actually draw it.
pub fn (mut ctx Context) new_streaming_image(w int, h int, channels int, sicfg StreamingImageConfig) int {
mut img := Image{}
img.width = w

View File

@ -4,7 +4,7 @@ fn test_ftp_cleint() {
$if !network ? {
return
}
// NB: this function makes network calls to external servers,
// Note: this function makes network calls to external servers,
// that is why it is not a very good idea to run it in CI.
// If you want to run it manually, use:
// `v -d network vlib/net/ftp/ftp_test.v`

View File

@ -280,7 +280,7 @@ pub fn (err MultiplePathAttributesError) msg() string {
// multipart_form_body converts form and file data into a multipart/form
// HTTP request body. It is the inverse of parse_multipart_form. Returns
// (body, boundary).
// NB: Form keys should not contain quotes
// Note: Form keys should not contain quotes
fn multipart_form_body(form map[string]string, files map[string][]FileData) (string, string) {
alpha_numeric := 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789'
boundary := rand.string_from_set(alpha_numeric, 64)

View File

@ -43,7 +43,7 @@ pub fn (mut con TcpConn) set_blocking(state bool) ? {
// read_line is a *simple*, *non customizable*, blocking line reader.
// It will return a line, ending with LF, or just '', on EOF.
// NB: if you want more control over the buffer, please use a buffered IO
// Note: if you want more control over the buffer, please use a buffered IO
// reader instead: `io.new_buffered_reader({reader: io.make_reader(con)})`
pub fn (mut con TcpConn) read_line() string {
return con.read_line_max(net.max_read_line_len)

View File

@ -272,7 +272,7 @@ pub fn orm_select_gen(orm SelectConfig, para string, num bool, qm string, start_
}
}
// NB: do not order, if the user did not want it explicitly,
// Note: do not order, if the user did not want it explicitly,
// ordering is *slow*, especially if there are no indexes!
if orm.has_order {
str += ' ORDER BY '

View File

@ -339,7 +339,7 @@ fn test_orm_sqlite() {
updated_time_mod := sql db {
select from Module where id == 1
}
// NB: usually updated_time_mod.created != t, because t has
// Note: usually updated_time_mod.created != t, because t has
// its microseconds set, while the value retrieved from the DB
// has them zeroed, because the db field resolution is seconds.
assert updated_time_mod.created.format_ss() == t.format_ss()

View File

@ -36,7 +36,7 @@ pub fn getenv_opt(key string) ?string {
if s == voidptr(0) {
return none
}
// NB: C.getenv *requires* that the result be copied.
// Note: C.getenv *requires* that the result be copied.
return cstring_to_vstring(s)
}
}

View File

@ -102,7 +102,7 @@ pub fn open(path string) ?File {
// create creates or opens a file at a specified location and returns a write-only `File` object.
pub fn create(path string) ?File {
/*
// NB: android/termux/bionic is also a kind of linux,
// Note: android/termux/bionic is also a kind of linux,
// but linux syscalls there sometimes fail,
// while the libc version should work.
$if linux {
@ -264,7 +264,7 @@ pub fn (mut f File) write_to(pos u64, buf []byte) ?int {
}
// write_ptr writes `size` bytes to the file, starting from the address in `data`.
// NB: write_ptr is unsafe and should be used carefully, since if you pass invalid
// Note: write_ptr is unsafe and should be used carefully, since if you pass invalid
// pointers to it, it will cause your programs to segfault.
[unsafe]
pub fn (mut f File) write_ptr(data voidptr, size int) int {
@ -297,7 +297,7 @@ pub fn (mut f File) write_full_buffer(buffer voidptr, buffer_len usize) ? {
// write_ptr_at writes `size` bytes to the file, starting from the address in `data`,
// at byte offset `pos`, counting from the start of the file (pos 0).
// NB: write_ptr_at is unsafe and should be used carefully, since if you pass invalid
// Note: write_ptr_at is unsafe and should be used carefully, since if you pass invalid
// pointers to it, it will cause your programs to segfault.
[unsafe]
pub fn (mut f File) write_ptr_at(data voidptr, size int, pos u64) int {

View File

@ -258,7 +258,7 @@ pub fn cp(src string, dst string) ? {
}
// vfopen returns an opened C file, given its path and open mode.
// NB: os.vfopen is useful for compatibility with C libraries, that expect `FILE *`.
// Note: os.vfopen is useful for compatibility with C libraries, that expect `FILE *`.
// If you write pure V code, os.create or os.open are more convenient.
pub fn vfopen(path string, mode string) ?&C.FILE {
if path.len == 0 {
@ -397,7 +397,7 @@ pub fn exists(path string) bool {
// is_executable returns `true` if `path` is executable.
pub fn is_executable(path string) bool {
$if windows {
// NB: https://docs.microsoft.com/en-us/cpp/c-runtime-library/reference/access-waccess?view=vs-2019
// Note: https://docs.microsoft.com/en-us/cpp/c-runtime-library/reference/access-waccess?view=vs-2019
// i.e. there is no X bit there, the modes can be:
// 00 Existence only
// 02 Write-only
@ -781,7 +781,7 @@ pub fn getwd() string {
// See http://pubs.opengroup.org/onlinepubs/9699919799/functions/realpath.html
// Also https://insanecoding.blogspot.com/2007/11/pathmax-simply-isnt.html
// and https://insanecoding.blogspot.com/2007/11/implementing-realpath-in-c.html
// NB: this particular rabbit hole is *deep* ...
// Note: this particular rabbit hole is *deep* ...
[manualfree]
pub fn real_path(fpath string) string {
size := max_path_bufffer_size()
@ -833,7 +833,7 @@ pub fn real_path(fpath string) string {
unsafe { res.free() }
return fpath.clone()
}
// NB: fullpath is much larger (usually ~4KB), than what C.realpath will
// Note: fullpath is much larger (usually ~4KB), than what C.realpath will
// actually fill in the vast majority of the cases => it pays to copy the
// resulting string from that buffer, to a shorter one, and then free the
// 4KB fullpath buffer.
@ -946,7 +946,7 @@ pub fn open_append(path string) ?File {
// execvp - loads and executes a new child process, *in place* of the current process.
// The child process executable is located in `cmdpath`.
// The arguments, that will be passed to it are in `args`.
// NB: this function will NOT return when successfull, since
// Note: this function will NOT return when successfull, since
// the child process will take control over execution.
pub fn execvp(cmdpath string, cmdargs []string) ? {
mut cargs := []&char{}
@ -972,7 +972,7 @@ pub fn execvp(cmdpath string, cmdargs []string) ? {
// The child process executable is located in `cmdpath`.
// The arguments, that will be passed to it are in `args`.
// You can pass environment variables to through `envs`.
// NB: this function will NOT return when successfull, since
// Note: this function will NOT return when successfull, since
// the child process will take control over execution.
pub fn execve(cmdpath string, cmdargs []string, envs []string) ? {
mut cargv := []&char{}
@ -992,7 +992,7 @@ pub fn execve(cmdpath string, cmdargs []string, envs []string) ? {
} $else {
res = C.execve(&char(cmdpath.str), cargv.data, cenvs.data)
}
// NB: normally execve does not return at all.
// Note: normally execve does not return at all.
// If it returns, then something went wrong...
if res == -1 {
return error_with_code(posix_get_error_msg(C.errno), C.errno)

View File

@ -38,7 +38,7 @@ fn init() {
// See http://pubs.opengroup.org/onlinepubs/9699919799/functions/realpath.html
// Also https://insanecoding.blogspot.com/2007/11/pathmax-simply-isnt.html
// and https://insanecoding.blogspot.com/2007/11/implementing-realpath-in-c.html
// NB: this particular rabbit hole is *deep* ...
// Note: this particular rabbit hole is *deep* ...
pub fn real_path(fpath string) string {
$if js_node {
mut res := ''

View File

@ -283,7 +283,7 @@ pub fn get_lines_joined() string {
}
// get_raw_lines_joined reads *all* input lines from stdin.
// It returns them as one large string. NB: unlike os.get_lines_joined,
// It returns them as one large string. Note: unlike os.get_lines_joined,
// empty lines (that contain only `\r\n` or `\n`), will be present in
// the output.
// Reading is stopped, only on EOF of stdin.

View File

@ -53,7 +53,7 @@ fn C.link(&char, &char) int
fn C.gethostname(&char, int) int
// NB: not available on Android fn C.getlogin_r(&char, int) int
// Note: not available on Android fn C.getlogin_r(&char, int) int
fn C.getlogin() &char
fn C.getppid() int

View File

@ -357,7 +357,7 @@ fn test_mv() {
fn test_cp_all() {
// fileX -> dir/fileX
// NB: clean up of the files happens inside the cleanup_leftovers function
// Note: clean up of the files happens inside the cleanup_leftovers function
os.write_file('ex1.txt', 'wow!') or { panic(err) }
os.mkdir('ex') or { panic(err) }
os.cp_all('ex1.txt', 'ex', false) or { panic(err) }
@ -749,7 +749,7 @@ fn test_posix_set_bit() ? {
}
mode = u32(s.st_mode) & 0o0777
assert mode == 0o0777
// NB: setting the sticky bit is platform dependend
// Note: setting the sticky bit is platform dependend
// `chmod -s -g -t`
os.posix_set_permission_bit(fpath, os.s_isuid, false)
os.posix_set_permission_bit(fpath, os.s_isgid, false)

View File

@ -40,10 +40,10 @@ pub fn (mut p Process) signal_continue() {
}
// wait - wait for a process to finish.
// NB: You have to call p.wait(), otherwise a finished process
// Note: You have to call p.wait(), otherwise a finished process
// would get to a zombie state, and its resources will not get
// released fully, until its parent process exits.
// NB: This call will block the calling process until the child
// Note: This call will block the calling process until the child
// process is finished.
pub fn (mut p Process) wait() {
if p.status == .not_started {

View File

@ -5,7 +5,7 @@ $if js_node {
}
// new_process - create a new process descriptor
// NB: new does NOT start the new process.
// Note: new does NOT start the new process.
// That is done because you may want to customize it first,
// by calling different set_ methods on it.
// In order to start it, call p.run() or p.wait()

View File

@ -36,7 +36,7 @@ pub mut:
}
// new_process - create a new process descriptor
// NB: new does NOT start the new process.
// Note: new does NOT start the new process.
// That is done because you may want to customize it first,
// by calling different set_ methods on it.
// In order to start it, call p.run() or p.wait()

View File

@ -13,7 +13,7 @@ fn (mut p Process) unix_spawn_process() int {
pid := fork()
if pid != 0 {
// This is the parent process after the fork.
// NB: pid contains the process ID of the child process
// Note: pid contains the process ID of the child process
if p.use_stdio_ctl {
p.stdio_fd[0] = pipeset[1] // store the write end of child's in
p.stdio_fd[1] = pipeset[2] // store the read end of child's out

View File

@ -2,7 +2,7 @@ module os
// os.Signal - enumerate possible POSIX signals and
// their integer codes.
// NB: the integer codes are given here explicitly,
// Note: the integer codes are given here explicitly,
// to make it easier to lookup, without needing to
// consult man pages / signal.h .

View File

@ -56,7 +56,7 @@ const ulid_encoding = '0123456789ABCDEFGHJKMNPQRSTVWXYZ'
// ulid generates an Unique Lexicographically sortable IDentifier.
// See https://github.com/ulid/spec .
// NB: ULIDs can leak timing information, if you make them public, because
// Note: ULIDs can leak timing information, if you make them public, because
// you can infer the rate at which some resource is being created, like
// users or business transactions.
// (https://news.ycombinator.com/item?id=14526173)

View File

@ -24,7 +24,7 @@ const (
// ulid generates an Unique Lexicographically sortable IDentifier.
// See https://github.com/ulid/spec .
// NB: ULIDs can leak timing information, if you make them public, because
// Note: ULIDs can leak timing information, if you make them public, because
// you can infer the rate at which some resource is being created, like
// users or business transactions.
// (https://news.ycombinator.com/item?id=14526173)

View File

@ -3,7 +3,7 @@
// that can be found in the LICENSE file.
module stbi
// NB: stbi uses math.h because of `ldexp` and `pow`, for which we *do* have
// Note: stbi uses math.h because of `ldexp` and `pow`, for which we *do* have
// pure V implementations, but our `math` module still depends on libm
// because of 'powf', 'cosf', 'sinf', 'sqrtf' and 'tanf'.

View File

@ -79,7 +79,7 @@ pub fn (mut b Builder) drain_builder(mut other Builder, other_new_cap int) {
}
// byte_at returns a byte, located at a given index `i`.
// NB: it can panic, if there are not enough bytes in the strings builder yet.
// Note: it can panic, if there are not enough bytes in the strings builder yet.
[inline]
pub fn (b &Builder) byte_at(n int) byte {
return unsafe { (&[]byte(b))[n] }
@ -123,7 +123,7 @@ pub fn (mut b Builder) cut_to(pos int) string {
}
// go_back_to resets the buffer to the given position `pos`
// NB: pos should be < than the existing buffer length.
// Note: pos should be < than the existing buffer length.
pub fn (mut b Builder) go_back_to(pos int) {
b.trim(pos)
}
@ -162,7 +162,7 @@ pub fn (b &Builder) after(n int) string {
}
// str returns a copy of all of the accumulated buffer content.
// NB: after a call to b.str(), the builder b should not be
// Note: after a call to b.str(), the builder b should not be
// used again, you need to call b.free() first, or just leave
// it to be freed by -autofree when it goes out of scope.
// The returned string *owns* its own separate copy of the

View File

@ -14,7 +14,7 @@ pub fn repeat(c byte, n int) string {
}
// strings.repeat_string - gives you `n` repetitions of the substring `s`
// NB: strings.repeat, that repeats a single byte, is between 2x
// Note: strings.repeat, that repeats a single byte, is between 2x
// and 24x faster than strings.repeat_string called for a 1 char string.
pub fn repeat_string(s string, n int) string {
if n <= 0 || s.len == 0 {

View File

@ -129,7 +129,7 @@ pub fn (ss &TextScanner) peek_back_n(n int) int {
// current returns the current character code from the input text.
// current returns `-1` at the start of the input text.
// NB: after `c := ts.next()`, `ts.current()` will also return `c`.
// Note: after `c := ts.next()`, `ts.current()` will also return `c`.
[direct_array_access; inline]
pub fn (mut ss TextScanner) current() int {
if ss.pos > 0 {

View File

@ -39,7 +39,7 @@ fn do_rec(ch chan int, id int, mut ctx Context) {
mut timer_sw_x := time.new_stopwatch()
mut tmp := int(0)
mut i := int(0)
// NB: a single receiver thread can get slightly more
// Note: a single receiver thread can get slightly more
// than its fair share of sends, that is why
// the receiver's Event array is much larger,
// enough so a single receiver can potentially process all

View File

@ -1,6 +1,6 @@
import sync
// NB: this is the same test as `vlib/sync/once_test.v`, but
// Note: this is the same test as `vlib/sync/once_test.v`, but
// it uses an explicit passing of the voidptr parameter in
// once.do_with_param/2, instead of passing a closure of it
// in once.do/1.

View File

@ -42,7 +42,7 @@ fn test_work_on_strings() {
}
fn test_work_on_ints() {
// NB: since maxjobs is left empty here,
// Note: since maxjobs is left empty here,
// the pool processor will use njobs = runtime.nr_jobs so that
// it will work optimally without overloading the system
mut pool_i := pool.new_pool_processor(

View File

@ -5,7 +5,7 @@ module stdatomic
//
// On windows tcc can simulate with other atomic operations.
//
// NB: this implementations should be regarded as alpha stage and be tested
// Note: this implementations should be regarded as alpha stage and be tested
// much more.
// add_u64 adds provided delta as an atomic operation

View File

@ -32,7 +32,7 @@ fn test_count_10_times_1_cycle_should_not_be_10_cycles_without_sync() {
go count_one_cycle_without_sync(mut counter, mut wg)
}
wg.wait()
// NB: we do not assert here, just print, because sometimes by chance counter.counter may be == desired_iterations
// Note: we do not assert here, just print, because sometimes by chance counter.counter may be == desired_iterations
eprintln('without synchronization the counter is: ${counter.counter:10} , expectedly != ${desired_iterations:10}')
}

View File

@ -5,7 +5,7 @@ module threads
// See vlib/v/parser/pratt.v, search for ast.GoExpr .
// The goal is that programs, that do not use threads at all will not need
// to link to -lpthread etc.
// NB: on some platforms like Android, linking -lpthread is not needed too.
// Note: on some platforms like Android, linking -lpthread is not needed too.
// See https://stackoverflow.com/a/31277163/1904615
$if !windows && !android {

View File

@ -6,7 +6,7 @@ fn test_time_after_2038_works() {
error_time := after_time.add_days(180)
dump(error_time)
assert error_time.str() == '2038-01-19 00:00:00'
// NB: the next date is after Y2K38, it should NOT wrap:
// Note: the next date is after Y2K38, it should NOT wrap:
error_time2 := after_time.add_days(181)
dump(error_time2)
assert error_time2.str() == '2038-01-20 00:00:00'

View File

@ -1,6 +1,6 @@
import time
// NB: on CI jobs, especially msvc ones, sleep_ms may sleep for much more
// Note: on CI jobs, especially msvc ones, sleep_ms may sleep for much more
// time than you have specified. To avoid false positives from CI test
// failures, some of the asserts will be run only if you pass `-d stopwatch`
fn test_stopwatch_works_as_intended() {

View File

@ -47,7 +47,7 @@ fn sys_mono_now_darwin() u64 {
return (tm - time.start_time) * time.time_base.numer / time.time_base.denom
}
// NB: vpc_now_darwin is used by `v -profile` .
// Note: vpc_now_darwin is used by `v -profile` .
// It should NOT call *any other v function*, just C functions and casts.
[inline]
fn vpc_now_darwin() u64 {

View File

@ -57,7 +57,7 @@ pub fn sys_mono_now() u64 {
}
}
// NB: vpc_now is used by `v -profile` .
// Note: vpc_now is used by `v -profile` .
// It should NOT call *any other v function*, just C functions and casts.
[inline]
fn vpc_now() u64 {

View File

@ -79,7 +79,7 @@ pub fn sys_mono_now() u64 {
return (tm - time.start_time) * 1000000000 / time.freq_time
}
// NB: vpc_now is used by `v -profile` .
// Note: vpc_now is used by `v -profile` .
// It should NOT call *any other v function*, just C functions and casts.
[inline]
fn vpc_now() u64 {

View File

@ -205,7 +205,7 @@ fn to_burntsushi(value ast.Value) string {
// Normalization for json
json_text := json2.Any(value.text).json_str().to_upper().replace(' ', 'T')
// NB: Since encoding strings in JSON now automatically includes quotes,
// Note: Since encoding strings in JSON now automatically includes quotes,
// I added a somewhat a workaround by adding an ending quote in order to
// recognize properly the date time type. - Ned
typ := if json_text.ends_with('Z"') || json_text.all_after('T').contains('-')

View File

@ -321,7 +321,7 @@ fn to_iarna(value ast.Value, skip_value_map bool) string {
}
ast.Time {
mut json_text := json2.Any(value.text).json_str()
// NB: Removes the quotes of the encoded JSON string - Ned
// Note: Removes the quotes of the encoded JSON string - Ned
json_text = to_iarna_time(json_text[1..json_text.len - 1])
if skip_value_map {
return json_text

View File

@ -1700,7 +1700,7 @@ pub fn (expr Expr) is_blank_ident() bool {
pub fn (expr Expr) pos() token.Pos {
// all uncommented have to be implemented
// NB: please do not print here. the language server will hang
// Note: please do not print here. the language server will hang
// as it uses STDIO primarly to communicate ~Ned
match expr {
AnonFn {
@ -2002,7 +2002,7 @@ pub fn (node Node) children() []Node {
Return {
return node.exprs.map(Node(it))
}
// NB: these four decl nodes cannot be merged as one branch
// Note: these four decl nodes cannot be merged as one branch
StructDecl {
return node.fields.map(Node(it))
}

View File

@ -236,7 +236,7 @@ pub fn (t &Table) fn_type_source_signature(f &Fn) string {
if arg.is_mut {
sig += 'mut '
}
// NB: arg name is only added for fmt, else it would causes errors with generics
// Note: arg name is only added for fmt, else it would causes errors with generics
if t.is_fmt && arg.name.len > 0 {
sig += '$arg.name '
}

View File

@ -168,7 +168,7 @@ pub fn (t Type) nr_muls() int {
[inline]
pub fn (t Type) is_ptr() bool {
// any normal pointer, i.e. &Type, &&Type etc;
// NB: voidptr, charptr and byteptr are NOT included!
// Note: voidptr, charptr and byteptr are NOT included!
return (int(t) >> 16) & 0xff > 0
}
@ -427,7 +427,7 @@ pub const (
u8_type_idx = 30
)
// NB: builtin_type_names must be in the same order as the idx consts above
// Note: builtin_type_names must be in the same order as the idx consts above
pub const builtin_type_names = ['void', 'voidptr', 'byteptr', 'charptr', 'i8', 'i16', 'int', 'i64',
'isize', 'byte', 'u16', 'u32', 'u64', 'usize', 'f32', 'f64', 'char', 'bool', 'none', 'string',
'rune', 'array', 'map', 'chan', 'any', 'float_literal', 'int_literal', 'thread', 'Error', 'u8']

View File

@ -36,7 +36,7 @@ pub mut:
table &ast.Table
ccoptions CcompilerOptions
//
// NB: changes in mod `builtin` force invalidation of every other .v file
// Note: changes in mod `builtin` force invalidation of every other .v file
mod_invalidates_paths map[string][]string // changes in mod `os`, invalidate only .v files, that do `import os`
mod_invalidates_mods map[string][]string // changes in mod `os`, force invalidation of mods, that do `import os`
path_invalidates_mods map[string][]string // changes in a .v file from `os`, invalidates `os`
@ -153,7 +153,7 @@ pub fn (mut b Builder) parse_imports() {
done_imports << file.mod.name
}
}
// NB: b.parsed_files is appended in the loop,
// Note: b.parsed_files is appended in the loop,
// so we can not use the shorter `for in` form.
for i := 0; i < b.parsed_files.len; i++ {
ast_file := b.parsed_files[i]

View File

@ -662,7 +662,7 @@ pub fn (mut v Builder) cc() {
println('strip failed')
return
}
// NB: upx --lzma can sometimes fail with NotCompressibleException
// Note: upx --lzma can sometimes fail with NotCompressibleException
// See https://github.com/vlang/v/pull/3528
mut ret2 := os.system('upx --lzma -qqq $v.pref.out_name')
if ret2 != 0 {

View File

@ -446,7 +446,7 @@ fn (mut v Builder) build_thirdparty_obj_file_with_msvc(path string, moduleflags
}
str_oargs := oargs.join(' ')
cmd := '"$msvc.full_cl_exe_path" /volatile:ms $str_oargs $defines $include_string /c "$cfile" /Fo"$obj_path"'
// NB: the quotes above ARE balanced.
// Note: the quotes above ARE balanced.
$if trace_thirdparty_obj_files ? {
println('>>> build_thirdparty_obj_file_with_msvc cmd: $cmd')
}
@ -496,7 +496,7 @@ pub fn msvc_string_flags(cflags []cflag.CFlag) MsvcStringFlags {
lib_paths << flag.value + os.path_separator + 'msvc'
// The above allows putting msvc specific .lib files in a subfolder msvc/ ,
// where gcc will NOT find them, but cl will do...
// NB: gcc is smart enough to not need .lib files at all in most cases, the .dll is enough.
// Note: gcc is smart enough to not need .lib files at all in most cases, the .dll is enough.
// When both a msvc .lib file and .dll file are present in the same folder,
// as for example for glfw3, compilation with gcc would fail.
} else if flag.value.ends_with('.o') {

View File

@ -832,7 +832,7 @@ pub fn (mut c Checker) fn_call(mut node ast.CallExpr, mut continue_check &bool)
final_param_typ = param_typ_sym.array_info().elem_type
final_param_sym = c.table.sym(final_param_typ)
}
// NB: Casting to voidptr is used as an escape mechanism, so:
// Note: Casting to voidptr is used as an escape mechanism, so:
// 1. allow passing *explicit* voidptr (native or through cast) to functions
// expecting voidptr or ...voidptr
// ... but 2. disallow passing non-pointers - that is very rarely what the user wanted,

View File

@ -175,7 +175,7 @@ pub fn (mut c Checker) find_unreachable_statements_after_noreturn_calls(stmts []
}
}
// NB: has_top_return/1 should be called on *already checked* stmts,
// Note: has_top_return/1 should be called on *already checked* stmts,
// which do have their stmt.expr.is_noreturn set properly:
fn has_top_return(stmts []ast.Stmt) bool {
for stmt in stmts {

View File

@ -2,7 +2,7 @@ import bbb.ccc
import www.ttt
import xxx.yyy
// NB: www.ttt has been deprecated.
// Note: www.ttt has been deprecated.
// => compiling this should produce an error,
// showing the deprecation message
fn main() {

View File

@ -106,7 +106,7 @@ fn test_all() {
//
if github_job == 'ubuntu-tcc' {
// This is done with tcc only, because the error output is compiler specific.
// NB: the tasks should be run serially, since they depend on
// Note: the tasks should be run serially, since they depend on
// setting and using environment variables.
mut cte_tasks := Tasks{
vexe: vexe
@ -200,7 +200,7 @@ fn (mut tasks Tasks) run() {
m_skip_files = []
}
$if tinyc {
// NB: tcc does not support __has_include, so the detection mechanism
// Note: tcc does not support __has_include, so the detection mechanism
// used for the other compilers does not work. It still provides a
// cleaner error message, than a generic C error, but without the explanation.
m_skip_files << 'vlib/v/checker/tests/missing_c_lib_header_1.vv'
@ -298,7 +298,7 @@ fn work_processor(mut work sync.Channel, mut results sync.Channel) {
}
}
// actual processing; NB: no output is done here at all
// actual processing; Note: no output is done here at all
fn (mut task TaskDescription) execute() {
if task.is_skipped {
return

View File

@ -10,7 +10,7 @@ import v.pref
// that either contains main .v files, or a v.mod file is reached.
// For example, given something like /languages/v/vlib/x/websocket/tests/autobahn
// it returns `x.websocket.tests`, because /languages/v/ has v.mod file in it.
// NB: calling this is expensive, so keep the result, instead of recomputing it.
// Note: calling this is expensive, so keep the result, instead of recomputing it.
// TODO: turn this to a Doc method, so that the new_vdoc_preferences call here can
// be removed.
fn get_parent_mod(input_dir string) ?string {

View File

@ -95,7 +95,7 @@ pub fn (mut ed EmbedFileData) data() &byte {
// program that uses $embed_file('file.bin') in -prod mode.
// V will generate a static index of all embedded files, and will call the
// find_index_entry_by_path over the index and the relative paths of the embeds.
// NB: these are public on purpose, to help -usecache.
// Note: these are public on purpose, to help -usecache.
pub struct EmbedFileIndexEntry {
id int
path string

View File

@ -2,7 +2,7 @@ module eval
const empty = Void{}
// NB: i64 is an int_literal, NOT an i64 (same with f64)
// Note: i64 is an int_literal, NOT an i64 (same with f64)
type Object = Array
| Float
| Int

View File

@ -25,7 +25,7 @@ pub mut:
out_imports strings.Builder
indent int
empty_line bool
line_len int // the current line length, NB: it counts \t as 4 spaces, and starts at 0 after f.writeln
line_len int // the current line length, Note: it counts \t as 4 spaces, and starts at 0 after f.writeln
buffering bool // disables line wrapping for exprs that will be analyzed later
par_level int // how many parentheses are put around the current expression
array_init_break []bool // line breaks after elements in hierarchy level of multi dimensional array

View File

@ -617,7 +617,7 @@ fn (mut g Gen) gen_str_for_array(info ast.Array, styp string, str_fn_name string
}
} else {
// There is a custom .str() method, so use it.
// NB: we need to take account of whether the user has defined
// Note: we need to take account of whether the user has defined
// `fn (x T) str() {` or `fn (x &T) str() {`, and convert accordingly
deref, deref_label := deref_kind(str_method_expects_ptr, is_elem_ptr, typ)
g.auto_str_funcs.writeln('\t\tstrings__Builder_write_string(&sb, _SLIT("$deref_label"));')

View File

@ -15,7 +15,7 @@ import v.depgraph
import sync.pool
const (
// NB: some of the words in c_reserved, are not reserved in C,
// Note: some of the words in c_reserved, are not reserved in C,
// but are in C++, or have special meaning in V, thus need escaping too.
// `small` should not be needed, but see: https://stackoverflow.com/questions/5874215/what-is-rpcndr-h
c_reserved = ['array', 'auto', 'bool', 'break', 'calloc', 'case', 'char', 'class', 'complex',
@ -2001,7 +2001,7 @@ fn (mut g Gen) call_cfn_for_casting_expr(fname string, expr ast.Expr, exp_is_ptr
if !got_is_ptr {
if !expr.is_lvalue()
|| (expr is ast.Ident && (expr as ast.Ident).obj.is_simple_define_const()) {
// NB: the `_to_sumtype_` family of functions do call memdup internally, making
// Note: the `_to_sumtype_` family of functions do call memdup internally, making
// another duplicate with the HEAP macro is redundant, so use ADDR instead:
promotion_macro_name := if fname.contains('_to_sumtype_') { 'ADDR' } else { 'HEAP' }
g.write('${promotion_macro_name}($got_styp, (')
@ -2743,7 +2743,7 @@ fn (mut g Gen) expr(node ast.Expr) {
} else {
g.discard_or_result = false
}
// NB: please keep the type names in the match here in alphabetical order:
// Note: please keep the type names in the match here in alphabetical order:
match mut node {
ast.ComptimeType {
g.error('g.expr(): Unhandled ComptimeType', node.pos)
@ -4144,7 +4144,7 @@ fn (mut g Gen) const_decl(node ast.ConstDecl) {
}
}
else {
// NB: -usecache uses prebuilt modules, each compiled with:
// Note: -usecache uses prebuilt modules, each compiled with:
// `v build-module vlib/module`
// combined with a top level program, that is compiled with:
// `v -usecache toplevel`
@ -4432,7 +4432,7 @@ fn (mut g Gen) write_init_function() {
if g.pref.prealloc {
g.writeln('prealloc_vinit();')
}
// NB: the as_cast table should be *before* the other constant initialize calls,
// Note: the as_cast table should be *before* the other constant initialize calls,
// because it may be needed during const initialization of builtin and during
// calling module init functions too, just in case they do fail...
g.write('\tas_cast_type_indexes = ')
@ -4481,7 +4481,7 @@ fn (mut g Gen) write_init_function() {
// shared libraries need a way to call _vinit/2. For that purpose,
// provide a constructor/destructor pair, ensuring that all constants
// are initialized just once, and that they will be freed too.
// NB: os.args in this case will be [].
// Note: os.args in this case will be [].
g.writeln('__attribute__ ((constructor))')
g.writeln('void _vinit_caller() {')
g.writeln('\tstatic bool once = false; if (once) {return;} once = true;')
@ -5463,7 +5463,7 @@ fn (mut g Gen) interface_table() string {
mut methods_wrapper := strings.new_builder(100)
methods_wrapper.writeln('// Methods wrapper for interface "$interface_name"')
mut already_generated_mwrappers := map[string]int{}
iinidx_minimum_base := 1000 // NB: NOT 0, to avoid map entries set to 0 later, so `if already_generated_mwrappers[name] > 0 {` works.
iinidx_minimum_base := 1000 // Note: NOT 0, to avoid map entries set to 0 later, so `if already_generated_mwrappers[name] > 0 {` works.
mut current_iinidx := iinidx_minimum_base
for st in inter_info.types {
st_sym := g.table.sym(st)

View File

@ -3,7 +3,7 @@ module c
import strings
import v.pref
// NB: @@@ here serve as placeholders.
// Note: @@@ here serve as placeholders.
// They will be replaced with correct strings
// for each constant, during C code generation.
@ -77,7 +77,7 @@ fn arm32_bytes(nargs int) string {
}
// gen_amd64_bytecode generates the amd64 bytecode a closure with `nargs` parameters.
// NB: `nargs` includes the last `userdata` parameter that will be passed to the original
// Note: `nargs` includes the last `userdata` parameter that will be passed to the original
// function, and as such nargs must always be > 0
fn amd64_bytes(nargs int) string {
match nargs {

View File

@ -59,7 +59,7 @@ fn (mut g Gen) gen_c_main_function_header() {
}
// GUI application
g.writeln('int WINAPI wWinMain(HINSTANCE instance, HINSTANCE prev_instance, LPWSTR cmd_line, int show_cmd){')
g.writeln('\tLPWSTR full_cmd_line = GetCommandLineW(); // NB: do not use cmd_line')
g.writeln('\tLPWSTR full_cmd_line = GetCommandLineW(); // Note: do not use cmd_line')
g.writeln('\ttypedef LPWSTR*(WINAPI *cmd_line_to_argv)(LPCWSTR, int*);')
g.writeln('\tHMODULE shell32_module = LoadLibrary(L"shell32.dll");')
g.writeln('\tcmd_line_to_argv CommandLineToArgvW = (cmd_line_to_argv)GetProcAddress(shell32_module, "CommandLineToArgvW");')

View File

@ -498,7 +498,7 @@ fn (mut g Gen) gen_anon_fn(mut node ast.AnonFn) {
// ensure that nargs maps to a known entry in the __closure_thunk array
// TODO make it a compile-time error (you can't call `sizeof()` inside preprocessor `#if`s)
// NB: this won't be necessary when (if) we have functions that return the machine code for
// Note: this won't be necessary when (if) we have functions that return the machine code for
// an arbitrary number of arguments
g.write('__closure_create($node.decl.name, __closure_check_nargs($args_size), ($ctx_struct*) memdup(&($ctx_struct){')
g.indent++

View File

@ -497,7 +497,7 @@ fn (mut g JsGen) gen_str_for_array(info ast.Array, styp string, str_fn_name stri
// g.definitions.writeln('\t\tstring x = str_intp(2, _MOV((StrIntpData[]){{new string("\'"), $c.si_s_code, {.d_s = it }}, {new string("\'"), 0, {.d_c = 0 }}}));\n')
} else {
// There is a custom .str() method, so use it.
// NB: we need to take account of whether the user has defined
// Note: we need to take account of whether the user has defined
// `fn (x T) str() {` or `fn (x &T) str() {`, and convert accordingly
deref, deref_label := deref_kind(str_method_expects_ptr, is_elem_ptr, typ)
g.definitions.writeln('\t\tstrings__Builder_write_string(sb, new string("$deref_label"));')

View File

@ -219,7 +219,7 @@ pub fn (mut g JsGen) doc_typ(t ast.Type) string {
styp += '$name'
}
.enum_ {
// NB: We could declare them as TypeScript enums but TS doesn't like
// Note: We could declare them as TypeScript enums but TS doesn't like
// our namespacing so these break if declared in a different module.
// Until this is fixed, We need to use the type of an enum's members
// rather than the enum itself, and this can only be 'number' for now

View File

@ -854,7 +854,7 @@ fn (mut g JsGen) stmt(node ast.Stmt) {
}
fn (mut g JsGen) expr(node ast.Expr) {
// NB: please keep the type names in the match here in alphabetical order:
// Note: please keep the type names in the match here in alphabetical order:
match mut node {
ast.ComptimeType {
verror('not yet implemented')
@ -2077,7 +2077,7 @@ fn (mut g JsGen) gen_struct_decl(node ast.StructDecl) {
}
fn (mut g JsGen) gen_array_init_expr(it ast.ArrayInit) {
// NB: Fixed arrays and regular arrays are handled the same, since fixed arrays:
// Note: Fixed arrays and regular arrays are handled the same, since fixed arrays:
// 1) Are only available for number types
// 2) Give the code unnecessary complexity
// 3) Have several limitations like missing most `Array.prototype` methods

View File

@ -11,7 +11,7 @@ pub const (
)
// The live reloader code is implemented here.
// NB: new_live_reload_info will be called by generated C code inside main()
// Note: new_live_reload_info will be called by generated C code inside main()
pub fn new_live_reload_info(original string, vexe string, vopts string, live_fn_mutex voidptr, live_linkfn live.FNLinkLiveSymbols) &live.LiveReloadInfo {
file_base := os.file_name(original).replace('.v', '')
so_dir := os.cache_dir()
@ -34,7 +34,7 @@ pub fn new_live_reload_info(original string, vexe string, vopts string, live_fn_
}
}
// NB: start_reloader will be called by generated code inside main(), to start
// Note: start_reloader will be called by generated code inside main(), to start
// the hot code reloader thread. start_reloader is executed in the context of
// the original main thread.
pub fn start_reloader(mut r live.LiveReloadInfo) {
@ -127,7 +127,7 @@ fn protected_load_lib(mut r live.LiveReloadInfo, new_lib_path string) {
os.rm(new_lib_path) or {}
}
// NB: r.reloader() is executed in a new, independent thread
// Note: r.reloader() is executed in a new, independent thread
fn reloader(mut r live.LiveReloadInfo) {
// elog(r,'reloader, r: $r')
mut last_ts := os.file_last_mod_unix(r.original)

View File

@ -24,7 +24,7 @@ Since this test program is sensitive to coordination (or lack of) of several pro
it tries to sidestep the coordination issue by polling the file system for the existance
of files, ORIGINAL.txt ... STOP.txt , which are appended to by the generated program.
NB: That approach of monitoring the state of the running generated program, is clearly not ideal,
Note: That approach of monitoring the state of the running generated program, is clearly not ideal,
but sidesteps the issue of coordinating processes through IPC or stdin/stdout in hopefully
not very flaky way.
@ -59,7 +59,7 @@ fn edefault(name string, default string) string {
}
fn atomic_write_source(source string) {
// NB: here wrtiting is done in 2 steps, since os.write_file can take some time,
// Note: here wrtiting is done in 2 steps, since os.write_file can take some time,
// during which the file will be modified, but it will still be not completely written.
// The os.mv after that, guarantees that the reloader will see a complete valid V program.
os.write_file(tmp_file, source) or { panic(err) }

View File

@ -58,7 +58,7 @@ fn (mut p Parser) array_init() ast.ArrayInit {
p.inside_array_lit = old_inside_array_lit
line_nr := p.tok.line_nr
$if tinyc {
// NB: do not remove the next line without testing
// Note: do not remove the next line without testing
// v selfcompilation with tcc first
tcc_stack_bug := 12345
_ = tcc_stack_bug

View File

@ -205,7 +205,7 @@ pub fn (mut p Parser) set_path(path string) {
}
pub fn parse_file(path string, table &ast.Table, comments_mode scanner.CommentsMode, pref &pref.Preferences) &ast.File {
// NB: when comments_mode == .toplevel_comments,
// Note: when comments_mode == .toplevel_comments,
// the parser gives feedback to the scanner about toplevel statements, so that the scanner can skip
// all the tricky inner comments. This is needed because we do not have a good general solution
// for handling them, and should be removed when we do (the general solution is also needed for vfmt)
@ -2898,7 +2898,7 @@ fn (mut p Parser) string_expr() ast.Expr {
mut has_fmt := false
mut fwidth := 0
mut fwidthneg := false
// 987698 is a magic default value, unlikely to be present in user input. NB: 0 is valid precision
// 987698 is a magic default value, unlikely to be present in user input. Note: 0 is valid precision
mut precision := 987698
mut visible_plus := false
mut fill := false
@ -3018,7 +3018,7 @@ fn (mut p Parser) module_decl() ast.Module {
p.error_with_pos('`module` and `$name` must be at same line', name_pos)
return mod_node
}
// NB: this shouldn't be reassigned into name_pos
// Note: this shouldn't be reassigned into name_pos
// as it creates a wrong position when extended
// to module_pos
n_pos := p.tok.pos()

View File

@ -118,7 +118,7 @@ pub mut:
is_run bool
is_debug bool // turned on by -g or -cg, it tells v to pass -g to the C backend compiler.
is_vlines bool // turned on by -g (it slows down .tmp.c generation slightly).
// NB: passing -cg instead of -g will set is_vlines to false and is_debug to true, thus making v generate cleaner C files,
// Note: passing -cg instead of -g will set is_vlines to false and is_debug to true, thus making v generate cleaner C files,
// which are sometimes easier to debug / inspect manually than the .tmp.c files by plain -g (when/if v line number generation breaks).
sanitize bool // use Clang's new "-fsanitize" option
sourcemap bool // JS Backend: -sourcemap will create a source map - default false
@ -260,7 +260,7 @@ pub fn parse_args_and_show_errors(known_external_commands []string, args []strin
res.check_only = true
}
'-h', '-help', '--help' {
// NB: help is *very important*, just respond to all variations:
// Note: help is *very important*, just respond to all variations:
res.is_help = true
}
'-v' {
@ -673,7 +673,7 @@ pub fn parse_args_and_show_errors(known_external_commands []string, args []strin
res.parse_define('debug')
}
if command == 'run' && res.is_prod && os.is_atty(1) > 0 {
eprintln_cond(show_output, "NB: building an optimized binary takes much longer. It shouldn't be used with `v run`.")
eprintln_cond(show_output, "Note: building an optimized binary takes much longer. It shouldn't be used with `v run`.")
eprintln_cond(show_output, 'Use `v run` without optimization, or build an optimized binary with -prod first, then run it separately.')
}
@ -889,7 +889,7 @@ pub fn cc_from_string(cc_str string) CompilerType {
}
pub fn get_host_arch() Arch {
// NB: we can not use `$if arch` here, because V skips cgen for the non
// Note: we can not use `$if arch` here, because V skips cgen for the non
// current comptime branches by default, so there is a bootstrapping
// problem => the __V_architecture macro is used to resolve it.
// TODO: think about how to solve it for non C backends, perhaps we

Some files were not shown because too many files have changed in this diff Show More