Re: weird macro params issue

Felix Gnass <[email protected]>
Newsgroups gmane.comp.web.freemarker.user
Message-ID <[email protected]>
On May 22, 2008, at 0:24 , Jonathan Revusky wrote:

> On Wed, May 21, 2008 at 11:31 PM, Attila Szegedi  
> <[email protected]> wrote:
>> On 2008.05.21., at 22:01, Jonathan Revusky wrote:
>> As for people wanting to do this, well, we had the guy who started
>> this thread who was doing it, and now it also turned out that the
>> "fmdoc" project announced here few days ago also relies on it.
>
> I didn't realize that. How does fmdoc rely on this?
>

Hi, let me get this straight: The fmdoc tool itself doesn't rely on  
this at all. But it's true that one of the examples linked on the  
fmdoc homepage indeed exploits this "feature".

I don't know if this is of any help to you, but this is what I thought  
how things would work:

<#function foo a b=a>
   <#return "a:" + a + " b:" + b />
</#macro>

foo(1) == "a:1 b:1"

<#assign a=2 />
foo(1)  == "a:1 b:1"

... because the preceding argument shadows the variable "a" defined in  
the enclosing namespace.

Whereas ....

<#function foo a b=c c="foo" >
   <#return "a:" + a + " b:" + b + " c:" + c />
</#function>

... should throw an exception because "c" is defined after "b" ...  
unless of course a variable "c" was defined in the enclosing namespace:

foo(1) == [ERROR: c is undefined]

<#assign c=2 />
foo(1) == "a:1 b:2 c:foo"
foo(1,4,3) == "a:1 b:4 c:3"

Best regards,
-Felix


-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
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.