raz / conform / run / ShortConst.raz

29 lines · 713 B · raw · history · last change 201d9da2

1(* and and or evaluate their right side only when needed, also when
2 the left side is a constant: false and f(), true or f() call no f,
3 as a value and as a condition, under not too. *)
4module ShortConst;
5import Out;
6
7(* Says c, so the output shows each call *)
8proc f(c: U8): BOOL;
9begin
10 Out.char(c);
11 return true;
12end;
13
14proc main*;
15var b: BOOL;
16begin
17 b := false and f('a');
18 b := true or f('b');
19 b := not (false and f('c'));
20 if b then Out.char('1'); end;
21 if not (true or f('d')) then Out.char('x'); end;
22 b := false and f('e') and f('f');
23 b := true and f('g');
24 b := false or f('h');
25 if false and true then Out.char('x'); end;
26 Out.char(10);
27end;
28
29end ShortConst.