I've played a bit with this and I have created a simple macro (as a part of my 
macro-learning process):
    
    
    import macros
    
    
    macro `?`(a: bool, body: untyped): untyped =
      let
        b = body[1]
        c = body[2]
      
      result = quote:
        if `a`: `b` else: `c`
    
    
    Run

And here it is how you can use it: 
    
    
    proc a1(): int =
      echo "a1"
      return 1
    
    proc a2(): int =
      echo "a2"
      return 2
    
    let
      a = 0 == 1 ? "wow" ! "nothing unusual"
      b = (3 == 1 + 2) ? "yup" & ", this also works" ! "nope"
      c = 'a' < 'b' ? 65+27 ! 42
      d = 'a' > 'b' ? a1 ! a2
    
    
    echo a
    echo b
    echo c
    echo d()
    
    
    Run

Notice that I use `!`, but you can also use `|` or any other not used symbol 
(`:` is used, and you cannot use it)

Reply via email to