Opinions about conditional built-in names?

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
20 messages Options
Reply | Threaded
Open this post in threaded view
|

Opinions about conditional built-in names?

Daniel Dekany
I have added someBoolean?choose(whenTrue, whenFalse), which is the FTL
equivalent of the ternary operator. Only one of the parameter
expressions will be evaluated. The name was voted/discussed back then,
though I'm still open for new ideas.

I also want to add this:

  someValue?switch(case1, result1, case2, result2, ...)

and I wonder what the name should be. Any opinions?

--
Best regards,
 Daniel Dekany


------------------------------------------------------------------------------
_______________________________________________
FreeMarker-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/freemarker-devel
Reply | Threaded
Open this post in threaded view
|

Re: Opinions about conditional built-in names?

bredelet
‎I think that "switch" is fine. Although "choose" or "choice" would work, but you are already taking it for the ternary operator. 

What other options were considered ? 

Maybe it could be:

${selected?then("Y","N")}
${agegroup?choice(4,"free", 12,"half price", 60, "standard", 120, "senior")}

I like choose/switch personally.

-- Denis.
  Original Message  
From: Daniel Dekany
Sent: Saturday, 30 May 2015 09:05
To: [hidden email]
Reply To: Daniel Dekany
Subject: [Freemarker-devel] Opinions about conditional built-in names?

I have added someBoolean?choose(whenTrue, whenFalse), which is the FTL
equivalent of the ternary operator. Only one of the parameter
expressions will be evaluated. The name was voted/discussed back then,
though I'm still open for new ideas.

I also want to add this:

someValue?switch(case1, result1, case2, result2, ...)

and I wonder what the name should be. Any opinions?

--
Best regards,
Daniel Dekany


------------------------------------------------------------------------------
_______________________________________________
FreeMarker-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/freemarker-devel

------------------------------------------------------------------------------
_______________________________________________
FreeMarker-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/freemarker-devel
Reply | Threaded
Open this post in threaded view
|

Re: Opinions about conditional built-in names?

Daniel Dekany
Saturday, May 30, 2015, 10:28:33 AM, [hidden email] wrote:

> ‎I think that "switch" is fine. Although "choose" or "choice" would
> work, but you are already taking it for the ternary operator. 
>
> What other options were considered ? 

clicked?choose("show", "hide")
clicked?choice("show", "hide")
clicked?either("show", "hide")
clicked?then("show", "hide")

Also there was clicked?then("show")!"hide", which is smart, but
exactly because of that I expect that the two parameter version is
easier to grasp for most users. Also it has a confusing collusion with
the planned (long term...) null-bypassing feature (which is skipping
built-in invocation when the left hand operand is null, so things like
maybeNull?iso_utc!'Not happened' will work.)

?then is not bad, though I miss the "else" from it, but
clicked?thenElse("show", "hide") doesn't look elegant.

I don't feel comfortable with ?choose either BTW, but it has to be
something...

> Maybe it could be:
>
> ${selected?then("Y","N")}
> ${agegroup?choice(4,"free", 12,"half price", 60, "standard", 120, "senior")}

Yeah, the "choice" word fits this usage better, but for that construct
I would go for "switch" anyway, for familiarity. I think that most
template authors were exposed to some C-ish language (even if just
JavaScript), so with "switch" they will feel more confident and don't
feel pressure to look up the built-in in the Manual.

--
Thanks,
 Daniel Dekany


One more thing regarding ?switch is that if it founds no match, that
would be an error, except if you have an odd number of arguments, in
which case the last argument corresponds to the switch's default
branch. I have also considered requiring an even number of arguments,
and then just return null if there was no matching case, and so once
can write x?switch(1, 'one', 2, 'two')!'more', but it basically have
the same problems as ?then(this)!other, plus users wont understand
what's going on when x?switch(1, 'one', 2, 'two') will be "null or
missing", while otherwise I can just tell in the error message that
none of the cases matched etc.

> I like choose/switch personally.
>
> -- Denis.
>   Original Message  
> From: Daniel Dekany
> Sent: Saturday, 30 May 2015 09:05
> To: [hidden email]
> Reply To: Daniel Dekany
> Subject: [Freemarker-devel] Opinions about conditional built-in names?
> ‎
> I have added someBoolean?choose(whenTrue, whenFalse), which is the FTL
> equivalent of the ternary operator. Only one of the parameter
> expressions will be evaluated. The name was voted/discussed back then,
> though I'm still open for new ideas.
>
> I also want to add this:
>
> someValue?switch(case1, result1, case2, result2, ...)
>
> and I wonder what the name should be. Any opinions?
>


------------------------------------------------------------------------------
_______________________________________________
FreeMarker-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/freemarker-devel
Reply | Threaded
Open this post in threaded view
|

Re: Opinions about conditional built-in names?

Daniel Dekany
And regarding the semantics of ?switch... as it sands now, if there's
no matching choice, that will be an exception that says:

  The value before ?switch(case1, value1, case2, value2, ...) didn't
  match any of the case parameters, and there was no default value
  parameter (an additional last parameter) either.

So, if you have an odd number of parameters, then the last one is like
the default branch of switch in Java.

I have also considered just returning null if there's no match, and
then one can write ?switch(...)!theDefault, but then if someone
doesn't give a default, the error messages will just say that
?switch(...) has evaluated to null/missing, which many users won't
understand why's happening. Also it has the same problems as
?then(this)!that had.

--
Thanks,
 Daniel Dekany


Saturday, May 30, 2015, 11:54:45 AM, Daniel Dekany wrote:

> Saturday, May 30, 2015, 10:28:33 AM, [hidden email] wrote:
>
>> ‎I think that "switch" is fine. Although "choose" or "choice" would
>> work, but you are already taking it for the ternary operator. 
>>
>> What other options were considered ? 
>
> clicked?choose("show", "hide")
> clicked?choice("show", "hide")
> clicked?either("show", "hide")
> clicked?then("show", "hide")
>
> Also there was clicked?then("show")!"hide", which is smart, but
> exactly because of that I expect that the two parameter version is
> easier to grasp for most users. Also it has a confusing collusion with
> the planned (long term...) null-bypassing feature (which is skipping
> built-in invocation when the left hand operand is null, so things like
> maybeNull?iso_utc!'Not happened' will work.)
>
> ?then is not bad, though I miss the "else" from it, but
> clicked?thenElse("show", "hide") doesn't look elegant.
>
> I don't feel comfortable with ?choose either BTW, but it has to be
> something...
>
>> Maybe it could be:
>>
>> ${selected?then("Y","N")}
>> ${agegroup?choice(4,"free", 12,"half price", 60, "standard", 120, "senior")}
>
> Yeah, the "choice" word fits this usage better, but for that construct
> I would go for "switch" anyway, for familiarity. I think that most
> template authors were exposed to some C-ish language (even if just
> JavaScript), so with "switch" they will feel more confident and don't
> feel pressure to look up the built-in in the Manual.


------------------------------------------------------------------------------
_______________________________________________
FreeMarker-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/freemarker-devel
Reply | Threaded
Open this post in threaded view
|

Re: Opinions about conditional built-in names?

Woonsan Ko
I personally prefer having the default value option inside the
parenthesis, without having to depend on the default value after '!'.
So, I like the idea the odd number of parameters for a default value.

Regarding the original question about 'switch' and 'choose', I like the
'switch' very much, but I'm not sure if 'choose' is a good name for
ternary operator. In XSL, 'choose' means just one choice of the
'switch'. 'choose' sounds like related to one of the 'multiple' choices
to me.
Another option to consider might be 'iif' [1], which seems a bit clearer
to me than 'either' and others.

    someBoolean?iif(whenTrue, whenFalse)

Just my two cents,

Woonsan

[1] http://en.wikipedia.org/wiki/IIf

On 5/30/15 6:02 AM, Daniel Dekany wrote:

> And regarding the semantics of ?switch... as it sands now, if there's
> no matching choice, that will be an exception that says:
>
>   The value before ?switch(case1, value1, case2, value2, ...) didn't
>   match any of the case parameters, and there was no default value
>   parameter (an additional last parameter) either.
>
> So, if you have an odd number of parameters, then the last one is like
> the default branch of switch in Java.
>
> I have also considered just returning null if there's no match, and
> then one can write ?switch(...)!theDefault, but then if someone
> doesn't give a default, the error messages will just say that
> ?switch(...) has evaluated to null/missing, which many users won't
> understand why's happening. Also it has the same problems as
> ?then(this)!that had.
>


--
[hidden email]     www.onehippo.com
Boston - 745 Atlantic Ave, 8th Floor, Boston MA 02111
Amsterdam - Oosteinde 11, 1017 WT Amsterdam
US +1 877 414 4776 (toll free)
Europe +31(0)20 522 4466

------------------------------------------------------------------------------
_______________________________________________
FreeMarker-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/freemarker-devel
Reply | Threaded
Open this post in threaded view
|

Re: Opinions about conditional built-in names?

Daniel Dekany
Sunday, May 31, 2015, 7:50:20 PM, Woonsan Ko wrote:

> I personally prefer having the default value option inside the
> parenthesis, without having to depend on the default value after '!'.
> So, I like the idea the odd number of parameters for a default value.
>
> Regarding the original question about 'switch' and 'choose', I like the
> 'switch' very much, but I'm not sure if 'choose' is a good name for
> ternary operator. In XSL, 'choose' means just one choice of the
> 'switch'.

Actually, in XSLT "choose" stands for "switch" (and "when" stands for
"case"). But that just proves how confusing this word is... :)

> 'choose' sounds like related to one of the 'multiple' choices
> to me.

