[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:
2025-12-26 22:26:06 +08:00
parent 20f39b7eba
commit 25c971118a
7 changed files with 143 additions and 21 deletions

View File

@@ -3,7 +3,48 @@ Official Module `std.io`
Library/std/io/io.fig
*/
public func print(value) -> Null
import _builtins;
import noSpace; // sub module `no space print`
// outputs
public func print(objects...) -> Int
{
__fstdout_print(value);
}
var length := objects.length();
for var i:=0; i < length; i += 1
{
if i > 0
{
__fstdout_print(" ");
}
__fstdout_print(objects[i]);
}
return length;
}
public func println(objects...) -> Int
{
var length := objects.length();
for var i:=0; i < length; i += 1
{
if i > 0
{
__fstdout_print(" ");
}
__fstdout_print(objects[i]);
}
__fstdout_print("\n");
return length + 1;
}
// inputs
public func read() -> String
{
return __fstdin_read();
}
public func readln() -> String
{
return __fstdin_readln();
}