08-select.M1pp (740B)
1 # %select(cond, then, else): only the chosen branch is rescanned. 2 # - cond truthy / falsy (any nonzero is truthy) 3 # - empty chosen branch (no stream push) 4 # - multi-token branch 5 # - branch containing a macro call (gets rescanned) 6 # - nested %select 7 8 %macro PICK(c, y, n) 9 %select(c, y, n) 10 %endm 11 12 # truthy / falsy 13 %select(1, yes, no) 14 %select(0, yes, no) 15 %select((= 4 4), eq, ne) 16 %select((!= 4 4), eq, ne) 17 18 # empty branches 19 empty_then_before %select(1, , kept) empty_then_after 20 empty_else_before %select(0, kept, ) empty_else_after 21 22 # multi-token branch 23 %select(1, alpha beta gamma, x y z) 24 25 # branch with a macro call (rescan) 26 %macro WORD(s) 27 s 28 %endm 29 %select(1, %WORD(picked), %WORD(skipped)) 30 31 # nested 32 %select(1, %select(0, A, B), C) 33 END