tobogganSe connecter

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.

32 lignes · 428 octetsBrut · Historique
1import std/io
2
3effect choose
4{
5 ctl choose :: -> Bool
6}
7
8// Continuations are one-shot: resuming twice is a runtime error.
9fn 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
26pub 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)