Saturday, November 24, 2018, 9:25:46 PM, Denis Bredelet wrote:

> Hi Daniel,
>
>> Le 24 nov. 2018 à 20:11, Daniel Dekany <ddek...@apache.org> a écrit :
>> 
>> Friday, November 23, 2018, 2:54:05 PM, Denis Bredelet wrote:
>> 
>>> Hi Daniel,
>>> 
>>> Note this discussion:
>>> https://issues.apache.org/jira/browse/FREEMARKER-107
>>> 
>>> That looks like func.apply() in Javascript right?
>>> https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Spread_syntax
>> 
>> func.apply() gives identical functionality, but no syntax to make it
>> succinct. Like consider (assuming the syntax is **kwargs, like in Python)
>> 
>>  <#assign commonParams = { 'style': 'foo', 'align': 'left' }>
>>  ...
>>  <@my.fancyInput type='text' size=10 **commonParams />
>> 
>> With function.apply-style it's something like:
>> 
>>  <@my?fancyInput?apply({ 'type': 'text', 'size': 10 } + commonParams) />
>> 
>> So that does the same without new syntax (it only adds a new built-in,
>> "apply"), but is more verbose, and it changes the look-and-feel of the
>> call a lot, just because you happen to need some dynamically added
>> parameters there.
>
> The extra parameters don’t need to be made into a map. You could just use 
> this syntax:
>
> <@my.fancyInput?apply(commonParams) type='text' size=10 />

Good point! Although then that's some form of currying, not "apply",
as the directive is not invoked by the built-in. But it's not normal
currying either, as we don't specifying the parameters directly. I
wonder what the built-in name should be. Maybe "spread_args":

<@my.fancyInput?spread_args(commonParams) type='text' size=10 />

Still not as nice as the specialized syntax, but certainly a better
compromise than adding new syntax.

>>> -- Denis.
>>> 
>>> Another interesting and long missing feature. The question is what the
>>> syntax should be, especially we need it both for by-position and
>>> by-name parameter passing.
>>> 
>> 
>> -- 
>> Thanks,
>> Daniel Dekany
>> 
>
>

-- 
Thanks,
 Daniel Dekany

Reply via email to