diff options
| author | Drahflow <drahflow@gmx.de> | 2017-05-31 16:49:56 +0200 |
|---|---|---|
| committer | Drahflow <drahflow@gmx.de> | 2017-05-31 16:49:56 +0200 |
| commit | 061dd644cbd2fdddbb2e52dbe63683fa7a04b769 (patch) | |
| tree | a69a50adf0b81e6878ddbcae30eef3ea6215b7e4 | |
| parent | 1fea64441786cb2affc755260c08c364ab483a4c (diff) | |
Implemented |=
| -rw-r--r-- | TODO | 1 | ||||
| -rw-r--r-- | compiler/standardClient.ey | 8 | ||||
| -rw-r--r-- | doc/global.md | 11 | ||||
| -rw-r--r-- | examples/working-compiler/apply.test | 18 |
4 files changed, 37 insertions, 1 deletions
@@ -1,4 +1,3 @@ -* implement |= as in { 1 add } |=i * better sys .file * don't make newly opened files executable by default * make :executable, :nonexecutable, :writable, :readable, etc. diff --git a/compiler/standardClient.ey b/compiler/standardClient.ey index d807d7c..b865856 100644 --- a/compiler/standardClient.ey +++ b/compiler/standardClient.ey @@ -4,6 +4,14 @@ { keys dump "undefined member in .|: " dump dump "" die } "#.|" defmd { keys dump "undefined member in =: " dump dump "" die } "#.=" defmd +{ + quoted { ==name =*f + name "|" sys .executeIdentifier + f + name "=" sys .executeIdentifier + } { ==name =*f name | f name = } ? * +} "|=" defq + ## regex support # ideas taken from http://swtch.com/~rsc/regexp/regexp3.html < diff --git a/doc/global.md b/doc/global.md index b20b3bc..e207973 100644 --- a/doc/global.md +++ b/doc/global.md @@ -58,6 +58,17 @@ Executes the top stack element. See [execution.md](execution.md) for the full st { "Hello World!" dump } * "Hello World!" +`|=` +---- + +Takes a name and a function from the stack. Resolves the name without +execution (like `|`) runs the function and then assigns the topmost +stack element back to name (like `=`). + + 0 ==long_variable_name + { 1 add } |=long_variable_name + long_variable_name dump # now 1 + `[` --- diff --git a/examples/working-compiler/apply.test b/examples/working-compiler/apply.test new file mode 100644 index 0000000..4dd3979 --- /dev/null +++ b/examples/working-compiler/apply.test @@ -0,0 +1,18 @@ +{ + quoted { ==name =*f + name "|" sys .executeIdentifier + f + name "=" sys .executeIdentifier + } { ==name =*f name | f name = } ? * +} "|=" defq + +0 ==i +i dump +{ 1 add } |=i +i dump + +{ + 0 ==j + { 1 add } |=j + j dump +} * |
