UNPKG

sai-language

Version:

An object-oriented language designed to afford code comprehension and maintenance. Transpiles in-place to Javascript.

79 lines (42 loc) 2.34 kB
# This file is automatically generated. _Do not edit._ Unknown Heading ### ASSERT - _run-time error checking_ - globals - ^assert If the first expression is _falsy_, throw an exception with the second expression as a message. Otherwise, return the expression. assert [test value], [error message] .. !assert [test value], [error message] For example: assert everythingIsAwesome, 'I have some bad news...' > Error: SAI: failed assertion: I have some bad news... You can use __assert__ in an expression, because it returns the value passed. set sock !assert GetSocket, "Could not obtain socket resource" __Assert__, like __debug__, is functionality that can be redefined by passing a new handler to SAI's configuration facility. ### DEBUG - _print diagnostics to the console_ - globals - ^debug Prints the value of the expression to the console. debug [expr] Compiles to a call to $AI.debug_op in `sai-library`, which you can hook to provide your own implementation. In the default implementation, just calls `console.log` with the provided value. debug "this is a test" > this is a test ### ENVIRONMENT - _return SAI runtime environment information_ - globals - ^environment Call the __environment__ function to gain information about the runtime state of your SAI module. .. set env to environment() The __environment__ function returns different things based on whether your module is running in static or dynamic mode. In static mode (when you're running from a pre-compiled `.js` script), you get this: fields dynamic (false) static (true) In dynamic mode (when you're using the `sai-language` package to compile on the fly), you get this: fields dynamic (true) static (false) paths (array) // array of paths searched dring CREATE Clean (function) // reset the compiler environment Configure (function) // e.g. change paths, etc GetSource (function) // return full JS source for a SAI object by name RegisterWithNode (function) // theoretically register .sai with node's require Require (function) // a version of require that uses SAI's paths, not node's