omega-bridge
Omega-first language interoperability: checked conversion backends and native language bindings
Brought by drakestapleton
omega-bridge / tests / fixtures / echo.om
| 1 | note echo: copy stdin to stdout through a 4096-byte pool, until read gives 0 |
| 2 | global buf uchar 4096 |
| 3 | fn main to int |
| 4 | n = read 0 buf 0 len buf |
| 5 | while gt n 0 |
| 6 | w = write 1 buf 0 ulong n |
| 7 | if ne w n |
| 8 | ret 1 |
| 9 | end |
| 10 | n = read 0 buf 0 len buf |
| 11 | end |
| 12 | if lt n 0 |
| 13 | ret 2 |
| 14 | end |
| 15 | ret 0 |
| 16 | end |