weird macro params issue

John Cherouvim <[email protected]>
Newsgroups gmane.comp.web.freemarker.user
Message-ID <[email protected]>
Hello

I have this macro:
<#macro test a b=a c=b>
    ${a} - ${b} - ${c}
</#macro>

And this client code:
<@test 1 /><br/>
<@test 1 2 /><br/>
<@test 1 2 3 /><br/>

Which produces:
1 - 1 - 1
1 - 2 - 2
1 - 2 - 3

Now if I just change the param names of the macro:
<#macro test foo bar=foo baz=bar>
    ${foo} - ${bar} - ${baz}
</#macro>

And keep the same client code, then the output produced is:
InvalidReferenceException: Expression bar is undefined on line 20, 
column 31 in index.ftl.
1 - 2 - 2
1 - 2 - 3

The first call fails when it tries to evaluate the baz=bar. Why is that?

Also, is this usage valid in freemarker? To have parameters default to 
the value of other parameters. I find it very useful for some use cases.

thanks,
Ioannis

-------------------------------------------------------------------------
This SF.net email is sponsored by the 2008 JavaOne(SM) Conference 
Don't miss this year's exciting event. There's still time to save $100. 
Use priority code J8TL2D2. 
http://ad.doubleclick.net/clk;198757673;13503038;p?http://java.sun.com/javaone
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.