Well, I'm also unhappy with "choose", I just couldn't find better
yet... What do you think about "then". Apart from the lack of "else"
in it, it reads quite fluently: loggedIn?then(user.name, "unknown").

> Another option to consider might be 'iif' [1], which seems a bit clearer
> to me than 'either' and others.
>
>     someBoolean?iif(whenTrue, whenFalse)
>
> Just my two cents,

I have played that idea back then, but I'm afraid very few knows what
does "iif" stands for. Also loggedIn?iif(user.name, "unknown") can be
easily misread like: we are logged in IF user.name is "unknown".

> Woonsan
>
> [1] http://en.wikipedia.org/wiki/IIf
>
> On 5/30/15 6:02 AM, Daniel Dekany wrote:
>> And regarding the semantics of ?switch... as it sands now, if there's
>> no matching choice, that will be an exception that says:
>>
>>   The value before ?switch(case1, value1, case2, value2, ...) didn't
>>   match any of the case parameters, and there was no default value
>>   parameter (an additional last parameter) either.
>>
>> So, if you have an odd number of parameters, then the last one is like
>> the default branch of switch in Java.
>>
>> I have also considered just returning null if there's no match, and
>> then one can write ?switch(...)!theDefault, but then if someone
>> doesn't give a default, the error messages will just say that
>> ?switch(...) has evaluated to null/missing, which many users won't
>> understand why's happening. Also it has the same problems as
>> ?then(this)!that had.
>>
>
>

--
Thanks,
 Daniel Dekany


------------------------------------------------------------------------------
_______________________________________________
FreeMarker-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/freemarker-devel
Reply | Threaded
Open this post in threaded view
|

Re: Opinions about conditional built-in names?

Woonsan Ko
On 6/1/15 3:26 PM, Daniel Dekany wrote:

> Sunday, May 31, 2015, 7:50:20 PM, Woonsan Ko wrote:
>
>> I personally prefer having the default value option inside the
>> parenthesis, without having to depend on the default value after '!'.
>> So, I like the idea the odd number of parameters for a default value.
>>
>> Regarding the original question about 'switch' and 'choose', I like the
>> 'switch' very much, but I'm not sure if 'choose' is a good name for
>> ternary operator. In XSL, 'choose' means just one choice of the
>> 'switch'.
>
> Actually, in XSLT "choose" stands for "switch" (and "when" stands for
> "case"). But that just proves how confusing this word is... :)

Oh you're right. Long time passed after I wrote XSL files last. :-D

>
>> 'choose' sounds like related to one of the 'multiple' choices
>> to me.
>
> Well, I'm also unhappy with "choose", I just couldn't find better
> yet... What do you think about "then". Apart from the lack of "else"
> in it, it reads quite fluently: loggedIn?then(user.name, "unknown").

Yeah, "then" sounds better to me than anything else.

>
>> Another option to consider might be 'iif' [1], which seems a bit clearer
>> to me than 'either' and others.
>>
>>     someBoolean?iif(whenTrue, whenFalse)
>>
>> Just my two cents,
>
> I have played that idea back then, but I'm afraid very few knows what
> does "iif" stands for. Also loggedIn?iif(user.name, "unknown") can be
> easily misread like: we are logged in IF user.name is "unknown".

Agreed. Not sound fluent.

Kind regards,

Woonsan

>
>> Woonsan
>>
>> [1] http://en.wikipedia.org/wiki/IIf
>>
>> On 5/30/15 6:02 AM, Daniel Dekany wrote:
>>> And regarding the semantics of ?switch... as it sands now, if there's
>>> no matching choice, that will be an exception that says:
>>>
>>>   The value before ?switch(case1, value1, case2, value2, ...) didn't
>>>   match any of the case parameters, and there was no default value
>>>   parameter (an additional last parameter) either.
>>>
>>> So, if you have an odd number of parameters, then the last one is like
>>> the default branch of switch in Java.
>>>
>>> I have also considered just returning null if there's no match, and
>>> then one can write ?switch(...)!theDefault, but then if someone
>>> doesn't give a default, the error messages will just say that
>>> ?switch(...) has evaluated to null/missing, which many users won't
>>> understand why's happening. Also it has the same problems as
>>> ?then(this)!that had.
>>>
>>
>>
>


--
[hidden email]     www.onehippo.com
Boston - 745 Atlantic Ave, 8th Floor, Boston MA 02111
Amsterdam - Oosteinde 11, 1017 WT Amsterdam
US +1 877 414 4776 (toll free)
Europe +31(0)20 522 4466

------------------------------------------------------------------------------
_______________________________________________
FreeMarker-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/freemarker-devel
Reply | Threaded
Open this post in threaded view
|

Re: [vote] Opinions about conditional built-in names?

Daniel Dekany
OK, so that's like a vote for "then". Anyone else has an opinion? Or
even just a vote on the name you prefer?

someBoolean?then(whenTrue, whenFalse)someBoolean?then(whenTrue, whenFalse)
or
someBoolean?choose(whenTrue, whenFalse)
or
something else?

--
Thanks,
 Daniel Dekany


Monday, June 1, 2015, 9:41:49 PM, Woonsan Ko wrote:

> On 6/1/15 3:26 PM, Daniel Dekany wrote:
>> Sunday, May 31, 2015, 7:50:20 PM, Woonsan Ko wrote:
>>
>>> I personally prefer having the default value option inside the
>>> parenthesis, without having to depend on the default value after '!'.
>>> So, I like the idea the odd number of parameters for a default value.
>>>
>>> Regarding the original question about 'switch' and 'choose', I like the
>>> 'switch' very much, but I'm not sure if 'choose' is a good name for
>>> ternary operator. In XSL, 'choose' means just one choice of the
>>> 'switch'.
>>
>> Actually, in XSLT "choose" stands for "switch" (and "when" stands for
>> "case"). But that just proves how confusing this word is... :)
>
> Oh you're right. Long time passed after I wrote XSL files last. :-D
>
>>
>>> 'choose' sounds like related to one of the 'multiple' choices
>>> to me.
>>
>> Well, I'm also unhappy with "choose", I just couldn't find better
>> yet... What do you think about "then". Apart from the lack of "else"
>> in it, it reads quite fluently: loggedIn?then(user.name, "unknown").
>
> Yeah, "then" sounds better to me than anything else.
>
>>
>>> Another option to consider might be 'iif' [1], which seems a bit clearer
>>> to me than 'either' and others.
>>>
>>>     someBoolean?iif(whenTrue, whenFalse)
>>>
>>> Just my two cents,
>>
>> I have played that idea back then, but I'm afraid very few knows what
>> does "iif" stands for. Also loggedIn?iif(user.name, "unknown") can be
>> easily misread like: we are logged in IF user.name is "unknown".
>
> Agreed. Not sound fluent.
>
> Kind regards,
>
> Woonsan
>
>>
>>> Woonsan
>>>
>>> [1] http://en.wikipedia.org/wiki/IIf
>>>
>>> On 5/30/15 6:02 AM, Daniel Dekany wrote:
>>>> And regarding the semantics of ?switch... as it sands now, if there's
>>>> no matching choice, that will be an exception that says:
>>>>
>>>>   The value before ?switch(case1, value1, case2, value2, ...) didn't
>>>>   match any of the case parameters, and there was no default value
>>>>   parameter (an additional last parameter) either.
>>>>
>>>> So, if you have an odd number of parameters, then the last one is like
>>>> the default branch of switch in Java.
>>>>
>>>> I have also considered just returning null if there's no match, and
>>>> then one can write ?switch(...)!theDefault, but then if someone
>>>> doesn't give a default, the error messages will just say that
>>>> ?switch(...) has evaluated to null/missing, which many users won't
>>>> understand why's happening. Also it has the same problems as
>>>> ?then(this)!that had.
>>>>
>>>
>>>
>>
>
>


------------------------------------------------------------------------------
_______________________________________________
FreeMarker-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/freemarker-devel
Reply | Threaded
Open this post in threaded view
|

Re: [vote] Opinions about conditional built-in names?

Raymond Auge
I lean to "then".

But before deciding maybe a quick look over these: http://en.wikipedia.org/wiki/%3F:

- Ray

On Tue, Jun 2, 2015 at 3:01 AM, Daniel Dekany <[hidden email]> wrote:
OK, so that's like a vote for "then". Anyone else has an opinion? Or
even just a vote on the name you prefer?

someBoolean?then(whenTrue, whenFalse)someBoolean?then(whenTrue, whenFalse)
or
someBoolean?choose(whenTrue, whenFalse)
or
something else?

--
Thanks,
 Daniel Dekany


Monday, June 1, 2015, 9:41:49 PM, Woonsan Ko wrote:

