From f91d5271548817068b232205275a21e8d6f5cbe2 Mon Sep 17 00:00:00 2001 From: Alexander Medvednikov Date: Tue, 14 Apr 2020 18:27:30 +0200 Subject: [PATCH] deprecate `import module` --- vlib/builtin/array.v | 7 ++++--- vlib/builtin/float.v | 27 ++++++++++++++++----------- vlib/v/parser/parser.v | 1 + 3 files changed, 21 insertions(+), 14 deletions(-) diff --git a/vlib/builtin/array.v b/vlib/builtin/array.v index 425b3bddc2..8b9a1d1ab7 100644 --- a/vlib/builtin/array.v +++ b/vlib/builtin/array.v @@ -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 diff --git a/vlib/builtin/float.v b/vlib/builtin/float.v index 2e02af7926..c989e11f63 100644 --- a/vlib/builtin/float.v +++ b/vlib/builtin/float.v @@ -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 - // ----- 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) } - diff --git a/vlib/v/parser/parser.v b/vlib/v/parser/parser.v index bf83aff806..9df088709d 100644 --- a/vlib/v/parser/parser.v +++ b/vlib/v/parser/parser.v @@ -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