programdemos/user-macros.xtl

A macro library of your own: userlibs/Repeat.xtlm (in the live demo, Repeat.xtlm among your files). It is found as a library of your own is, and its macro r:t_imes< writes statements as many times as you ask, when the program is expanded: a loop unrolled before it runs.

Run it with ./demos/user-macros.xtl or "xetal run demos/user-macros.xtl". It prints hip hip three times, hooray, then 32. "xetal expand demos/user-macros.xtl" shows the copies.

source · imports r: userlibs/Repeat.xtlm

x : Int

value · line 18

The number the five unrolled statements double, from 1 to 32.

x ← 1

x : Int

value · line 20

Five copies of x := x * 2, written by r:t_imes<.

"5" ʳt̲imes< "x := x * 2"
ʳt̲imes< expands to
x ← x × 2
x ← x × 2
x ← x × 2
x ← x × 2
x ← x × 2

x : Int

value · line 20

Five copies of x := x * 2, written by r:t_imes<.

"5" ʳt̲imes< "x := x * 2"
ʳt̲imes< expands to
x ← x × 2
x ← x × 2
x ← x × 2
x ← x × 2
x ← x × 2

x : Int

value · line 20

Five copies of x := x * 2, written by r:t_imes<.

"5" ʳt̲imes< "x := x * 2"
ʳt̲imes< expands to
x ← x × 2
x ← x × 2
x ← x × 2
x ← x × 2
x ← x × 2

x : Int

value · line 20

Five copies of x := x * 2, written by r:t_imes<.

"5" ʳt̲imes< "x := x * 2"
ʳt̲imes< expands to
x ← x × 2
x ← x × 2
x ← x × 2
x ← x × 2
x ← x × 2

x : Int

value · line 20

Five copies of x := x * 2, written by r:t_imes<.

"5" ʳt̲imes< "x := x * 2"
ʳt̲imes< expands to
x ← x × 2
x ← x × 2
x ← x × 2
x ← x × 2
x ← x × 2