As OGNL implements, SpEL should also support the comma operator, which is great for multi-paragraph expressions and for defining variables inside expressions and referencing them.

        String mathEl = "a=3,b=3,(a+1)*(b-1)";
        Object value2 = Ognl.getValue(mathEl, new HashMap<String, Object>());
        System.out.println(value2);

        SpelExpressionParser parser = new SpelExpressionParser();
        Object value1 = parser.parseExpression(mathEl).getValue();
        System.out.println(value1);

It works fine in OGNL, but not in SpEL.

Comment From: sbrannen

I'm not an expert on OGNL, but I assume you're referring to the "sequence operator".

The comma (,) or sequence operator. This operator is borrowed from C. The comma is used to separate two independent expressions. The value of the second of these expressions is the value of the comma expression.

So what is the expected value? (3+1)*(3-1) --> 8?

Comment From: timnick-snow

I'm not an expert on OGNL, but I assume you're referring to the "sequence operator".

The comma (,) or sequence operator. This operator is borrowed from C. The comma is used to separate two independent expressions. The value of the second of these expressions is the value of the comma expression.

So what is the expected value? (3+1)*(3-1) --> 8?

yes. expect to get 8. The value of the last expression should be the return value

Comment From: sbrannen

@aclement, have you ever considered supporting multiple expressions in a given input string in SpEL?

What do you think about this proposal?

Comment From: spring-projects-issues

If you would like us to look at this issue, please provide the requested information. If the information is not provided within the next 7 days this issue will be closed.

Comment From: spring-projects-issues

Closing due to lack of requested feedback. If you would like us to look at this issue, please provide the requested information and we will re-open the issue.

Comment From: sbrannen

Reopening, awaiting feedback from @aclement

Comment From: spring-projects-issues

If you would like us to look at this issue, please provide the requested information. If the information is not provided within the next 7 days this issue will be closed.

Comment From: spring-projects-issues

Closing due to lack of requested feedback. If you would like us to look at this issue, please provide the requested information and we will re-open the issue.

Comment From: aclement

We used to have this in early SpEL versions. Since SpEL was based on the expression language in Spring .NET - see 11.3.6. Expression lists over here https://www.springframework.net/doc-latest/reference/html/expressions.html . There were many other things you can find on that page that we had too - lambda expressions, built-in aggregators. In the end we simplified SpEL for Spring Java, deliberately. Now that is a number of years ago, and I'm not against adding some of these capabilities back in. We just have to take care we don't go too far and turn it into a fully fledged programming language, I don't think that is what it is for.

Comment From: sbrannen

Thanks for the feedback, @aclement. That was the insight I was looking for.

We used to have this in early SpEL versions. Since SpEL was based on the expression language in Spring .NET - see 11.3.6. Expression lists over here https://www.springframework.net/doc-latest/reference/html/expressions.html .

Found it: https://www.springframework.net/doc-latest/reference/html/expressions.html#expressions-explist

We just have to take care we don't go too far and turn it into a fully fledged programming language, I don't think that is what it is for.

Yes, I agree with you on that, and we will take that into consideration when assessing this proposal and similar ones.

Comment From: snicoll

There hasn't been further interest from the community and it looks like we're heading more towards simplifying SpEL than anything else. I am going to close this but we can reconsider if there are more votes from the community.