Quantcast

Forwarding freemarker vararg parameter

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Forwarding freemarker vararg parameter

Albert Kam
Hi all,

I have a function that accepts a vararg param, which i want to pass to another function that also has the vararg param :

<#function process extras...>
    <#local result=anotherProcess(extras)>
    ...
</#function>

<#function anotherProcess extras...>
    ...
</#function>

And if i call process(1, 2, 3), then on process(), the extras is [1, 2, 3].
But when extras is passed to anotherProcess(), the extras is now  [[1, 2, 3]], where i expect it to be [1, 2, 3].

Is there a way to pass the extras as 'expanded' list to anotherProcess, or in other words, just forward the 'extras' vararg as is ?

Thank you !

--
Do not pursue the past. Do not lose yourself in the future.
The past no longer is. The future has not yet come.
Looking deeply at life as it is in the very here and now,
the practitioner dwells in stability and freedom.
(Thich Nhat Hanh)

------------------------------------------------------------------------------
Download BIRT iHub F-Type - The Free Enterprise-Grade BIRT Server
from Actuate! Instantly Supercharge Your Business Reports and Dashboards
with Interactivity, Sharing, Native Excel Exports, App Integration & more
Get technology previously reserved for billion-dollar corporations, FREE
http://pubads.g.doubleclick.net/gampad/clk?id=164703151&iu=/4140/ostg.clktrk
_______________________________________________
FreeMarker-user mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/freemarker-user
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Forwarding freemarker vararg parameter

Daniel Dekany
Unfortunately there's no feature for that. As a work around, you can
introduce a non-varargs variant of the "anotherProcess" function, that
expects a list but without using "..." in the declaration, and then
call that from both the "process" and "anotherProcess" functions.

Wednesday, December 10, 2014, 10:33:24 AM, Albert Kam wrote:

> Hi all,
>
> I have a function that accepts a vararg param, which i want to pass
> to another function that also has the vararg param :
>
> <#function process extras...>
>     <#local result=anotherProcess(extras)>
>     ...
> </#function>
>
> <#function anotherProcess extras...>
>     ...
> </#function>
>
> And if i call process(1, 2, 3), then on process(), the extras is [1, 2, 3].
> But when extras is passed to anotherProcess(), the extras is now
> [[1, 2, 3]], where i expect it to be [1, 2, 3].
>
> Is there a way to pass the extras as 'expanded' list to
> anotherProcess, or in other words, just forward the 'extras' vararg as is ?
>
> Thank you !
>

--
Thanks,
 Daniel Dekany


------------------------------------------------------------------------------
Download BIRT iHub F-Type - The Free Enterprise-Grade BIRT Server
from Actuate! Instantly Supercharge Your Business Reports and Dashboards
with Interactivity, Sharing, Native Excel Exports, App Integration & more
Get technology previously reserved for billion-dollar corporations, FREE
http://pubads.g.doubleclick.net/gampad/clk?id=164703151&iu=/4140/ostg.clktrk
_______________________________________________
FreeMarker-user mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/freemarker-user
Loading...