> On 6/1/15 3:26 PM, Daniel Dekany wrote:
>> Sunday, May 31, 2015, 7:50:20 PM, Woonsan Ko wrote:
>>
>>> I personally prefer having the default value option inside the
>>> parenthesis, without having to depend on the default value after '!'.
>>> So, I like the idea the odd number of parameters for a default value.
>>>
>>> Regarding the original question about 'switch' and 'choose', I like the
>>> 'switch' very much, but I'm not sure if 'choose' is a good name for
>>> ternary operator. In XSL, 'choose' means just one choice of the
>>> 'switch'.
>>
>> Actually, in XSLT "choose" stands for "switch" (and "when" stands for
>> "case"). But that just proves how confusing this word is... :)
>
> Oh you're right. Long time passed after I wrote XSL files last. :-D
>
>>
>>> 'choose' sounds like related to one of the 'multiple' choices
>>> to me.
>>
>> Well, I'm also unhappy with "choose", I just couldn't find better
>> yet... What do you think about "then". Apart from the lack of "else"
>> in it, it reads quite fluently: loggedIn?then(user.name, "unknown").
>
> Yeah, "then" sounds better to me than anything else.
>
>>
>>> Another option to consider might be 'iif' [1], which seems a bit clearer
>>> to me than 'either' and others.
>>>
>>>     someBoolean?iif(whenTrue, whenFalse)
>>>
>>> Just my two cents,
>>
>> I have played that idea back then, but I'm afraid very few knows what
>> does "iif" stands for. Also loggedIn?iif(user.name, "unknown") can be
>> easily misread like: we are logged in IF user.name is "unknown".
>
> Agreed. Not sound fluent.
>
> Kind regards,
>
> Woonsan
>
>>
>>> Woonsan
>>>
>>> [1] http://en.wikipedia.org/wiki/IIf
>>>
>>> On 5/30/15 6:02 AM, Daniel Dekany wrote:
>>>> And regarding the semantics of ?switch... as it sands now, if there's
>>>> no matching choice, that will be an exception that says:
>>>>
>>>>   The value before ?switch(case1, value1, case2, value2, ...) didn't
>>>>   match any of the case parameters, and there was no default value
>>>>   parameter (an additional last parameter) either.
>>>>
>>>> So, if you have an odd number of parameters, then the last one is like
>>>> the default branch of switch in Java.
>>>>
>>>> I have also considered just returning null if there's no match, and
>>>> then one can write ?switch(...)!theDefault, but then if someone
>>>> doesn't give a default, the error messages will just say that
>>>> ?switch(...) has evaluated to null/missing, which many users won't
>>>> understand why's happening. Also it has the same problems as
>>>> ?then(this)!that had.
>>>>
>>>
>>>
>>
>
>


------------------------------------------------------------------------------
_______________________________________________
FreeMarker-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/freemarker-devel



--
Raymond Augé (@rotty3000)
Senior Software Architect Liferay, Inc. (@Liferay)
Board Member & EEG Co-Chair, OSGi Alliance (@OSGiAlliance)

------------------------------------------------------------------------------

_______________________________________________
FreeMarker-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/freemarker-devel
Reply | Threaded
Open this post in threaded view
|

Re: [vote] Opinions about conditional built-in names?

Raymond Auge
Having reviewed those and due to my preferring readability over anything else, I would still lean toward:

someBoolean?then(whenTrue, whenFalse)

But would actually prefer the more expressive:

someBoolean?ifelse(whenTrue, whenFalse)

I'd learn to deal with the first of course.

- Ray

On Tue, Jun 2, 2015 at 7:47 AM, Raymond Auge <[hidden email]> wrote:
I lean to "then".

But before deciding maybe a quick look over these: http://en.wikipedia.org/wiki/%3F:

- Ray

On Tue, Jun 2, 2015 at 3:01 AM, Daniel Dekany <[hidden email]> wrote:
OK, so that's like a vote for "then". Anyone else has an opinion? Or
even just a vote on the name you prefer?

someBoolean?then(whenTrue, whenFalse)someBoolean?then(whenTrue, whenFalse)
or
someBoolean?choose(whenTrue, whenFalse)
or
something else?

--
Thanks,
 Daniel Dekany


Monday, June 1, 2015, 9:41:49 PM, Woonsan Ko wrote:

> On 6/1/15 3:26 PM, Daniel Dekany wrote:
>> Sunday, May 31, 2015, 7:50:20 PM, Woonsan Ko wrote:
>>
>>> I personally prefer having the default value option inside the
>>> parenthesis, without having to depend on the default value after '!'.
>>> So, I like the idea the odd number of parameters for a default value.
>>>
>>> Regarding the original question about 'switch' and 'choose', I like the
>>> 'switch' very much, but I'm not sure if 'choose' is a good name for
>>> ternary operator. In XSL, 'choose' means just one choice of the
>>> 'switch'.
>>
>> Actually, in XSLT "choose" stands for "switch" (and "when" stands for
>> "case"). But that just proves how confusing this word is... :)
>
> Oh you're right. Long time passed after I wrote XSL files last. :-D
>
>>
>>> 'choose' sounds like related to one of the 'multiple' choices
>>> to me.
>>
>> Well, I'm also unhappy with "choose", I just couldn't find better
>> yet... What do you think about "then". Apart from the lack of "else"
>> in it, it reads quite fluently: loggedIn?then(user.name, "unknown").
>
> Yeah, "then" sounds better to me than anything else.
>
>>
>>> Another option to consider might be 'iif' [1], which seems a bit clearer
>>> to me than 'either' and others.
>>>
>>>     someBoolean?iif(whenTrue, whenFalse)
>>>
>>> Just my two cents,
>>
>> I have played that idea back then, but I'm afraid very few knows what
>> does "iif" stands for. Also loggedIn?iif(user.name, "unknown") can be
>> easily misread like: we are logged in IF user.name is "unknown".
>
> Agreed. Not sound fluent.
>
> Kind regards,
>
> Woonsan
>
>>
>>> Woonsan
>>>
>>> [1] http://en.wikipedia.org/wiki/IIf
>>>
>>> On 5/30/15 6:02 AM, Daniel Dekany wrote:
>>>> And regarding the semantics of ?switch... as it sands now, if there's
>>>> no matching choice, that will be an exception that says:
>>>>
>>>>   The value before ?switch(case1, value1, case2, value2, ...) didn't
>>>>   match any of the case parameters, and there was no default value
>>>>   parameter (an additional last parameter) either.
>>>>
>>>> So, if you have an odd number of parameters, then the last one is like
>>>> the default branch of switch in Java.
>>>>
>>>> I have also considered just returning null if there's no match, and
>>>> then one can write ?switch(...)!theDefault, but then if someone
>>>> doesn't give a default, the error messages will just say that
>>>> ?switch(...) has evaluated to null/missing, which many users won't
>>>> understand why's happening. Also it has the same problems as
>>>> ?then(this)!that had.
>>>>
>>>
>>>
>>
>
>


------------------------------------------------------------------------------
_______________________________________________
FreeMarker-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/freemarker-devel



--
Raymond Augé (@rotty3000)
Senior Software Architect Liferay, Inc. (@Liferay)
Board Member & EEG Co-Chair, OSGi Alliance (@OSGiAlliance)



--
Raymond Augé (@rotty3000)
Senior Software Architect Liferay, Inc. (@Liferay)
Board Member & EEG Co-Chair, OSGi Alliance (@OSGiAlliance)

------------------------------------------------------------------------------

_______________________________________________
FreeMarker-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/freemarker-devel
Reply | Threaded
Open this post in threaded view
|

Re: [vote] Opinions about conditional built-in names?

Woonsan Ko
In reply to this post by Daniel Dekany
+1 on "then".

Woonsan


On 6/2/15 3:01 AM, Daniel Dekany wrote:
> OK, so that's like a vote for "then". Anyone else has an opinion? Or
> even just a vote on the name you prefer?
>
> someBoolean?then(whenTrue, whenFalse)someBoolean?then(whenTrue, whenFalse)
> or
> someBoolean?choose(whenTrue, whenFalse)
> or
> something else?
>


--
[hidden email]     www.onehippo.com
Boston - 745 Atlantic Ave, 8th Floor, Boston MA 02111
Amsterdam - Oosteinde 11, 1017 WT Amsterdam
US +1 877 414 4776 (toll free)
Europe +31(0)20 522 4466

------------------------------------------------------------------------------
_______________________________________________
FreeMarker-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/freemarker-devel
Reply | Threaded
Open this post in threaded view
|

Re: [vote] Opinions about conditional built-in names?

Daniel Dekany
In reply to this post by Raymond Auge
Tuesday, June 2, 2015, 1:54:24 PM, Raymond Auge wrote:

> Having reviewed those and due to my preferring readability over
> anything else, I would still lean toward:
>
> someBoolean?then(whenTrue, whenFalse)
>
> But would actually prefer the more expressive:
>
> someBoolean?ifelse(whenTrue, whenFalse)

Then rather someBoolean?thenElse(whenTrue, whenFalse), isn't it?
Though that even longer...

What should I notice in that Wikipedia article?

--
Thanks,
 Daniel Dekany


