[jira] [Commented] (JEXL-316) Operator ?? has very low priority

2019-10-09 Thread Dmitri Blinov (Jira)


[ 
https://issues.apache.org/jira/browse/JEXL-316?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16947558#comment-16947558
 ] 

Dmitri Blinov commented on JEXL-316:


As an example of '?:' and '??' having different results *now* we could consider 
the following tests:
{code:java}
{} ?? 3
{code}
and
{code:java}
{} ?: 3
{code}

> Operator ?? has very low priority
> -
>
> Key: JEXL-316
> URL: https://issues.apache.org/jira/browse/JEXL-316
> Project: Commons JEXL
>  Issue Type: Bug
>Affects Versions: 3.1
>Reporter: Dmitri Blinov
>Assignee: Henri Biestro
>Priority: Major
> Fix For: 3.2
>
>
> In current version of JEXL the script
> {code:java}
> 10??0 + 200 {code}
> evaluates to 10, which is counterintuitive. It requires to always use 
> parantheses after {{\\??}}. The operator {{??}} should have higer priority. 
> It is the same problem as with current version of freemarker, but they 
> promise to fix it in the next major release.
> The suggestion is to set priority of operator {{??}} to be between 
> {{UnaryExpression()}} and {{ValueExpression()}}
> {code}
> void ConditionalExpression() #void : {}
> {
>   ConditionalOrExpression()
>   (
>  Expression()  Expression() #TernaryNode(3)
>   |
>  Expression() #TernaryNode(2)
>   )?
> }
> ...
> void UnaryExpression() #void : {}
> {
>  UnaryExpression() #UnaryMinusNode(1)
>   |
>  UnaryExpression() #UnaryPlusNode(1)
>   |
>  UnaryExpression() #BitwiseComplNode(1)
>   |
> (|) UnaryExpression() #NotNode(1)
>   |
>  UnaryExpression() #EmptyFunction(1)
>   |
>  UnaryExpression() #SizeFunction(1)
>   |
> NullpExpression()
> }
> void NullpExpression() #void : {}
> {
> ValueExpression()
> (
> ValueExpression() #NullpNode(2)
> )*
> }
> {code}



