系统内置功能
Flux包含许多预定义值。这些预定义值在各种内置包的源文件中定义。
当内置值在Flux中无法表示时,其值可能由托管环境定义。所有此类值必须具有相应的builtin语句来声明内置值的存在和类型。
BuiltinStatement = "builtin" identifier ":" TypeExpression .
TypeExpression = MonoType ["where" Constraints] .
MonoType = Tvar | BasicType | ArrayType | StreamType | VectorType | RecordType | FunctionType .
Tvar = "A" … "Z" .
BasicType = "int" | "uint" | "float" | "string" | "bool" | "time" | "duration" | "bytes" | "regexp" .
ArrayType = "[" MonoType "]" .
StreamType = "stream" "[" MonoType "]" .
VectorType = "vector" "[" MonoType "]" .
RecordType = ( "{" [RecordTypeProperties] "}" ) | ( "{" Tvar "with" RecordTypeProperties "}" ) .
FunctionType = "(" [FunctionTypeParameters] ")" "=>" MonoType .
RecordTypeProperties = RecordTypeProperty { "," RecordTypeProperty } .
RecordTypeProperty = Label ":" MonoType .
Label = identifier | string_lit
FunctionTypeParameters = FunctionTypeParameter { "," FunctionTypeParameter } .
FunctionTypeParameter = [ "<-" | "?" ] identifier ":" MonoType .
Constraints = Constraint { "," Constraint } .
Constraint = Tvar ":" Kinds .
Kinds = identifier { "+" identifier } .
示例
builtin filter : (<-tables: stream[T], fn: (r: T) => bool) => stream[T]