You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@freemarker.apache.org by Denis Bredelet <br...@mac.com.INVALID> on 2018/11/23 13:54:05 UTC

Re : Spread operator (splat operator) in FTL

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
 
-- 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


Re: Spread operator (splat operator) in FTL

Posted by Denis Bredelet <br...@mac.com.INVALID>.
Hi,

> On 25 Nov 2018, at 17:52, Daniel Dekany <dd...@apache.org> wrote:
> 
>> 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.

If I may do another suggestion, can we call this built-in “?set_args” or “?preset”?

I feel “spread args” could be too technical.

— Denis.

Re: Spread operator (splat operator) in FTL

Posted by Daniel Dekany <dd...@apache.org>.
Saturday, November 24, 2018, 9:25:46 PM, Denis Bredelet wrote:

> Hi Daniel,
>
>> Le 24 nov. 2018 à 20:11, Daniel Dekany <dd...@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


Re: Spread operator (splat operator) in FTL

Posted by Denis Bredelet <br...@mac.com.INVALID>.
Hi Daniel,

> Le 24 nov. 2018 à 20:11, Daniel Dekany <dd...@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 />

>> -- 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
> 


Re: Re : Spread operator (splat operator) in FTL

Posted by Daniel Dekany <dd...@apache.org>.
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.

> -- 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