mirror of
https://github.com/peklaiho/madlisp.git
synced 2024-11-22 21:35:03 +00:00
add toggle for debug output
This commit is contained in:
parent
1ece3649bc
commit
90f4d7860d
@ -162,6 +162,7 @@ quote | `(quote (1 2 3))` | `(1 2 3)` | Return the argument without evaluation.
|
||||
|
||||
Name | Example | Example result | Description
|
||||
----- | ------- | -------------- | -----------
|
||||
debug | `(debug)` | `true` | Toggle debug output.
|
||||
doc | `(doc +)` | `"Return the sum of all arguments."` | Show description of a built-in function.
|
||||
loop | `(loop (fn (a) (do (print a) (coinflip))) "hello ")` | `hello hello hello false` | Call the given function repeatedly in a loop until it returns false.
|
||||
meta | `(meta (env) "name")` | `"root/user"` | Read meta information of an entity.
|
||||
|
@ -294,6 +294,11 @@ class Evaller
|
||||
}
|
||||
}
|
||||
|
||||
public function getDebug(): bool
|
||||
{
|
||||
return $this->debug;
|
||||
}
|
||||
|
||||
public function setDebug(bool $val): void
|
||||
{
|
||||
$this->debug = $val;
|
||||
|
@ -18,6 +18,14 @@ class LispFactory
|
||||
$env->set('__DIR__', null);
|
||||
|
||||
// Register core functions
|
||||
$env->set('debug', new CoreFunc('debug', 'Toggle debug mode.', 0, 0,
|
||||
function () use ($eval) {
|
||||
$val = !$eval->getDebug();
|
||||
$eval->setDebug($val);
|
||||
return $val;
|
||||
}
|
||||
));
|
||||
|
||||
$env->set('doc', new CoreFunc('doc', 'Get documentation for a function.', 1, 1,
|
||||
function ($a) {
|
||||
if ($a instanceof Func) {
|
||||
|
Loading…
Reference in New Issue
Block a user