diff --git a/index.html b/index.html index 63d276433..2271bb4bc 100644 --- a/index.html +++ b/index.html @@ -985,7 +985,7 @@
module core
type bool
type error
type int
module cy
module math
module cli
module os
type File
type Dir
type DirIterator
Table ArgOption
module test
Builtin modules are the bare minimum that comes with Cyber. The embeddable library contains these modules and nothing more. They include:
module core
#The core
module contains functions related to Cyber and common utilities. It is automatically imported into each script's namespace.
Sample usage:
-- `print` and `typeof` are available without imports.
print 'hello'
print typeof('my str').id()
+
func copy(val any) any
Copies a primitive value or creates a shallow copy of an object value.
@@ -2768,18 +2772,12 @@core. #
If
val
is an error,panic(val)
is invoked. Otherwise,val
is returned.
func panic(err any) dynamic
Stop execution in the current fiber and starts unwinding the call stack. See Unexpected Errors.
-
-
func parseCyber(src String) Map
Parses Cyber source string into structured map object. Currently, only metadata about static declarations is made available but this will be extended to include an AST.
-
-
func parseCyon(src String) any
Parses a CYON string into a value.
func performGC() Map
Runs the garbage collector once to detect reference cycles and abandoned objects. Returns the statistics of the run in a map value.
func print(str any)
Prints a value. The host determines how it is printed.
func runestr(val int) String
Converts a rune to a string.
-
-
func toCyon(val any) String
Encodes a value to CYON string.
^topic @@ -3043,7 +3041,25 @@
func typeof(val any) metatype
Returns the value's type as a
metatype
object.
type Box
#type TccState
#module cy
#The cy
module contains functions related to the Cyber language.
Sample usage:
+use cy
+print cy.toCyon([1, 2, 3])
+
+
+
++
func parse(src String) Map
Parses Cyber source string into a structured map object. Currently, only metadata about static declarations is made available but this will be extended to include an AST.
+
+
func parseCyon(src String) any
Parses a CYON string into a value.
+
+
func repl(read_line any)
Starts an isolated REPL session. The callback
+read_line(prefix String) String
is responsible for obtaining the input.
+^topic ++
func toCyon(val any) String
Encodes a value to CYON string.
+
module math
#The math module contains commonly used math constants and functions.
Sample usage:
use math
@@ -3051,6 +3067,7 @@ math. #
var r = 10.0
print(math.pi * r^2)
+
var e float
Euler's number and the base of natural logarithms; approximately 2.718.
@@ -3159,11 +3176,26 @@math. #
Std modules. #
Std modules come with Cyber's CLI. They include:
-
^topic -- os: System level functions.
-- test: Utilities for testing.
+- cli: Related to the command line.
+- os: System level functions.
+- test: Utilities for testing.
os. #
++
module cli
#The
+cli
module contains functions related to the command line.Sample usage:
++ + +use cli +cli.repl() +
+
func repl()
Starts an isolated REPL session. Invokes
+cy.repl(replReadLine)
.+^topic ++
func replReadLine(prefix String) String
Default implementation to read a line from the CLI for a REPL.
+
module os
#Cyber's os module contains system level functions. It's still undecided as to how much should be included here so it's incomplete. You can still access os and libc functions yourself using Cyber's FFI or embedding API.
Sample usage:
+use os @@ -3172,6 +3204,7 @@
os. #
for map -> [k, v]: print "$(k) -> $(v)"
var cpu String
The current cpu arch's tag name.
@@ -3320,7 +3353,7 @@
Map DirWalkEntry
^topic
Table ArgOption
#^topic -
key summary 'name' -> String
The name of the option to match excluding the hyphen prefix. eg. -path
'type' -> metatype(String | float | boolean)
Parse as given value type. 'default' -> any
Optional: Default value if option is missing. none
is used if this is not provided.test. #
+
module test
#The
test
module contains utilities for testing.Sample usage:
+use t 'test' @@ -3328,6 +3361,7 @@
test. #
var a = 123 + 321 t.eq(a, 444)
func assert(pred bool)
Panics if
pred
isfalse
.