> I'd learn to deal with the first of course.
>
> - Ray
>
> On Tue, Jun 2, 2015 at 7:47 AM, Raymond Auge <[hidden email]> wrote:
> I lean to "then".
>
> But before deciding maybe a quick look over these: http://en.wikipedia.org/wiki/%3F:
>
> - Ray
>
> On Tue, Jun 2, 2015 at 3:01 AM, Daniel Dekany <[hidden email]> wrote:
> OK, so that's like a vote for "then". Anyone else has an opinion? Or
> even just a vote on the name you prefer?
>
> someBoolean?then(whenTrue, whenFalse)someBoolean?then(whenTrue, whenFalse)
> or
> someBoolean?choose(whenTrue, whenFalse)
> or
> something else?
>
> --
> Thanks,
>  Daniel Dekany
>
>
> Monday, June 1, 2015, 9:41:49 PM, Woonsan Ko wrote:
>
>> On 6/1/15 3:26 PM, Daniel Dekany wrote:
>>> Sunday, May 31, 2015, 7:50:20 PM, Woonsan Ko wrote:
>>>
>>>> I personally prefer having the default value option inside the
>>>> parenthesis, without having to depend on the default value after '!'.
>>>> So, I like the idea the odd number of parameters for a default value.
>>>>
>>>> Regarding the original question about 'switch' and 'choose', I like the
>>>> 'switch' very much, but I'm not sure if 'choose' is a good name for
>>>> ternary operator. In XSL, 'choose' means just one choice of the
>>>> 'switch'.
>>>
>>> Actually, in XSLT "choose" stands for "switch" (and "when" stands for
>>> "case"). But that just proves how confusing this word is...  
>>
>> Oh you're right. Long time passed after I wrote XSL files last.  
>>
>>>
>>>> 'choose' sounds like related to one of the 'multiple' choices
>>>> to me.
>>>
>>> Well, I'm also unhappy with "choose", I just couldn't find better
>>> yet... What do you think about "then". Apart from the lack of "else"
>>> in it, it reads quite fluently: loggedIn?then(user.name, "unknown").
>>
>> Yeah, "then" sounds better to me than anything else.
>>
>>>
>>>> Another option to consider might be 'iif' [1], which seems a bit clearer
>>>> to me than 'either' and others.
>>>>
>>>>     someBoolean?iif(whenTrue, whenFalse)
>>>>
>>>> Just my two cents,
>>>
>>> I have played that idea back then, but I'm afraid very few knows what
>>> does "iif" stands for. Also loggedIn?iif(user.name, "unknown") can be
>>> easily misread like: we are logged in IF user.name is "unknown".
>>
>> Agreed. Not sound fluent.
>>
>> Kind regards,
>>
>> Woonsan
>>
>>>
>>>> Woonsan
>>>>
>>>> [1] http://en.wikipedia.org/wiki/IIf
>>>>
>>>> On 5/30/15 6:02 AM, Daniel Dekany wrote:
>>>>> And regarding the semantics of ?switch... as it sands now, if there's
>>>>> no matching choice, that will be an exception that says:
>>>>>
>>>>>   The value before ?switch(case1, value1, case2, value2, ...) didn't
>>>>>   match any of the case parameters, and there was no default value
>>>>>   parameter (an additional last parameter) either.
>>>>>
>>>>> So, if you have an odd number of parameters, then the last one is like
>>>>> the default branch of switch in Java.
>>>>>
>>>>> I have also considered just returning null if there's no match, and
>>>>> then one can write ?switch(...)!theDefault, but then if someone
>>>>> doesn't give a default, the error messages will just say that
>>>>> ?switch(...) has evaluated to null/missing, which many users won't
>>>>> understand why's happening. Also it has the same problems as
>>>>> ?then(this)!that had.
>>>>>
>>>>
>>>>
>>>
>>
>>
>
>
> ------------------------------------------------------------------------------
> _______________________________________________
> FreeMarker-devel mailing list
> [hidden email]
> https://lists.sourceforge.net/lists/listinfo/freemarker-devel
>
>
>
> --
> Raymond Augé (@rotty3000)
> Senior Software Architect Liferay, Inc. (@Liferay)
> Board Member & EEG Co-Chair, OSGi Alliance (@OSGiAlliance)
>
>
>


------------------------------------------------------------------------------
_______________________________________________
FreeMarker-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/freemarker-devel
Reply | Threaded
Open this post in threaded view
|

Re: [vote] Opinions about conditional built-in names?

Jaime Garza-2
thenElse is not in the style of other composite words for built-ins, like cap_first, right? The style dictates ?then_else

Personally I like boolean?if(true-expr, false-expr)

Very concise.

Jaime Garza

-----Original Message-----
From: Daniel Dekany [mailto:[hidden email]]
Sent: Tuesday, June 02, 2015 2:20 PM
To: FreeMarker-devel
Subject: Re: [Freemarker-devel] [vote] Opinions about conditional built-in names?

Tuesday, June 2, 2015, 1:54:24 PM, Raymond Auge wrote:

> Having reviewed those and due to my preferring readability over
> anything else, I would still lean toward:
>
> someBoolean?then(whenTrue, whenFalse)
>
> But would actually prefer the more expressive:
>
> someBoolean?ifelse(whenTrue, whenFalse)

Then rather someBoolean?thenElse(whenTrue, whenFalse), isn't it?
Though that even longer...

What should I notice in that Wikipedia article?

--
Thanks,
 Daniel Dekany


> I'd learn to deal with the first of course.
>
> - Ray
>
> On Tue, Jun 2, 2015 at 7:47 AM, Raymond Auge <[hidden email]> wrote:
> I lean to "then".
>
> But before deciding maybe a quick look over these: http://en.wikipedia.org/wiki/%3F:
>
> - Ray
>
> On Tue, Jun 2, 2015 at 3:01 AM, Daniel Dekany <[hidden email]> wrote:
> OK, so that's like a vote for "then". Anyone else has an opinion? Or
> even just a vote on the name you prefer?
>
> someBoolean?then(whenTrue, whenFalse)someBoolean?then(whenTrue, whenFalse)
> or
> someBoolean?choose(whenTrue, whenFalse)
> or
> something else?
>
> --
> Thanks,
>  Daniel Dekany
>
>
> Monday, June 1, 2015, 9:41:49 PM, Woonsan Ko wrote:
>
>> On 6/1/15 3:26 PM, Daniel Dekany wrote:
>>> Sunday, May 31, 2015, 7:50:20 PM, Woonsan Ko wrote:
>>>
>>>> I personally prefer having the default value option inside the
>>>> parenthesis, without having to depend on the default value after '!'.
>>>> So, I like the idea the odd number of parameters for a default value.
>>>>
>>>> Regarding the original question about 'switch' and 'choose', I like the
>>>> 'switch' very much, but I'm not sure if 'choose' is a good name for
>>>> ternary operator. In XSL, 'choose' means just one choice of the
>>>> 'switch'.
>>>
>>> Actually, in XSLT "choose" stands for "switch" (and "when" stands for
>>> "case"). But that just proves how confusing this word is...  
>>
>> Oh you're right. Long time passed after I wrote XSL files last.  
>>
>>>
>>>> 'choose' sounds like related to one of the 'multiple' choices
>>>> to me.
>>>
>>> Well, I'm also unhappy with "choose", I just couldn't find better
>>> yet... What do you think about "then". Apart from the lack of "else"
>>> in it, it reads quite fluently: loggedIn?then(user.name, "unknown").
>>
>> Yeah, "then" sounds better to me than anything else.
>>
>>>
>>>> Another option to consider might be 'iif' [1], which seems a bit clearer
>>>> to me than 'either' and others.
>>>>
>>>>     someBoolean?iif(whenTrue, whenFalse)
>>>>
>>>> Just my two cents,
>>>
>>> I have played that idea back then, but I'm afraid very few knows what
>>> does "iif" stands for. Also loggedIn?iif(user.name, "unknown") can be
>>> easily misread like: we are logged in IF user.name is "unknown".
>>
>> Agreed. Not sound fluent.
>>
>> Kind regards,
>>
>> Woonsan
>>
>>>
>>>> Woonsan
>>>>
>>>> [1] http://en.wikipedia.org/wiki/IIf
>>>>
>>>> On 5/30/15 6:02 AM, Daniel Dekany wrote:
>>>>> And regarding the semantics of ?switch... as it sands now, if there's
>>>>> no matching choice, that will be an exception that says:
>>>>>
>>>>>   The value before ?switch(case1, value1, case2, value2, ...) didn't
>>>>>   match any of the case parameters, and there was no default value
>>>>>   parameter (an additional last parameter) either.
>>>>>
>>>>> So, if you have an odd number of parameters, then the last one is like
>>>>> the default branch of switch in Java.
>>>>>
>>>>> I have also considered just returning null if there's no match, and
>>>>> then one can write ?switch(...)!theDefault, but then if someone
>>>>> doesn't give a default, the error messages will just say that
>>>>> ?switch(...) has evaluated to null/missing, which many users won't
>>>>> understand why's happening. Also it has the same problems as
>>>>> ?then(this)!that had.
>>>>>
>>>>
>>>>
>>>
>>
>>
>
>
> ------------------------------------------------------------------------------
> _______________________________________________
> FreeMarker-devel mailing list
> [hidden email]
> https://lists.sourceforge.net/lists/listinfo/freemarker-devel
>
>
>
> --
> Raymond Augé (@rotty3000)
> Senior Software Architect Liferay, Inc. (@Liferay)
> Board Member & EEG Co-Chair, OSGi Alliance (@OSGiAlliance)
>
>
>


------------------------------------------------------------------------------
_______________________________________________
FreeMarker-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/freemarker-devel

------------------------------------------------------------------------------
_______________________________________________
FreeMarker-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/freemarker-devel
Reply | Threaded
Open this post in threaded view
|

Re: [vote] Opinions about conditional built-in names?

Daniel Dekany
Wednesday, June 3, 2015, 12:00:09 AM, Jaime Garza wrote:

> thenElse is not in the style of other composite words for
> built-ins, like cap_first, right? The style dictates ?then_else

