[jira] [Commented] (JEXL-226) add ?? operator support

2017-06-28 Thread Min Wei (JIRA)

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

Min Wei commented on JEXL-226:
--

This is great, Henri

> add ?? operator support 
> 
>
> Key: JEXL-226
> URL: https://issues.apache.org/jira/browse/JEXL-226
> Project: Commons JEXL
>  Issue Type: New Feature
>Affects Versions: Later
>Reporter: Min Wei
>Assignee: Henri Biestro
>  Labels: features
> Fix For: 3.2
>
>   Original Estimate: 1h
>  Remaining Estimate: 1h
>
> Jexl already supports null-coalescing semantics with the operator "?:". So it 
> should be a simple matter to extend it with a different syntax.
> https://docs.microsoft.com/en-us/dotnet/csharp/language-reference/operators/null-conditional-operator
> https://github.com/apache/commons-jexl/pull/4



--
This message was sent by Atlassian JIRA
(v6.4.14#64029)


[jira] [Commented] (JEXL-226) add ?? operator support

2017-06-28 Thread Dmitri Blinov (JIRA)

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

Dmitri Blinov commented on JEXL-226:


Sorry, false alarm, this is the artifact from old build :-(

> add ?? operator support 
> 
>
> Key: JEXL-226
> URL: https://issues.apache.org/jira/browse/JEXL-226
> Project: Commons JEXL
>  Issue Type: New Feature
>Affects Versions: Later
>Reporter: Min Wei
>Assignee: Henri Biestro
>  Labels: features
> Fix For: 3.2
>
>   Original Estimate: 1h
>  Remaining Estimate: 1h
>
> Jexl already supports null-coalescing semantics with the operator "?:". So it 
> should be a simple matter to extend it with a different syntax.
> https://docs.microsoft.com/en-us/dotnet/csharp/language-reference/operators/null-conditional-operator
> https://github.com/apache/commons-jexl/pull/4



--
This message was sent by Atlassian JIRA
(v6.4.14#64029)


[jira] [Commented] (JEXL-226) add ?? operator support

2017-06-28 Thread Dmitri Blinov (JIRA)

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

Dmitri Blinov commented on JEXL-226:


I'm unable to use this operator in scripts. The following construct

{code}
x??true
{code}

throws org.apache.commons.jexl3.JexlException$Parsing: evalScript@1:3 parsing 
error in '?'

> add ?? operator support 
> 
>
> Key: JEXL-226
> URL: https://issues.apache.org/jira/browse/JEXL-226
> Project: Commons JEXL
>  Issue Type: New Feature
>Affects Versions: Later
>Reporter: Min Wei
>Assignee: Henri Biestro
>  Labels: features
> Fix For: 3.2
>
>   Original Estimate: 1h
>  Remaining Estimate: 1h
>
> Jexl already supports null-coalescing semantics with the operator "?:". So it 
> should be a simple matter to extend it with a different syntax.
> https://docs.microsoft.com/en-us/dotnet/csharp/language-reference/operators/null-conditional-operator
> https://github.com/apache/commons-jexl/pull/4



--
This message was sent by Atlassian JIRA
(v6.4.14#64029)


[jira] [Commented] (JEXL-226) add ?? operator support

2017-06-27 Thread Henri Biestro (JIRA)

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

Henri Biestro commented on JEXL-226:


The Elvis operator casts the left-hand side to boolean; The 'null coalescing' 
operator does not.
{code}
// x is not defined
x ?? 'other value' ; // 'other value'
var x = null;
x?? 'other value'; // 'other value'
x = 1;
x?? 'other value'; // 1
x = 0.0;
x?? 'other value'; // 0.0
x = NaN;
x??'other value'; //NaN
x ="";
x??'other value'; // ""
{code}

> add ?? operator support 
> 
>
> Key: JEXL-226
> URL: https://issues.apache.org/jira/browse/JEXL-226
> Project: Commons JEXL
>  Issue Type: New Feature
>Affects Versions: Later
>Reporter: Min Wei
>  Labels: features
> Fix For: Later
>
>   Original Estimate: 1h
>  Remaining Estimate: 1h
>
> Jexl already supports null-coalescing semantics with the operator "?:". So it 
> should be a simple matter to extend it with a different syntax.
> https://docs.microsoft.com/en-us/dotnet/csharp/language-reference/operators/null-conditional-operator
> https://github.com/apache/commons-jexl/pull/4



--
This message was sent by Atlassian JIRA
(v6.4.14#64029)


[jira] [Commented] (JEXL-226) add ?? operator support

2017-06-27 Thread Sebb (JIRA)

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

Sebb commented on JEXL-226:
---

Just so we are completely clear, could we please document what is expected for 
a null variable?
And a true/non-zero variable?

> add ?? operator support 
> 
>
> Key: JEXL-226
> URL: https://issues.apache.org/jira/browse/JEXL-226
> Project: Commons JEXL
>  Issue Type: New Feature
>Affects Versions: Later
>Reporter: Min Wei
>  Labels: features
> Fix For: Later
>
>   Original Estimate: 1h
>  Remaining Estimate: 1h
>
> Jexl already supports null-coalescing semantics with the operator "?:". So it 
> should be a simple matter to extend it with a different syntax.
> https://docs.microsoft.com/en-us/dotnet/csharp/language-reference/operators/null-conditional-operator
> https://github.com/apache/commons-jexl/pull/4



--
This message was sent by Atlassian JIRA
(v6.4.14#64029)


[jira] [Commented] (JEXL-226) add ?? operator support

2017-06-27 Thread Henri Biestro (JIRA)

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

Henri Biestro commented on JEXL-226:


Aliases we have (eq, etc...) are witnesses of a long past; I wish there was an 
easy way to deprecate them...

Back to null coalescing, after carefully reviewing the various semantics 
associated with '?:' and '??', it might be worth adding an actual strict 'null 
coalescing' operator. It would only return the right hand side if the left hand 
side is null (or undefined for a variable). The difference would be as such:
{code}
var a = false;
a ?? 'other value'  ; // returns false
a ?: 'other value' ; // returns 'other value'
var b = 0;
b ?? 'other value'  ; // returns 0
b ?: 'other value' ; // returns 'other value'
{code}

> add ?? operator support 
> 
>
> Key: JEXL-226
> URL: https://issues.apache.org/jira/browse/JEXL-226
> Project: Commons JEXL
>  Issue Type: New Feature
>Affects Versions: Later
>Reporter: Min Wei
>  Labels: features
> Fix For: Later
>
>   Original Estimate: 1h
>  Remaining Estimate: 1h
>
> Jexl already supports null-coalescing semantics with the operator "?:". So it 
> should be a simple matter to extend it with a different syntax.
> https://docs.microsoft.com/en-us/dotnet/csharp/language-reference/operators/null-conditional-operator
> https://github.com/apache/commons-jexl/pull/4



--
This message was sent by Atlassian JIRA
(v6.4.14#64029)


[jira] [Commented] (JEXL-226) add ?? operator support

2017-06-27 Thread Dmitri Blinov (JIRA)

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

Dmitri Blinov commented on JEXL-226:


Just to mention that we have aliases for relational operators like {{eq}} for 
{{==}} etc. And I personally would find it more convenient and easy to read to 
use {{in}} instead of {{=~}} :-)

> add ?? operator support 
> 
>
> Key: JEXL-226
> URL: https://issues.apache.org/jira/browse/JEXL-226
> Project: Commons JEXL
>  Issue Type: New Feature
>Affects Versions: Later
>Reporter: Min Wei
>  Labels: features
> Fix For: Later
>
>   Original Estimate: 1h
>  Remaining Estimate: 1h
>
> Jexl already supports null-coalescing semantics with the operator "?:". So it 
> should be a simple matter to extend it with a different syntax.
> https://docs.microsoft.com/en-us/dotnet/csharp/language-reference/operators/null-conditional-operator
> https://github.com/apache/commons-jexl/pull/4



--
This message was sent by Atlassian JIRA
(v6.4.14#64029)


[jira] [Commented] (JEXL-226) add ?? operator support

2017-06-26 Thread Min Wei (JIRA)

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

Min Wei commented on JEXL-226:
--

I know the Java heritage, though ?? is becoming a more pattern (e.g. Swift 
supports it too). 

Note that I am still experimenting with JEXL. And kind of curious about the 
main use cases by other people. I know it's originally planned to support SCXML 

Given JEXL is already departing away from Java (e.g. its lambda etc.), it might 
make sense to make it more "LISP like" expression language that supports 
defining new operators. 

Anyway, just a suggestion. Please feel free to close out this jira.  

> add ?? operator support 
> 
>
> Key: JEXL-226
> URL: https://issues.apache.org/jira/browse/JEXL-226
> Project: Commons JEXL
>  Issue Type: New Feature
>Affects Versions: Later
>Reporter: Min Wei
>  Labels: features
> Fix For: Later
>
>   Original Estimate: 1h
>  Remaining Estimate: 1h
>
> Jexl already supports null-coalescing semantics with the operator "?:". So it 
> should be a simple matter to extend it with a different syntax.
> https://docs.microsoft.com/en-us/dotnet/csharp/language-reference/operators/null-conditional-operator
> https://github.com/apache/commons-jexl/pull/4



--
This message was sent by Atlassian JIRA
(v6.4.14#64029)


[jira] [Commented] (JEXL-226) add ?? operator support

2017-06-26 Thread Henri Biestro (JIRA)

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

Henri Biestro commented on JEXL-226:


JEXL stands for Java Expression Language though :-) 
Not a fan of adding a C# syntax for an operator that already exists; I'd 
suggest regexp/replace ?? with ?: if this is a must in your case.

For operators, at least the actual operations behind the syntax, most of the 
behaviors (if not all) can be customized through a user-defined JexlArithmetic 
and overriding/overloading the corresponding methods. (see 
http://commons.apache.org/proper/commons-jexl/apidocs/org/apache/commons/jexl3/JexlOperator.html
 )

> add ?? operator support 
> 
>
> Key: JEXL-226
> URL: https://issues.apache.org/jira/browse/JEXL-226
> Project: Commons JEXL
>  Issue Type: New Feature
>Affects Versions: Later
>Reporter: Min Wei
>  Labels: features
> Fix For: Later
>
>   Original Estimate: 1h
>  Remaining Estimate: 1h
>
> Jexl already supports null-coalescing semantics with the operator "?:". So it 
> should be a simple matter to extend it with a different syntax.
> https://docs.microsoft.com/en-us/dotnet/csharp/language-reference/operators/null-conditional-operator
> https://github.com/apache/commons-jexl/pull/4



--
This message was sent by Atlassian JIRA
(v6.4.14#64029)


[jira] [Commented] (JEXL-226) add ?? operator support

2017-06-26 Thread Min Wei (JIRA)

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

Min Wei commented on JEXL-226:
--

I have some internal use cases to prefer the C# like syntax. 

On thinking of it, it might be a good idea to be able to redefine the operators 
in general for a scripting language like JEXL. Because it's a DSL after all. 

> add ?? operator support 
> 
>
> Key: JEXL-226
> URL: https://issues.apache.org/jira/browse/JEXL-226
> Project: Commons JEXL
>  Issue Type: New Feature
>Affects Versions: Later
>Reporter: Min Wei
>  Labels: features
> Fix For: Later
>
>   Original Estimate: 1h
>  Remaining Estimate: 1h
>
> Jexl already supports null-coalescing semantics with the operator "?:". So it 
> should be a simple matter to extend it with a different syntax.
> https://docs.microsoft.com/en-us/dotnet/csharp/language-reference/operators/null-conditional-operator
> https://github.com/apache/commons-jexl/pull/4



--
This message was sent by Atlassian JIRA
(v6.4.14#64029)


[jira] [Commented] (JEXL-226) add ?? operator support

2017-06-26 Thread Henri Biestro (JIRA)

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

Henri Biestro commented on JEXL-226:


I'm very much against having 2 syntaxes for the same operator.
What is the benefit of not using the 'elvis' operator ?

> add ?? operator support 
> 
>
> Key: JEXL-226
> URL: https://issues.apache.org/jira/browse/JEXL-226
> Project: Commons JEXL
>  Issue Type: New Feature
>Affects Versions: Later
>Reporter: Min Wei
>  Labels: features
> Fix For: Later
>
>   Original Estimate: 1h
>  Remaining Estimate: 1h
>
> Jexl already supports null-coalescing semantics with the operator "?:". So it 
> should be a simple matter to extend it with a different syntax.
> https://docs.microsoft.com/en-us/dotnet/csharp/language-reference/operators/null-conditional-operator
> https://github.com/apache/commons-jexl/pull/4



--
This message was sent by Atlassian JIRA
(v6.4.14#64029)