louise
The Louise language: compiler, runtime, std, tooling
Clone avec HTTPS, un jeton personnel en mot de passe, ou avec SSH, une clé ajoutée dans vos paramètres.
Dernier runRéussi#125 · main · 16 min 13 s
0Étoiles
0Forks
40Issues
| 1 | import std/io |
| 2 | |
| 3 | effect choose |
| 4 | { |
| 5 | ctl choose :: -> Bool |
| 6 | } |
| 7 | |
| 8 | // Continuations are one-shot: resuming twice is a runtime error. |
| 9 | fn both :: |
| 10 | { |
| 11 | handle |
| 12 | { |
| 13 | if choose () |
| 14 | { |
| 15 | 1 |
| 16 | } |
| 17 | else |
| 18 | { |
| 19 | 2 |
| 20 | } |
| 21 | } |
| 22 | with |
| 23 | { choose -> resume True + resume False } |
| 24 | } |
| 25 | |
| 26 | pub fn main :: -> () / <io> |
| 27 | { |
| 28 | io.println "start" |
| 29 | io.println (show (both ())) |
| 30 | } |
| 31 | //> start |
| 32 | //! panic: `resume` called twice (continuations are one-shot) |