--
This message was sent by Atlassian Jira
(v8.3.4#803005)


[jira] [Commented] (JEXL-316) Operator ?? has very low priority

2019-10-03 Thread Dmitri Blinov (Jira)


[ 
https://issues.apache.org/jira/browse/JEXL-316?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16943401#comment-16943401
 ] 

Dmitri Blinov commented on JEXL-316:


I have checked how in other languages the position of the null-coalescing 
operator is defined, and results are very mixed. The languages like C#, 
Javascript (being proposed) place null coalescing operand closer to ternary, 
like it is currently implemented in JEXL. Some languages like PHP and 
freemarker are closer to what is being proposed. There are some like Swift that 
are in between - above the arithmetic, but below comparisons. Some languages do 
not have null coalescing operator at all, but use *elvis* operator for this 
purpose, which they BTW, see as shortened form of ternary operator. For me, for 
example, this is also comes as no surprise  - I get used to elvis being a 
ternary sibling, not a null coaliscing one. In some sence, IMO, the 
introduction of null coalescing operator in JEXL is more justified when it 
differs from what we have already had.

So, the community has no single approach to the problem, and no industry-wide 
convention. Lets leave it as it is for now.

> Operator ?? has very low priority
> -
>
> Key: JEXL-316
> URL: https://issues.apache.org/jira/browse/JEXL-316
> Project: Commons JEXL
>  Issue Type: Bug
>Affects Versions: 3.1
>Reporter: Dmitri Blinov
>Assignee: Henri Biestro
>Priority: Major
> Fix For: 3.2
>
>
> In current version of JEXL the script
> {code:java}
> 10??0 + 200 {code}
> evaluates to 10, which is counterintuitive. It requires to always use 
> parantheses after {{\\??}}. The operator {{??}} should have higer priority. 
> It is the same problem as with current version of freemarker, but they 
> promise to fix it in the next major release.
> The suggestion is to set priority of operator {{??}} to be between 
> {{UnaryExpression()}} and {{ValueExpression()}}
> {code}
> void ConditionalExpression() #void : {}
> {
>   ConditionalOrExpression()
>   (
>  Expression()  Expression() #TernaryNode(3)
>   |
>  Expression() #TernaryNode(2)
>   )?
> }
> ...
> void UnaryExpression() #void : {}
> {
>  UnaryExpression() #UnaryMinusNode(1)
>   |
>  UnaryExpression() #UnaryPlusNode(1)
>   |
>  UnaryExpression() #BitwiseComplNode(1)
>   |
> (|) UnaryExpression() #NotNode(1)
>   |
>  UnaryExpression() #EmptyFunction(1)
>   |
>  UnaryExpression() #SizeFunction(1)
>   |
> NullpExpression()
> }
> void NullpExpression() #void : {}
> {
> ValueExpression()
> (
> ValueExpression() #NullpNode(2)
> )*
> }
> {code}



--
This message was sent by Atlassian Jira
(v8.3.4#803005)


[jira] [Commented] (JEXL-316) Operator ?? has very low priority

2019-10-02 Thread Henri Biestro (Jira)


[ 
https://issues.apache.org/jira/browse/JEXL-316?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16942930#comment-16942930
 ] 

Henri Biestro commented on JEXL-316:


Discussed this with other parties (devs, consultants) that disliked the idea 
that '?:' and '??' would lead to potentially very different usages and results. 
The current semantic of 'if-false' and 'if-null' and their difference is 
understood; the surprise that would come from having so drastically different 
syntactic applicable rules a scripting language is not liked. Not sure the 
change can survive the 'no surprise' rule 
Considering he (external) consensus is the syntactic rules for both, I only hop 
and hope you can fuill 2  


> Operator ?? has very low priority
> -
>
> Key: JEXL-316
> URL: https://issues.apache.org/jira/browse/JEXL-316
> Project: Commons JEXL
>  Issue Type: Bug
>Affects Versions: 3.1
>Reporter: Dmitri Blinov
>Assignee: Henri Biestro
>Priority: Major
> Fix For: 3.2
>
>
> In current version of JEXL the script
> {code:java}
> 10??0 + 200 {code}
> evaluates to 10, which is counterintuitive. It requires to always use 
> parantheses after {{\\??}}. The operator {{??}} should have higer priority. 
> It is the same problem as with current version of freemarker, but they 
> promise to fix it in the next major release.
> The suggestion is to set priority of operator {{??}} to be between 
> {{UnaryExpression()}} and {{ValueExpression()}}
> {code}
> void ConditionalExpression() #void : {}
> {
>   ConditionalOrExpression()
>   (
>  Expression()  Expression() #TernaryNode(3)
>   |
>  Expression() #TernaryNode(2)
>   )?
> }
> ...
> void UnaryExpression() #void : {}
> {
>  UnaryExpression() #UnaryMinusNode(1)
>   |
>  UnaryExpression() #UnaryPlusNode(1)
>   |
>  UnaryExpression() #BitwiseComplNode(1)
>   |
> (|) UnaryExpression() #NotNode(1)
>   |
>  UnaryExpression() #EmptyFunction(1)
>   |
>  UnaryExpression() #SizeFunction(1)
>   |
> NullpExpression()
> }
> void NullpExpression() #void : {}
> {
> ValueExpression()
> (
> ValueExpression() #NullpNode(2)
> )*
> }
> {code}



--
This message was sent by Atlassian Jira
(v8.3.4#803005)


[jira] [Commented] (JEXL-316) Operator ?? has very low priority

2019-10-01 Thread Dmitri Blinov (Jira)


[ 
https://issues.apache.org/jira/browse/JEXL-316?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16941603#comment-16941603
 ] 

Dmitri Blinov commented on JEXL-316:


The difference is subtle yet significant. The ability of elvis operator to 
handle logical expressions places it to the higher league. One can expect to 
use elvis operator to calculate complicated conditions, may be even with side 
effects, like {{transferAmount = checkAccountBalance(x) && lockAmount(y) ?: 
0}}, where its ability to evaluate left part only once really kicks in. On the 
other hand, the null coalescing operator is only needed to protect from *null* 
values from undefined variables and properties to leak into calculation, like 
{{a + b??2}}. In most cases this is expected to be {{a + (b??2)}} and not 
{{(a+b)??2}}, since its natural, though not totally impossible, for any 
arithmetic calculation or logical conditions not to produce null results. 

Personally I think elvis operator is strange and its usage is questionable, I 
have never found the reason to use it except may be only once or twice. And 
personally I don't care much. But for compatibility reasons I would let it be 
as it is.


> Operator ?? has very low priority
> -
>
> Key: JEXL-316
> URL: https://issues.apache.org/jira/browse/JEXL-316
> Project: Commons JEXL
>  Issue Type: Bug
>Affects Versions: 3.1
>Reporter: Dmitri Blinov
>Assignee: Henri Biestro
>Priority: Major
> Fix For: 3.2
>
>
> In current version of JEXL the script
> {code:java}
> 10??0 + 200 {code}
> evaluates to 10, which is counterintuitive. It requires to always use 
> parantheses after {{\\??}}. The operator {{??}} should have higer priority. 
> It is the same problem as with current version of freemarker, but they 
> promise to fix it in the next major release.
> The suggestion is to set priority of operator {{??}} to be between 
> {{UnaryExpression()}} and {{ValueExpression()}}
> {code}
> void ConditionalExpression() #void : {}
> {
>   ConditionalOrExpression()
>   (
>  Expression()  Expression() #TernaryNode(3)
>   |
>  Expression() #TernaryNode(2)
>   )?
> }
> ...
> void UnaryExpression() #void : {}
> {
>  UnaryExpression() #UnaryMinusNode(1)
>   |
>  UnaryExpression() #UnaryPlusNode(1)
>   |
>  UnaryExpression() #BitwiseComplNode(1)
>   |
> (|) UnaryExpression() #NotNode(1)
>   |
>  UnaryExpression() #EmptyFunction(1)
>   |
>  UnaryExpression() #SizeFunction(1)
>   |
> NullpExpression()
> }
> void NullpExpression() #void : {}
> {
> ValueExpression()
> (
> ValueExpression() #NullpNode(2)
> )*
> }
> {code}



--
This message was sent by Atlassian Jira
(v8.3.4#803005)


[jira] [Commented] (JEXL-316) Operator ?? has very low priority

2019-09-30 Thread Henri Biestro (Jira)


[ 
https://issues.apache.org/jira/browse/JEXL-316?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16941034#comment-16941034
 ] 

Henri Biestro commented on JEXL-316:


{code}10?:0 + 200{code} should behave like: {code}10??0 + 200{code} Shouldn't 
it?

> Operator ?? has very low priority
> -
>
> Key: JEXL-316
> URL: https://issues.apache.org/jira/browse/JEXL-316
> Project: Commons JEXL
>  Issue Type: Bug
>Affects Versions: 3.1
>Reporter: Dmitri Blinov
>Assignee: Henri Biestro
>Priority: Major
> Fix For: 3.2
>
>
> In current version of JEXL the script
> {code:java}
> 10??0 + 200 {code}
> evaluates to 10, which is counterintuitive. It requires to always use 
> parantheses after {{\\??}}. The operator {{??}} should have higer priority. 
> It is the same problem as with current version of freemarker, but they 
> promise to fix it in the next major release.
> The suggestion is to set priority of operator {{??}} to be between 
> {{UnaryExpression()}} and {{ValueExpression()}}
> {code}
> void ConditionalExpression() #void : {}
> {
>   ConditionalOrExpression()
>   (
>  Expression()  Expression() #TernaryNode(3)
>   |
>  Expression() #TernaryNode(2)
>   )?
> }
> ...
> void UnaryExpression() #void : {}
> {
>  UnaryExpression() #UnaryMinusNode(1)
>   |
>  UnaryExpression() #UnaryPlusNode(1)
>   |
>  UnaryExpression() #BitwiseComplNode(1)
>   |
> (|) UnaryExpression() #NotNode(1)
>   |
>  UnaryExpression() #EmptyFunction(1)
>   |
>  UnaryExpression() #SizeFunction(1)
>   |
> NullpExpression()
> }
> void NullpExpression() #void : {}
> {
> ValueExpression()
> (
> ValueExpression() #NullpNode(2)
> )*
> }
> {code}



--
This message was sent by Atlassian Jira
(v8.3.4#803005)


[jira] [Commented] (JEXL-316) Operator ?? has very low priority

2019-09-30 Thread Dmitri Blinov (Jira)


[ 
https://issues.apache.org/jira/browse/JEXL-316?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16941000#comment-16941000
 ] 

Dmitri Blinov commented on JEXL-316:


The {{??}} operator was introduced IIRC, in version 3.2. Not sure about elvis 
operator. Intuitively nothing is wrong with it. 

> Operator ?? has very low priority
> -
>
> Key: JEXL-316
> URL: https://issues.apache.org/jira/browse/JEXL-316
> Project: Commons JEXL
>  Issue Type: Bug
>Affects Versions: 3.1
>Reporter: Dmitri Blinov
>Assignee: Henri Biestro
>Priority: Major
> Fix For: 3.2
>
>
> In current version of JEXL the script
> {code:java}
> 10??0 + 200 {code}
> evaluates to 10, which is counterintuitive. It requires to always use 
> parantheses after {{\\??}}. The operator {{??}} should have higer priority. 
> It is the same problem as with current version of freemarker, but they 
> promise to fix it in the next major release.
> The suggestion is to set priority of operator {{??}} to be between 
> {{UnaryExpression()}} and {{ValueExpression()}}
> {code}
> void ConditionalExpression() #void : {}
> {
>   ConditionalOrExpression()
>   (
>  Expression()  Expression() #TernaryNode(3)
>   |
>  Expression() #TernaryNode(2)
>   )?
> }
> ...
> void UnaryExpression() #void : {}
> {
>  UnaryExpression() #UnaryMinusNode(1)
>   |
>  UnaryExpression() #UnaryPlusNode(1)
>   |
>  UnaryExpression() #BitwiseComplNode(1)
>   |
> (|) UnaryExpression() #NotNode(1)
>   |
>  UnaryExpression() #EmptyFunction(1)
>   |
>  UnaryExpression() #SizeFunction(1)
>   |
> NullpExpression()
> }
> void NullpExpression() #void : {}
> {
> ValueExpression()
> (
> ValueExpression() #NullpNode(2)
> )*
> }
> {code}



--
This message was sent by Atlassian Jira
(v8.3.4#803005)


[jira] [Commented] (JEXL-316) Operator ?? has very low priority

2019-09-30 Thread Henri Biestro (Jira)


[ 
https://issues.apache.org/jira/browse/JEXL-316?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16940978#comment-16940978
 ] 

Henri Biestro commented on JEXL-316:


I agree, operator precedence is wrong in this case; shouldn't this apply to the 
Elvis operator as well ?

> Operator ?? has very low priority
> -
>
> Key: JEXL-316
> URL: https://issues.apache.org/jira/browse/JEXL-316
> Project: Commons JEXL
>  Issue Type: Bug
>Affects Versions: 3.1
>Reporter: Dmitri Blinov
>Assignee: Henri Biestro
>Priority: Major
> Fix For: 3.2
>
>
> In current version of JEXL the script
> {code:java}
> 10??0 + 200 {code}
> evaluates to 10, which is counterintuitive. It requires to always use 
> parantheses after {{\\??}}. The operator {{??}} should have higer priority. 
> It is the same problem as with current version of freemarker, but they 
> promise to fix it in the next major release.
> The suggestion is to set priority of operator {{??}} to be between 
> {{UnaryExpression()}} and {{ValueExpression()}}
> {code}
> void ConditionalExpression() #void : {}
> {
>   ConditionalOrExpression()
>   (
>  Expression()  Expression() #TernaryNode(3)
>   |
>  Expression() #TernaryNode(2)
>   )?
> }
> ...
> void UnaryExpression() #void : {}
> {
>  UnaryExpression() #UnaryMinusNode(1)
>   |
>  UnaryExpression() #UnaryPlusNode(1)
>   |
>  UnaryExpression() #BitwiseComplNode(1)
>   |
> (|) UnaryExpression() #NotNode(1)
>   |
>  UnaryExpression() #EmptyFunction(1)
>   |
>  UnaryExpression() #SizeFunction(1)
>   |
> NullpExpression()
> }
> void NullpExpression() #void : {}
> {
> ValueExpression()
> (
> ValueExpression() #NullpNode(2)
> )*
> }
> {code}



--
This message was sent by Atlassian Jira
(v8.3.4#803005)