Yes, I meant then_else. (Or... in fact, in 2.3.23 you can use camel
case as well, but then you need to use camel case for everything
that's defined by Freemarker.)

> Personally I like boolean?if(true-expr, false-expr)

So my concern with ?if is this that loggedIn?if(user.name, "unknown")
can be easily misread like this, as you read it left-to-right: (We
are) logged in IF user.name is "unknown". At last the "logged in IF
user.name" part is especially easy to read into it, and is already the
opposite of what the expression means (IF logged in then user.name).

> Very concise.
>
> Jaime Garza
>
> -----Original Message-----
> From: Daniel Dekany [mailto:[hidden email]]
> Sent: Tuesday, June 02, 2015 2:20 PM
> To: FreeMarker-devel
> Subject: Re: [Freemarker-devel] [vote] Opinions about conditional built-in names?
>
> Tuesday, June 2, 2015, 1:54:24 PM, Raymond Auge wrote:
>
>> Having reviewed those and due to my preferring readability over
>> anything else, I would still lean toward:
>>
>> someBoolean?then(whenTrue, whenFalse)
>>
>> But would actually prefer the more expressive:
>>
>> someBoolean?ifelse(whenTrue, whenFalse)
>
> Then rather someBoolean?thenElse(whenTrue, whenFalse), isn't it?
> Though that even longer...
>
> What should I notice in that Wikipedia article?
>
> --
> Thanks,
>  Daniel Dekany
>
>
>> I'd learn to deal with the first of course.
>>
>> - Ray
>>
>> On Tue, Jun 2, 2015 at 7:47 AM, Raymond Auge <[hidden email]> wrote:
>> I lean to "then".
>>
>> But before deciding maybe a quick look over these: http://en.wikipedia.org/wiki/%3F:
>>
>> - Ray
>>
>> On Tue, Jun 2, 2015 at 3:01 AM, Daniel Dekany <[hidden email]> wrote:
>> OK, so that's like a vote for "then". Anyone else has an opinion? Or
>> even just a vote on the name you prefer?
>>
>> someBoolean?then(whenTrue, whenFalse)someBoolean?then(whenTrue, whenFalse)
>> or
>> someBoolean?choose(whenTrue, whenFalse)
>> or
>> something else?
>>
>> --
>> Thanks,
>>  Daniel Dekany
>>
>>
>> Monday, June 1, 2015, 9:41:49 PM, Woonsan Ko wrote:
>>
>>> On 6/1/15 3:26 PM, Daniel Dekany wrote:
>>>> Sunday, May 31, 2015, 7:50:20 PM, Woonsan Ko wrote:
>>>>
>>>>> I personally prefer having the default value option inside the
>>>>> parenthesis, without having to depend on the default value after '!'.
>>>>> So, I like the idea the odd number of parameters for a default value.
>>>>>
>>>>> Regarding the original question about 'switch' and 'choose', I like the
>>>>> 'switch' very much, but I'm not sure if 'choose' is a good name for
>>>>> ternary operator. In XSL, 'choose' means just one choice of the
>>>>> 'switch'.
>>>>
>>>> Actually, in XSLT "choose" stands for "switch" (and "when" stands for
>>>> "case"). But that just proves how confusing this word is...  
>>>
>>> Oh you're right. Long time passed after I wrote XSL files last.  
>>>
>>>>
>>>>> 'choose' sounds like related to one of the 'multiple' choices
>>>>> to me.
>>>>
>>>> Well, I'm also unhappy with "choose", I just couldn't find better
>>>> yet... What do you think about "then". Apart from the lack of "else"
>>>> in it, it reads quite fluently: loggedIn?then(user.name, "unknown").
>>>
>>> Yeah, "then" sounds better to me than anything else.
>>>
>>>>
>>>>> Another option to consider might be 'iif' [1], which seems a bit clearer
>>>>> to me than 'either' and others.
>>>>>
>>>>>     someBoolean?iif(whenTrue, whenFalse)
>>>>>
>>>>> Just my two cents,
>>>>
>>>> I have played that idea back then, but I'm afraid very few knows what
>>>> does "iif" stands for. Also loggedIn?iif(user.name, "unknown") can be
>>>> easily misread like: we are logged in IF user.name is "unknown".
>>>
>>> Agreed. Not sound fluent.
>>>
>>> Kind regards,
>>>
>>> Woonsan
>>>
>>>>
>>>>> Woonsan
>>>>>
>>>>> [1] http://en.wikipedia.org/wiki/IIf
>>>>>
>>>>> On 5/30/15 6:02 AM, Daniel Dekany wrote:
>>>>>> And regarding the semantics of ?switch... as it sands now, if there's
>>>>>> no matching choice, that will be an exception that says:
>>>>>>
>>>>>>   The value before ?switch(case1, value1, case2, value2, ...) didn't
>>>>>>   match any of the case parameters, and there was no default value
>>>>>>   parameter (an additional last parameter) either.
>>>>>>
>>>>>> So, if you have an odd number of parameters, then the last one is like
>>>>>> the default branch of switch in Java.
>>>>>>
>>>>>> I have also considered just returning null if there's no match, and
>>>>>> then one can write ?switch(...)!theDefault, but then if someone
>>>>>> doesn't give a default, the error messages will just say that
>>>>>> ?switch(...) has evaluated to null/missing, which many users won't
>>>>>> understand why's happening. Also it has the same problems as
>>>>>> ?then(this)!that had.
>>>>>>
>>>>>
>>>>>
>>>>
>>>
>>>
>>
>>
>> ------------------------------------------------------------------------------
>> _______________________________________________
>> FreeMarker-devel mailing list
>> [hidden email]
>> https://lists.sourceforge.net/lists/listinfo/freemarker-devel
>>
>>
>>
>> --
>> Raymond Augé (@rotty3000)
>> Senior Software Architect Liferay, Inc. (@Liferay)
>> Board Member & EEG Co-Chair, OSGi Alliance (@OSGiAlliance)
>>
>>
>>
>
>
> ------------------------------------------------------------------------------
> _______________________________________________
> FreeMarker-devel mailing list
> [hidden email]
> https://lists.sourceforge.net/lists/listinfo/freemarker-devel
>
> ------------------------------------------------------------------------------
> _______________________________________________
> FreeMarker-devel mailing list
> [hidden email]
> https://lists.sourceforge.net/lists/listinfo/freemarker-devel

--
Thanks,
 Daniel Dekany


------------------------------------------------------------------------------
_______________________________________________
FreeMarker-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/freemarker-devel
Reply | Threaded
Open this post in threaded view
|

Re: [vote] Opinions about conditional built-in names?

Daniel Dekany
For now I have renamed

  exp?choose(whenTrue, whenFalse)

to

  exp?then(whenTrue, whenFalse)

because this time that was the most popular option (last year it was
?choose for some reason). I still wonder if we should sacrifice some
terseness for being more understandable with:

  exp?then_else(whenTrue, whenFalse).

If you hate to type "_", take into account that in 2.3.23 you can
already write templates in camel case, which will be probably the
recommended convention sooner or later. Then you have:
exp?thenElse(whenTrue, whenFalse)

Opinions?

--
Thanks,
 Daniel Dekany


Wednesday, June 3, 2015, 12:58:56 AM, Daniel Dekany wrote:

> Wednesday, June 3, 2015, 12:00:09 AM, Jaime Garza wrote:
>
>> thenElse is not in the style of other composite words for
>> built-ins, like cap_first, right? The style dictates ?then_else
>
> Yes, I meant then_else. (Or... in fact, in 2.3.23 you can use camel
> case as well, but then you need to use camel case for everything
> that's defined by Freemarker.)
>
>> Personally I like boolean?if(true-expr, false-expr)
>
> So my concern with ?if is this that loggedIn?if(user.name, "unknown")
> can be easily misread like this, as you read it left-to-right: (We
> are) logged in IF user.name is "unknown". At last the "logged in IF
> user.name" part is especially easy to read into it, and is already the
> opposite of what the expression means (IF logged in then user.name).
>
>> Very concise.
>>
>> Jaime Garza
>>
>> -----Original Message-----
>> From: Daniel Dekany [mailto:[hidden email]]
>> Sent: Tuesday, June 02, 2015 2:20 PM
>> To: FreeMarker-devel
>> Subject: Re: [Freemarker-devel] [vote] Opinions about conditional built-in names?
>>
>> Tuesday, June 2, 2015, 1:54:24 PM, Raymond Auge wrote:
>>
>>> Having reviewed those and due to my preferring readability over
>>> anything else, I would still lean toward:
>>>
>>> someBoolean?then(whenTrue, whenFalse)
>>>
>>> But would actually prefer the more expressive:
>>>
>>> someBoolean?ifelse(whenTrue, whenFalse)
>>
>> Then rather someBoolean?thenElse(whenTrue, whenFalse), isn't it?
>> Though that even longer...
>>
>> What should I notice in that Wikipedia article?
>>
>> --
>> Thanks,
>>  Daniel Dekany
>>
>>
>>> I'd learn to deal with the first of course.
>>>
>>> - Ray
>>>
>>> On Tue, Jun 2, 2015 at 7:47 AM, Raymond Auge <[hidden email]> wrote:
>>> I lean to "then".
>>>
>>> But before deciding maybe a quick look over these: http://en.wikipedia.org/wiki/%3F:
>>>
>>> - Ray
>>>
>>> On Tue, Jun 2, 2015 at 3:01 AM, Daniel Dekany <[hidden email]> wrote:
>>> OK, so that's like a vote for "then". Anyone else has an opinion? Or
>>> even just a vote on the name you prefer?
>>>
>>> someBoolean?then(whenTrue, whenFalse)someBoolean?then(whenTrue, whenFalse)
>>> or
>>> someBoolean?choose(whenTrue, whenFalse)
>>> or
>>> something else?
>>>
>>> --
>>> Thanks,
>>>  Daniel Dekany
>>>
>>>
>>> Monday, June 1, 2015, 9:41:49 PM, Woonsan Ko wrote:
>>>
>>>> On 6/1/15 3:26 PM, Daniel Dekany wrote:
>>>>> Sunday, May 31, 2015, 7:50:20 PM, Woonsan Ko wrote:
>>>>>
>>>>>> I personally prefer having the default value option inside the
>>>>>> parenthesis, without having to depend on the default value after '!'.
>>>>>> So, I like the idea the odd number of parameters for a default value.
>>>>>>
>>>>>> Regarding the original question about 'switch' and 'choose', I like the
>>>>>> 'switch' very much, but I'm not sure if 'choose' is a good name for
>>>>>> ternary operator. In XSL, 'choose' means just one choice of the
>>>>>> 'switch'.
>>>>>
>>>>> Actually, in XSLT "choose" stands for "switch" (and "when" stands for
>>>>> "case"). But that just proves how confusing this word is...  
>>>>
>>>> Oh you're right. Long time passed after I wrote XSL files last.  
>>>>
>>>>>
>>>>>> 'choose' sounds like related to one of the 'multiple' choices
>>>>>> to me.
>>>>>
>>>>> Well, I'm also unhappy with "choose", I just couldn't find better
>>>>> yet... What do you think about "then". Apart from the lack of "else"
>>>>> in it, it reads quite fluently: loggedIn?then(user.name, "unknown").
>>>>
>>>> Yeah, "then" sounds better to me than anything else.
>>>>
>>>>>
>>>>>> Another option to consider might be 'iif' [1], which seems a bit clearer
>>>>>> to me than 'either' and others.
>>>>>>
>>>>>>     someBoolean?iif(whenTrue, whenFalse)
>>>>>>
>>>>>> Just my two cents,
>>>>>
>>>>> I have played that idea back then, but I'm afraid very few knows what
>>>>> does "iif" stands for. Also loggedIn?iif(user.name, "unknown") can be
>>>>> easily misread like: we are logged in IF user.name is "unknown".
>>>>
>>>> Agreed. Not sound fluent.
>>>>
>>>> Kind regards,
>>>>
>>>> Woonsan
>>>>
>>>>>
>>>>>> Woonsan
>>>>>>
>>>>>> [1] http://en.wikipedia.org/wiki/IIf
>>>>>>
>>>>>> On 5/30/15 6:02 AM, Daniel Dekany wrote:
>>>>>>> And regarding the semantics of ?switch... as it sands now, if there's
>>>>>>> no matching choice, that will be an exception that says:
>>>>>>>
>>>>>>>   The value before ?switch(case1, value1, case2, value2, ...) didn't
>>>>>>>   match any of the case parameters, and there was no default value
>>>>>>>   parameter (an additional last parameter) either.
>>>>>>>
>>>>>>> So, if you have an odd number of parameters, then the last one is like
>>>>>>> the default branch of switch in Java.
>>>>>>>
>>>>>>> I have also considered just returning null if there's no match, and
>>>>>>> then one can write ?switch(...)!theDefault, but then if someone
>>>>>>> doesn't give a default, the error messages will just say that
>>>>>>> ?switch(...) has evaluated to null/missing, which many users won't
>>>>>>> understand why's happening. Also it has the same problems as
>>>>>>> ?then(this)!that had.


------------------------------------------------------------------------------
_______________________________________________
FreeMarker-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/freemarker-devel
Reply | Threaded
Open this post in threaded view
|

Re: [vote] Opinions about conditional built-in names?

Raymond Auge
+1 for: ?thenElse / ?then_else



On Fri, Jun 5, 2015 at 2:31 AM, Daniel Dekany <[hidden email]> wrote:
For now I have renamed

  exp?choose(whenTrue, whenFalse)

to

  exp?then(whenTrue, whenFalse)

because this time that was the most popular option (last year it was
?choose for some reason). I still wonder if we should sacrifice some
terseness for being more understandable with:

  exp?then_else(whenTrue, whenFalse).

If you hate to type "_", take into account that in 2.3.23 you can
already write templates in camel case, which will be probably the
recommended convention sooner or later. Then you have:
exp?thenElse(whenTrue, whenFalse)

Opinions?

--
Thanks,
 Daniel Dekany


Wednesday, June 3, 2015, 12:58:56 AM, Daniel Dekany wrote:

> Wednesday, June 3, 2015, 12:00:09 AM, Jaime Garza wrote:
>
>> thenElse is not in the style of other composite words for
>> built-ins, like cap_first, right? The style dictates ?then_else
>
> Yes, I meant then_else. (Or... in fact, in 2.3.23 you can use camel
> case as well, but then you need to use camel case for everything
> that's defined by Freemarker.)
>
>> Personally I like boolean?if(true-expr, false-expr)
>
> So my concern with ?if is this that loggedIn?if(user.name, "unknown")
> can be easily misread like this, as you read it left-to-right: (We
> are) logged in IF user.name is "unknown". At last the "logged in IF
> user.name" part is especially easy to read into it, and is already the
> opposite of what the expression means (IF logged in then user.name).
>
>> Very concise.
>>
>> Jaime Garza
>>
>> -----Original Message-----
>> From: Daniel Dekany [mailto:[hidden email]]
>> Sent: Tuesday, June 02, 2015 2:20 PM
>> To: FreeMarker-devel
>> Subject: Re: [Freemarker-devel] [vote] Opinions about conditional built-in names?
>>
>> Tuesday, June 2, 2015, 1:54:24 PM, Raymond Auge wrote:
>>
>>> Having reviewed those and due to my preferring readability over
>>> anything else, I would still lean toward:
>>>
>>> someBoolean?then(whenTrue, whenFalse)
>>>
>>> But would actually prefer the more expressive:
>>>
>>> someBoolean?ifelse(whenTrue, whenFalse)
>>
>> Then rather someBoolean?thenElse(whenTrue, whenFalse), isn't it?
>> Though that even longer...
>>
>> What should I notice in that Wikipedia article?
>>
>> --
>> Thanks,
>>  Daniel Dekany
>>
>>
>>> I'd learn to deal with the first of course.
>>>
>>> - Ray
>>>
>>> On Tue, Jun 2, 2015 at 7:47 AM, Raymond Auge <[hidden email]> wrote:
>>> I lean to "then".
>>>
>>> But before deciding maybe a quick look over these: http://en.wikipedia.org/wiki/%3F:
>>>
>>> - Ray
>>>
>>> On Tue, Jun 2, 2015 at 3:01 AM, Daniel Dekany <[hidden email]> wrote:
>>> OK, so that's like a vote for "then". Anyone else has an opinion? Or
>>> even just a vote on the name you prefer?
>>>
>>> someBoolean?then(whenTrue, whenFalse)someBoolean?then(whenTrue, whenFalse)
>>> or
>>> someBoolean?choose(whenTrue, whenFalse)
>>> or
>>> something else?
>>>
>>> --
>>> Thanks,
>>>  Daniel Dekany
>>>
>>>
>>> Monday, June 1, 2015, 9:41:49 PM, Woonsan Ko wrote:
>>>
>>>> On 6/1/15 3:26 PM, Daniel Dekany wrote:
>>>>> Sunday, May 31, 2015, 7:50:20 PM, Woonsan Ko wrote:
>>>>>
>>>>>> I personally prefer having the default value option inside the
>>>>>> parenthesis, without having to depend on the default value after '!'.
>>>>>> So, I like the idea the odd number of parameters for a default value.
>>>>>>
>>>>>> Regarding the original question about 'switch' and 'choose', I like the
>>>>>> 'switch' very much, but I'm not sure if 'choose' is a good name for
>>>>>> ternary operator. In XSL, 'choose' means just one choice of the
>>>>>> 'switch'.
>>>>>
>>>>> Actually, in XSLT "choose" stands for "switch" (and "when" stands for
>>>>> "case"). But that just proves how confusing this word is...
>>>>
>>>> Oh you're right. Long time passed after I wrote XSL files last.
>>>>
>>>>>
>>>>>> 'choose' sounds like related to one of the 'multiple' choices
>>>>>> to me.
>>>>>
>>>>> Well, I'm also unhappy with "choose", I just couldn't find better
>>>>> yet... What do you think about "then". Apart from the lack of "else"
>>>>> in it, it reads quite fluently: loggedIn?then(user.name, "unknown").
>>>>
>>>> Yeah, "then" sounds better to me than anything else.
>>>>
>>>>>
>>>>>> Another option to consider might be 'iif' [1], which seems a bit clearer
>>>>>> to me than 'either' and others.
>>>>>>
>>>>>>     someBoolean?iif(whenTrue, whenFalse)
>>>>>>
>>>>>> Just my two cents,
>>>>>
>>>>> I have played that idea back then, but I'm afraid very few knows what
>>>>> does "iif" stands for. Also loggedIn?iif(user.name, "unknown") can be
>>>>> easily misread like: we are logged in IF user.name is "unknown".
>>>>
>>>> Agreed. Not sound fluent.
>>>>
>>>> Kind regards,
>>>>
>>>> Woonsan
>>>>
>>>>>
>>>>>> Woonsan
>>>>>>
>>>>>> [1] http://en.wikipedia.org/wiki/IIf
>>>>>>
>>>>>> On 5/30/15 6:02 AM, Daniel Dekany wrote:
>>>>>>> And regarding the semantics of ?switch... as it sands now, if there's
>>>>>>> no matching choice, that will be an exception that says:
>>>>>>>
>>>>>>>   The value before ?switch(case1, value1, case2, value2, ...) didn't
>>>>>>>   match any of the case parameters, and there was no default value
>>>>>>>   parameter (an additional last parameter) either.
>>>>>>>
>>>>>>> So, if you have an odd number of parameters, then the last one is like
>>>>>>> the default branch of switch in Java.
>>>>>>>
>>>>>>> I have also considered just returning null if there's no match, and
>>>>>>> then one can write ?switch(...)!theDefault, but then if someone
>>>>>>> doesn't give a default, the error messages will just say that
>>>>>>> ?switch(...) has evaluated to null/missing, which many users won't
>>>>>>> understand why's happening. Also it has the same problems as
>>>>>>> ?then(this)!that had.


------------------------------------------------------------------------------
_______________________________________________
FreeMarker-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/freemarker-devel



--
Raymond Augé (@rotty3000)
Senior Software Architect Liferay, Inc. (@Liferay)
Board Member & EEG Co-Chair, OSGi Alliance (@OSGiAlliance)

------------------------------------------------------------------------------

_______________________________________________
FreeMarker-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/freemarker-devel
Reply | Threaded
Open this post in threaded view
|

Re: [vote] Opinions about conditional built-in names?

Woonsan Ko
+1 for: ?thenElse / ?then_else

Just changed my mind. It seems clearer than "then".

Woonsan

On 6/5/15 9:49 AM, Raymond Auge wrote:

> +1 for: ?thenElse / ?then_else
>
>
>
> On Fri, Jun 5, 2015 at 2:31 AM, Daniel Dekany <[hidden email]
> <mailto:[hidden email]>> wrote:
>
>     For now I have renamed
>
>       exp?choose(whenTrue, whenFalse)
>
>     to
>
>       exp?then(whenTrue, whenFalse)
>
>     because this time that was the most popular option (last year it was
>     ?choose for some reason). I still wonder if we should sacrifice some
>     terseness for being more understandable with:
>
>       exp?then_else(whenTrue, whenFalse).
>
>     If you hate to type "_", take into account that in 2.3.23 you can
>     already write templates in camel case, which will be probably the
>     recommended convention sooner or later. Then you have:
>     exp?thenElse(whenTrue, whenFalse)
>
>     Opinions?
>
>     --
>     Thanks,
>      Daniel Dekany
>
>
>     Wednesday, June 3, 2015, 12:58:56 AM, Daniel Dekany wrote:
>
>     > Wednesday, June 3, 2015, 12:00:09 AM, Jaime Garza wrote:
>     >
>     >> thenElse is not in the style of other composite words for
>     >> built-ins, like cap_first, right? The style dictates ?then_else
>     >
>     > Yes, I meant then_else. (Or... in fact, in 2.3.23 you can use camel
>     > case as well, but then you need to use camel case for everything
>     > that's defined by Freemarker.)
>     >
>     >> Personally I like boolean?if(true-expr, false-expr)
>     >
>     > So my concern with ?if is this that loggedIn?if(user.name
>     <http://user.name>, "unknown")
>     > can be easily misread like this, as you read it left-to-right: (We
>     > are) logged in IF user.name <http://user.name> is "unknown". At
>     last the "logged in IF
>     > user.name <http://user.name>" part is especially easy to read into
>     it, and is already the
>     > opposite of what the expression means (IF logged in then user.name
>     <http://user.name>).
>     >
>     >> Very concise.
>     >>
>     >> Jaime Garza
>     >>
>     >> -----Original Message-----
>     >> From: Daniel Dekany [mailto:[hidden email]
>     <mailto:[hidden email]>]
>     >> Sent: Tuesday, June 02, 2015 2:20 PM
>     >> To: FreeMarker-devel
>     >> Subject: Re: [Freemarker-devel] [vote] Opinions about conditional
>     built-in names?
>     >>
>     >> Tuesday, June 2, 2015, 1:54:24 PM, Raymond Auge wrote:
>     >>
>     >>> Having reviewed those and due to my preferring readability over
>     >>> anything else, I would still lean toward:
>     >>>
>     >>> someBoolean?then(whenTrue, whenFalse)
>     >>>
>     >>> But would actually prefer the more expressive:
>     >>>
>     >>> someBoolean?ifelse(whenTrue, whenFalse)
>     >>
>     >> Then rather someBoolean?thenElse(whenTrue, whenFalse), isn't it?
>     >> Though that even longer...
>     >>
>     >> What should I notice in that Wikipedia article?
>     >>
>     >> --
>     >> Thanks,
>     >>  Daniel Dekany
>     >>
>     >>
>     >>> I'd learn to deal with the first of course.
>     >>>
>     >>> - Ray
>     >>>
>     >>> On Tue, Jun 2, 2015 at 7:47 AM, Raymond Auge
>     <[hidden email] <mailto:[hidden email]>> wrote:
>     >>> I lean to "then".
>     >>>
>     >>> But before deciding maybe a quick look over these:
>     http://en.wikipedia.org/wiki/%3F:
>     >>>
>     >>> - Ray
>     >>>
>     >>> On Tue, Jun 2, 2015 at 3:01 AM, Daniel Dekany
>     <[hidden email] <mailto:[hidden email]>> wrote:
>     >>> OK, so that's like a vote for "then". Anyone else has an opinion? Or
>     >>> even just a vote on the name you prefer?
>     >>>
>     >>> someBoolean?then(whenTrue, whenFalse)someBoolean?then(whenTrue,
>     whenFalse)
>     >>> or
>     >>> someBoolean?choose(whenTrue, whenFalse)
>     >>> or
>     >>> something else?
>     >>>
>     >>> --
>     >>> Thanks,
>     >>>  Daniel Dekany
>     >>>
>     >>>
>     >>> Monday, June 1, 2015, 9:41:49 PM, Woonsan Ko wrote:
>     >>>
>     >>>> On 6/1/15 3:26 PM, Daniel Dekany wrote:
>     >>>>> Sunday, May 31, 2015, 7:50:20 PM, Woonsan Ko wrote:
>     >>>>>
>     >>>>>> I personally prefer having the default value option inside the
>     >>>>>> parenthesis, without having to depend on the default value
>     after '!'.
>     >>>>>> So, I like the idea the odd number of parameters for a
>     default value.
>     >>>>>>
>     >>>>>> Regarding the original question about 'switch' and 'choose',
>     I like the
>     >>>>>> 'switch' very much, but I'm not sure if 'choose' is a good
>     name for
>     >>>>>> ternary operator. In XSL, 'choose' means just one choice of the
>     >>>>>> 'switch'.
>     >>>>>
>     >>>>> Actually, in XSLT "choose" stands for "switch" (and "when"
>     stands for
>     >>>>> "case"). But that just proves how confusing this word is...
>     >>>>
>     >>>> Oh you're right. Long time passed after I wrote XSL files last.
>     >>>>
>     >>>>>
>     >>>>>> 'choose' sounds like related to one of the 'multiple' choices
>     >>>>>> to me.
>     >>>>>
>     >>>>> Well, I'm also unhappy with "choose", I just couldn't find better
>     >>>>> yet... What do you think about "then". Apart from the lack of
>     "else"
>     >>>>> in it, it reads quite fluently: loggedIn?then(user.name
>     <http://user.name>, "unknown").
>     >>>>
>     >>>> Yeah, "then" sounds better to me than anything else.
>     >>>>
>     >>>>>
>     >>>>>> Another option to consider might be 'iif' [1], which seems a
>     bit clearer
>     >>>>>> to me than 'either' and others.
>     >>>>>>
>     >>>>>>     someBoolean?iif(whenTrue, whenFalse)
>     >>>>>>
>     >>>>>> Just my two cents,
>     >>>>>
>     >>>>> I have played that idea back then, but I'm afraid very few
>     knows what
>     >>>>> does "iif" stands for. Also loggedIn?iif(user.name
>     <http://user.name>, "unknown") can be
>     >>>>> easily misread like: we are logged in IF user.name
>     <http://user.name> is "unknown".
>     >>>>
>     >>>> Agreed. Not sound fluent.
>     >>>>
>     >>>> Kind regards,
>     >>>>
>     >>>> Woonsan
>     >>>>
>     >>>>>
>     >>>>>> Woonsan
>     >>>>>>
>     >>>>>> [1] http://en.wikipedia.org/wiki/IIf
>     >>>>>>
>     >>>>>> On 5/30/15 6:02 AM, Daniel Dekany wrote:
>     >>>>>>> And regarding the semantics of ?switch... as it sands now,
>     if there's
>     >>>>>>> no matching choice, that will be an exception that says:
>     >>>>>>>
>     >>>>>>>   The value before ?switch(case1, value1, case2, value2,
>     ...) didn't
>     >>>>>>>   match any of the case parameters, and there was no default
>     value
>     >>>>>>>   parameter (an additional last parameter) either.
>     >>>>>>>
>     >>>>>>> So, if you have an odd number of parameters, then the last
>     one is like
>     >>>>>>> the default branch of switch in Java.
>     >>>>>>>
>     >>>>>>> I have also considered just returning null if there's no
>     match, and
>     >>>>>>> then one can write ?switch(...)!theDefault, but then if someone
>     >>>>>>> doesn't give a default, the error messages will just say that
>     >>>>>>> ?switch(...) has evaluated to null/missing, which many users
>     won't
>     >>>>>>> understand why's happening. Also it has the same problems as
>     >>>>>>> ?then(this)!that had.
>
>
>     ------------------------------------------------------------------------------
>     _______________________________________________
>     FreeMarker-devel mailing list
>     [hidden email]
>     <mailto:[hidden email]>
>     https://lists.sourceforge.net/lists/listinfo/freemarker-devel
>
>
>
>
> --
> *Raymond Augé*
> <http://www.liferay.com/web/raymond.auge/profile> (@rotty3000)
> Senior Software Architect *Liferay, Inc.*
> <http://www.liferay.com> (@Liferay)
> Board Member & EEG Co-Chair, OSGi Alliance <http://osgi.org> (@OSGiAlliance)
>
>
> ------------------------------------------------------------------------------
>
>
>
> _______________________________________________
> FreeMarker-devel mailing list
> [hidden email]
> https://lists.sourceforge.net/lists/listinfo/freemarker-devel
>


--
[hidden email]     www.onehippo.com
Boston - 745 Atlantic Ave, 8th Floor, Boston MA 02111
Amsterdam - Oosteinde 11, 1017 WT Amsterdam
US +1 877 414 4776 (toll free)
Europe +31(0)20 522 4466

------------------------------------------------------------------------------
_______________________________________________
FreeMarker-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/freemarker-devel
Reply | Threaded
Open this post in threaded view
|

Re: [vote] Opinions about conditional built-in names?

bredelet
In reply to this post by Daniel Dekany
‎Hi Daniel,

----
For now I have renamed

exp?choose(whenTrue, whenFalse)

to

exp?then(whenTrue, whenFalse)

because this time that was the most popular option (last year it was
?choose for some reason). I still wonder if we should sacrifice some
terseness for being more understandable with:

exp?then_else(whenTrue, whenFalse).

If you hate to type "_", take into account that in 2.3.23 you can
already write templates in camel case, which will be probably the
recommended convention sooner or later. Then you have:
exp?thenElse(whenTrue, whenFalse)

Opinions?
----

I think you should keep it at "then".

To take your example again:

loggedin?thenElse(username, "unknown")

It is confusing to read.

Also, can the default value be optional ? This builtin could double as another way to write:

loggedin!username

This is clearer:

loggedin?then(username)
--
Thanks,
Daniel Dekany


Wednesday, June 3, 2015, 12:58:56 AM, Daniel Dekany wrote:

> Wednesday, June 3, 2015, 12:00:09 AM, Jaime Garza wrote:
>
>> thenElse is not in the style of other composite words for
>> built-ins, like cap_first, right? The style dictates ?then_else
>
> Yes, I meant then_else. (Or... in fact, in 2.3.23 you can use camel
> case as well, but then you need to use camel case for everything
> that's defined by Freemarker.)
>
>> Personally I like boolean?if(true-expr, false-expr)
>
> So my concern with ?if is this that loggedIn?if(user.name, "unknown")
> can be easily misread like this, as you read it left-to-right: (We
> are) logged in IF user.name is "unknown". At last the "logged in IF
> user.name" part is especially easy to read into it, and is already the
> opposite of what the expression means (IF logged in then user.name).
>
>> Very concise.
>>
>> Jaime Garza
>>
>> -----Original Message-----
>> From: Daniel Dekany [mailto:[hidden email]]
>> Sent: Tuesday, June 02, 2015 2:20 PM
>> To: FreeMarker-devel
>> Subject: Re: [Freemarker-devel] [vote] Opinions about conditional built-in names?
>>
>> Tuesday, June 2, 2015, 1:54:24 PM, Raymond Auge wrote:
>>
>>> Having reviewed those and due to my preferring readability over
>>> anything else, I would still lean toward:
>>>
>>> someBoolean?then(whenTrue, whenFalse)
>>>
>>> But would actually prefer the more expressive:
>>>
>>> someBoolean?ifelse(whenTrue, whenFalse)
>>
>> Then rather someBoolean?thenElse(whenTrue, whenFalse), isn't it?
>> Though that even longer...
>>
>> What should I notice in that Wikipedia article?
>>
>> --
>> Thanks,
>> Daniel Dekany
>>
>>
>>> I'd learn to deal with the first of course.
>>>
>>> - Ray
>>>
>>> On Tue, Jun 2, 2015 at 7:47 AM, Raymond Auge <[hidden email]> wrote:
>>> I lean to "then".
>>>
>>> But before deciding maybe a quick look over these: http://en.wikipedia.org/wiki/%3F:
>>>
>>> - Ray
>>>
>>> On Tue, Jun 2, 2015 at 3:01 AM, Daniel Dekany <[hidden email]> wrote:
>>> OK, so that's like a vote for "then". Anyone else has an opinion? Or
>>> even just a vote on the name you prefer?
>>>
>>> someBoolean?then(whenTrue, whenFalse)someBoolean?then(whenTrue, whenFalse)
>>> or
>>> someBoolean?choose(whenTrue, whenFalse)
>>> or
>>> something else?
>>>
>>> --
>>> Thanks,
>>> Daniel Dekany
>>>
>>>
>>> Monday, June 1, 2015, 9:41:49 PM, Woonsan Ko wrote:
>>>
>>>> On 6/1/15 3:26 PM, Daniel Dekany wrote:
>>>>> Sunday, May 31, 2015, 7:50:20 PM, Woonsan Ko wrote:
>>>>>
>>>>>> I personally prefer having the default value option inside the
>>>>>> parenthesis, without having to depend on the default value after '!'.
>>>>>> So, I like the idea the odd number of parameters for a default value.
>>>>>>
>>>>>> Regarding the original question about 'switch' and 'choose', I like the
>>>>>> 'switch' very much, but I'm not sure if 'choose' is a good name for
>>>>>> ternary operator. In XSL, 'choose' means just one choice of the
>>>>>> 'switch'.
>>>>>
>>>>> Actually, in XSLT "choose" stands for "switch" (and "when" stands for
>>>>> "case"). But that just proves how confusing this word is...
>>>>
>>>> Oh you're right. Long time passed after I wrote XSL files last.
>>>>
>>>>>
>>>>>> 'choose' sounds like related to one of the 'multiple' choices
>>>>>> to me.
>>>>>
>>>>> Well, I'm also unhappy with "choose", I just couldn't find better
>>>>> yet... What do you think about "then". Apart from the lack of "else"
>>>>> in it, it reads quite fluently: loggedIn?then(user.name, "unknown").
>>>>
>>>> Yeah, "then" sounds better to me than anything else.
>>>>
>>>>>
>>>>>> Another option to consider might be 'iif' [1], which seems a bit clearer
>>>>>> to me than 'either' and others.
>>>>>>
>>>>>> someBoolean?iif(whenTrue, whenFalse)
>>>>>>
>>>>>> Just my two cents,
>>>>>
>>>>> I have played that idea back then, but I'm afraid very few knows what
>>>>> does "iif" stands for. Also loggedIn?iif(user.name, "unknown") can be
>>>>> easily misread like: we are logged in IF user.name is "unknown".
>>>>
>>>> Agreed. Not sound fluent.
>>>>
>>>> Kind regards,
>>>>
>>>> Woonsan
>>>>
>>>>>
>>>>>> Woonsan
>>>>>>
>>>>>> [1] http://en.wikipedia.org/wiki/IIf
>>>>>>
>>>>>> On 5/30/15 6:02 AM, Daniel Dekany wrote:
>>>>>>> And regarding the semantics of ?switch... as it sands now, if there's
>>>>>>> no matching choice, that will be an exception that says:
>>>>>>>
>>>>>>> The value before ?switch(case1, value1, case2, value2, ...) didn't
>>>>>>> match any of the case parameters, and there was no default value
>>>>>>> parameter (an additional last parameter) either.
>>>>>>>
>>>>>>> So, if you have an odd number of parameters, then the last one is like
>>>>>>> the default branch of switch in Java.
>>>>>>>
>>>>>>> I have also considered just returning null if there's no match, and
>>>>>>> then one can write ?switch(...)!theDefault, but then if someone
>>>>>>> doesn't give a default, the error messages will just say that
>>>>>>> ?switch(...) has evaluated to null/missing, which many users won't
>>>>>>> understand why's happening. Also it has the same problems as
>>>>>>> ?then(this)!that had.


------------------------------------------------------------------------------
_______________________________________________
FreeMarker-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/freemarker-devel

------------------------------------------------------------------------------
_______________________________________________
FreeMarker-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/freemarker-devel
Reply | Threaded
Open this post in threaded view
|

Re: [vote] Opinions about conditional built-in names?

Daniel Dekany
Friday, June 5, 2015, 7:39:43 PM, [hidden email] wrote:

> ‎Hi Daniel,
>
> ----
> For now I have renamed
>
> exp?choose(whenTrue, whenFalse)
>
> to
>
> exp?then(whenTrue, whenFalse)
>
> because this time that was the most popular option (last year it was
> ?choose for some reason). I still wonder if we should sacrifice some
> terseness for being more understandable with:
>
> exp?then_else(whenTrue, whenFalse).
>
> If you hate to type "_", take into account that in 2.3.23 you can
> already write templates in camel case, which will be probably the
> recommended convention sooner or later. Then you have:
> exp?thenElse(whenTrue, whenFalse)
>
> Opinions?
> ----
>
> I think you should keep it at "then".
>
> To take your example again:
>
> loggedin?thenElse(username, "unknown")
>
> It is confusing to read.

To me: ?thenElse is less "fluent", OTOH I guess if someone stops and
thinks a bit, he has better chance to realize what it means than with
?then. OTOH ?then is shorter, and if you have already used to it, more
pleasant to read.

> Also, can the default value be optional ? This builtin could double as another way to write:
>
> loggedin!username
> ‎
> This is clearer:
>
> loggedin?then(username)

`loggedin!username` just associates a default value to `loggedin` if
`loggedin` is missing. It doesn't care if `loggedin` is `true` or
`false`, as those are both non-missing values. `?then` on the other
hand deals with existing boolean values. So they don't overlap.

--
Thanks,
 Daniel Dekany


------------------------------------------------------------------------------
_______________________________________________
FreeMarker-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/freemarker-devel
Reply | Threaded
Open this post in threaded view
|

Re: [vote] Opinions about conditional built-in names?

Denis Bredelet
Hi,

I think you should keep it at "then". 

To take your example again:

loggedin?thenElse(username, "unknown")

It is confusing to read. 

To me: ?thenElse is less "fluent", OTOH I guess if someone stops and
thinks a bit, he has better chance to realize what it means than with
?then. OTOH ?then is shorter, and if you have already used to it, more
pleasant to read.

Yes ?then() has my vote.

Also, can the default value be optional ? This builtin could double as another way to write:

loggedin!username

This is clearer:

loggedin?then(username)

`loggedin!username` just associates a default value to `loggedin` if
`loggedin` is missing. It doesn't care if `loggedin` is `true` or
`false`, as those are both non-missing values. `?then` on the other
hand deals with existing boolean values. So they don't overlap.

Oops, you’re right. Brain slip. It would be more like:

username!anonymousUser

I think it is clear what it does.

— Denis.

------------------------------------------------------------------------------

_______________________________________________
FreeMarker-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/freemarker-devel