mirror of
https://github.com/vlang/v.git
synced 2023-08-10 21:13:21 +03:00
deprecate import module
This commit is contained in:
parent
211275ab49
commit
f91d527154
@ -3,13 +3,14 @@
|
||||
// that can be found in the LICENSE file.
|
||||
module builtin
|
||||
|
||||
import strings
|
||||
import (
|
||||
strings
|
||||
)
|
||||
|
||||
pub struct array {
|
||||
pub:
|
||||
// Using a void pointer allows to implement arrays without generics and without generating
|
||||
data voidptr// Using a void pointer allows to implement arrays without generics and without generating
|
||||
// extra code for every type.
|
||||
data voidptr
|
||||
len int
|
||||
cap int
|
||||
element_size int
|
||||
|
@ -2,12 +2,13 @@
|
||||
// Use of this source code is governed by an MIT license
|
||||
// that can be found in the LICENSE file.
|
||||
module builtin
|
||||
import strconv.ftoa
|
||||
|
||||
import (
|
||||
strconv.ftoa
|
||||
)
|
||||
|
||||
#include <float.h>
|
||||
|
||||
// ----- f64 to string functions -----
|
||||
|
||||
// str return a f64 as string in scientific notation, auto display digits limit
|
||||
[inline]
|
||||
pub fn (d f64) str() string {
|
||||
@ -23,7 +24,7 @@ pub fn (x f64) strsci(digit_num int) string {
|
||||
} else if n_digit > 17 {
|
||||
n_digit = 17
|
||||
}
|
||||
return ftoa.f64_to_str(x,n_digit)
|
||||
return ftoa.f64_to_str(x, n_digit)
|
||||
}
|
||||
|
||||
// return a decimal notation of the input f64
|
||||
@ -33,7 +34,6 @@ pub fn (x f64) strlong() string {
|
||||
}
|
||||
|
||||
// ----- f32 to string functions -----
|
||||
|
||||
// str return a f32 as string in scientific notation, auto display digits limit
|
||||
[inline]
|
||||
pub fn (d f32) str() string {
|
||||
@ -49,7 +49,7 @@ pub fn (x f32) strsci(digit_num int) string {
|
||||
} else if n_digit > 8 {
|
||||
n_digit = 8
|
||||
}
|
||||
return ftoa.f32_to_str(x,n_digit)
|
||||
return ftoa.f32_to_str(x, n_digit)
|
||||
}
|
||||
|
||||
// return a decimal notation of the input f32
|
||||
@ -59,20 +59,26 @@ pub fn (x f32) strlong() string {
|
||||
}
|
||||
|
||||
// ----- C functions -----
|
||||
|
||||
[inline]
|
||||
fn f32_abs(a f32) f32 {
|
||||
return if a < 0 { -a } else { a }
|
||||
return if a < 0 {
|
||||
-a
|
||||
} else {
|
||||
a
|
||||
}
|
||||
}
|
||||
|
||||
[inline]
|
||||
fn f64_abs(a f64) f64 {
|
||||
return if a < 0 { -a } else { a }
|
||||
return if a < 0 {
|
||||
-a
|
||||
} else {
|
||||
a
|
||||
}
|
||||
}
|
||||
|
||||
// compare floats using C epsilon
|
||||
// ==
|
||||
|
||||
[inline]
|
||||
pub fn (a f64) eq(b f64) bool {
|
||||
return f64_abs(a - b) <= C.DBL_EPSILON
|
||||
@ -175,4 +181,3 @@ fn (a f64) gebit(b f64) bool {
|
||||
fn (a f32) gebit(b f32) bool {
|
||||
return C.DEFAULT_GE(a, b)
|
||||
}
|
||||
|
||||
|
@ -1496,6 +1496,7 @@ fn (p mut Parser) import_stmt() []ast.Import {
|
||||
}
|
||||
p.check(.rpar)
|
||||
} else {
|
||||
p.warn('`import module` has been deprecated, use `import ( module )` instead')
|
||||
imports << p.parse_import()
|
||||
}
|
||||
return imports
|
||||
|
Loading…
Reference in New Issue
Block a user