work in progress
Builtin functions are the main building blocks of Rye, the only active component.
Builtin functions and regular function have some information avaliable at runtime. These are provided in Go or Rye code directly.
We don’t want to make runtime too heavy, so additional infomation will be available as an offline structure that the runtime can use to display information in console for example. Or for generating information on the web.
For every builtin this consists of:
Runtime information is provided as part of making a builtin function, which has these fields available.
Loadable information is provided as a comment above the builtin function definition in a Go file. Example of such comment:
// The longer description of function, where it adds value,
// but if dostcstring is enough, don't write it just for the
// sake of it.
// Args:
// * subtrahend - the value being substraced from
// * minuend
// Tests:
// equal { 10 - 2 } 8
// equal { _- 2 10 } -8
// Example: Subtracting 3 values
// ; be careful how op-words (like -) work
// print ( 100 - 10 ) - 1
// ; prints 89
// print 100 - 10 - 1
// ; prints 91
// Examples:
// * Name of another example
// Tags: #math #core
"_-": { // **
Argsn: 2,
Doc: "Subtracts two numbers.",
Pure: true,
Fn: func(ps *env.ProgramState, arg0 env.Object, arg1 env.Object, arg2 env.Object, arg3 env.Object, arg4 env.Object) env.Object {
...
... (Go definition of builtin)