[Feat] 可变参数 variadic! 目前函数若使用可变参数,参数只能为1个
语法 func (arg...) 获取到的类型为 List
若要判断类型,使用标准库 std.value.type
[Feat] 标准库 std.io std.value 实现,提供print,read等函数
详见 Library/std 实现
[Impl] 分离 builtin value 和 function注册
This commit is contained in:
53
src/Module/Library/std/value/value.fig
Normal file
53
src/Module/Library/std/value/value.fig
Normal file
@@ -0,0 +1,53 @@
|
||||
/*
|
||||
Official Module `std.value`
|
||||
Library/std/value/value.fig
|
||||
*/
|
||||
|
||||
import _builtins;
|
||||
|
||||
public func type(object: Any) -> String
|
||||
{
|
||||
return __fvalue_type(object);
|
||||
}
|
||||
|
||||
public func int_parse(number: String) -> Int
|
||||
{
|
||||
return __fvalue_int_parse(number);
|
||||
}
|
||||
|
||||
public func int_from(number: Any) -> Any
|
||||
{
|
||||
var ntype := type(number);
|
||||
if ntype == "Double" or ntype == "Bool"
|
||||
{
|
||||
return __fvalue_int_from(number);
|
||||
}
|
||||
if ntype == "Int"
|
||||
{
|
||||
return number;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public func double_parse(number: String) -> Double
|
||||
{
|
||||
return __fvalue_double_parse(number);
|
||||
}
|
||||
|
||||
public func double_from(number: Any) -> Any
|
||||
{
|
||||
if ntype == "Int" or ntype == "Bool"
|
||||
{
|
||||
return __fvalue_double_from(number);
|
||||
}
|
||||
if ntype == "Double"
|
||||
{
|
||||
return number;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public func string_from(obj: Any) -> String
|
||||
{
|
||||
return __fvalue_string_from(obj);
|
||||
}
|
||||
Reference in New Issue
Block a user