mirror of
https://github.com/peklaiho/madlisp.git
synced 2025-02-01 22:10:08 +00:00
add function: exit
This commit is contained in:
parent
5b2691d475
commit
72dc10f369
@ -144,6 +144,7 @@ doc | `(doc +)` | `"Return the sum of all arguments."` | Show description of a
|
|||||||
read | `(read "(+ 1 2 3)")` | `(+ 1 2 3)` | Read a string as code and return the expression.
|
read | `(read "(+ 1 2 3)")` | `(+ 1 2 3)` | Read a string as code and return the expression.
|
||||||
print | `(print "hello world")` | `"hello world"null` | Print expression on the screen. Print returns null (which is shown due to the extra print in repl). Give optional second argument as `true` to show strings in readable format.
|
print | `(print "hello world")` | `"hello world"null` | Print expression on the screen. Print returns null (which is shown due to the extra print in repl). Give optional second argument as `true` to show strings in readable format.
|
||||||
error | `(error "invalid value")` | `error: invalid value` | Throw an exception with message as argument.
|
error | `(error "invalid value")` | `error: invalid value` | Throw an exception with message as argument.
|
||||||
|
exit | `(exit 1)` | | Terminate the script with given exit code using [exit](https://www.php.net/manual/en/function.exit.php).
|
||||||
|
|
||||||
### Collection functions
|
### Collection functions
|
||||||
|
|
||||||
|
@ -41,6 +41,12 @@ class LispFactory
|
|||||||
}
|
}
|
||||||
));
|
));
|
||||||
|
|
||||||
|
$env->set('exit', new CoreFunc('exit', 'Terminate the script with given exit code.', 0, 1,
|
||||||
|
function ($status = 0) {
|
||||||
|
exit($status);
|
||||||
|
}
|
||||||
|
));
|
||||||
|
|
||||||
// Register core libraries
|
// Register core libraries
|
||||||
(new Lib\Collections())->register($env);
|
(new Lib\Collections())->register($env);
|
||||||
(new Lib\Compare())->register($env);
|
(new Lib\Compare())->register($env);
|
||||||
|
Loading…
Reference in New Issue
Block a user