So it is the last untyped **actions** parameter which is causing the problem?

**Changing the top example:**
    
    
    var lastGreeting: string
    
    template greet*(lastGreeting: untyped, text = "Hello", who = "Bob",
        actions: untyped) =
      lastGreeting = text & " " & who
      actions
      echo lastGreeting
    
    greet lastGreeting:
      echo "Example 1"
    greet(lastGreeting, "Hi"):
      echo "Example 2"
    greet(lastGreeting, "Salute", "Fred"):
      echo "Example 3"
    greet(lastGreeting, who = "Tom"):
      echo "Example 4"
    
    echo "\nLastGreeting: ", lastGreeting
    
    
    Run

does generate the same type of compile errors:
    
    
    /Users/dennismisener/work/Nim/test_template_optional_params.nim(64, 8) 
Error: undeclared identifier: 'mySite'
    candidates (edit distance, scope distance); see '--spellSuggest':
     (3, 3): 'system'
     (3, 4): 'byte'
     (3, 4): 'csize'
    dennismisener@Denniss-iMac nim % n test_template_optional_params.nim
    /Users/dennismisener/work/Nim/test_template_optional_params.nim(64, 8) 
Error: undeclared identifier: 'mySite'
    candidates (edit distance, scope distance); see '--spellSuggest':
     (3, 3): 'system'
     (3, 4): 'byte'
     (3, 4): 'csize'
    dennismisener@Denniss-iMac nim % n test_template_optional_params.nim
    /Users/dennismisener/work/Nim/test_template_optional_params.nim(64, 8) 
Error: undeclared identifier: 'mySite'
    candidates (edit distance, scope distance); see '--spellSuggest':
     (3, 3): 'system'
     (3, 4): 'byte'
     (3, 4): 'csize'
    dennismisener@Denniss-iMac nim % n test_template_optional_params.nim
    /Users/dennismisener/work/Nim/test_template_optional_params.nim(10, 1) 
Error: type mismatch
    Expression: greet lastGreeting do:
      echo ["Example 1"]
      [1] lastGreeting: string
      [2]
    echo ["Example 1"]: void
    
    Expected one of (first mismatch at [position]):
    [2] template greet(lastGreeting: untyped; text = "Hello"; who = "Bob";
                   actions: untyped)
    
    
    Run

Defaulting for the previous template parameters doesn't happen!!

**If so, how can I achieve the desired effect of template parameter defaulting 
in such a case?**

( _or is this a sad case of you can 't get there from here_ :-( )

Reply via email to