| 1 | module Generic; |
| 2 | import Out, Stack, Ints := Pile(I64), More := Pile(I64), Strs := Pile([]const U8); |
| 3 | import SYSTEM; |
| 4 | |
| 5 | proc yes(b: BOOL); |
| 6 | begin |
| 7 | if b then Out.str("true"); else Out.str("false"); end; |
| 8 | end; |
| 9 | |
| 10 | proc main*; |
| 11 | var l: Strs.Pile; v: I64; s: []const U8; ok: BOOL; |
| 12 | begin |
| 13 | ok := Ints.push(Stack.p, 7); |
| 14 | ok := More.push(Stack.p, 8); (* two imports, one instance: one pile *) |
| 15 | Out.int(Stack.top()); Out.char(' '); Out.int(Stack.p^.len); Out.char(' '); yes(ok); Out.ln; |
| 16 | v, ok := Ints.pop(Stack.p); |
| 17 | Out.int(v); Out.char(' '); Out.int(Stack.p^.len); Out.ln; |
| 18 | ok := Strs.push(SYSTEM.ADR(l), "b"); |
| 19 | ok := Strs.push(SYSTEM.ADR(l), "a"); |
| 20 | s, ok := Strs.pop(SYSTEM.ADR(l)); |
| 21 | Out.str(s); Out.str(Strs.top(SYSTEM.ADR(l))); yes(ok); Out.ln; |
| 22 | s, ok := Strs.pop(SYSTEM.ADR(l)); |
| 23 | s, ok := Strs.pop(SYSTEM.ADR(l)); |
| 24 | Out.char('['); Out.str(s); Out.str("] "); yes(ok); Out.ln; |
| 25 | end; |
| 26 | |
| 27 | end Generic. |