https://github.com/abrudz/dyalog-safe-exec
Drop-in for ⍎ to execute arbitrary APL code safely
https://github.com/abrudz/dyalog-safe-exec
Last synced: 6 months ago
JSON representation
Drop-in for ⍎ to execute arbitrary APL code safely
- Host: GitHub
- URL: https://github.com/abrudz/dyalog-safe-exec
- Owner: abrudz
- License: mit
- Created: 2018-10-11T16:11:16.000Z (almost 7 years ago)
- Default Branch: master
- Last Pushed: 2024-07-23T10:59:05.000Z (about 1 year ago)
- Last Synced: 2025-02-10T15:30:33.199Z (8 months ago)
- Language: APL
- Size: 102 KB
- Stars: 11
- Watchers: 4
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README

# Safe Execute for [Dyalog APL](https://www.dyalog.com/)
*Drop-in for* `⍎` *to execute arbitrary APL code safely*Load with `⎕FIX 'file://path/Safe.dyalog'` then execute an expression with for example `Safe.Exec '⍳10'`.
Expressions are executed in a new empty namespace with `⎕IO←1` and `⎕ML←1`, but you can also supply a namespace ref in the optional left argument, and the expression will then be executed there.
The left argument may also contain a number indicating a timeout for expressions. If no such number is given, `10` (seconds) will be used.
If an error occcurs in the expression, it will be re-signalled from `Safe.Exec` but with error number incremented by `200`. E.g. a `DOMAIN ERROR` which is normally error number (`⎕EN`) `11` will be signalled as `211`.
The following errors may also be signalled:
`6` (`VALUE ERROR`) if the expression is shy or has no result
`10` (`EXPRESSION TIME LIMIT EXCEEDED`) if the expression timed out
`11` (`NOT PERMITTED`) if the expression attempted to use a restricted feature.
## Example usage
```
ns←⎕NS ⍬
ns.A←10
ns Safe.Exec '⍳A'
1 2 3 4 5 6 7 8 9 10
```For a more advanced example preserving a state and handling errors, see `Example.dyalog`.
## Logo
By [dzaima](https://chat.stackexchange.com/transcript/message/56823573#56823573) and [Wezl](https://chat.stackexchange.com/transcript/message/56823580#56823580).