One way to solve it (might be the only way, because I guess expansion of body 
after `:` to last argument relies on keeping order of arguments and skipping 
arguments messes this up).

You can use named arguments instead:
    
    
    var lastGreeting: string
    
    template greet*(lastGreeting: untyped, text = "Hello", who = "Bob",
        actions: untyped) =
      lastGreeting = text & " " & who
      actions
      echo lastGreeting
    
    greet(lastGreeting, actions =
      echo "Example 1")
    greet(lastGreeting, "Hi", actions =
      echo "Example 2")
    greet(lastGreeting, "Salute", "Fred", actions =
      echo "Example 3")
    greet(lastGreeting, who = "Tom", actions =
      echo "Example 4")
    
    echo "\nLastGreeting: ", lastGreeting
    
    
    Run

Reply via email to