Conversation

zhuliquan

allow the last argument append with comma in func expr.
make below expr can be parsed ok.

func1(
     argument1,
     argument2,
     argument3,
)

@antonmedv

Althoug this is nice feature, I think for not is not needed in Expr. as most of the time expressions is one line.

We may return later to this and change our decision.

@zhuliquan

Althoug this is nice feature, I think for not is not needed in Expr. as most of the time expressions is one line.

We may return later to this and change our decision.

Although most of the time the expression is a single line, I still think this feature makes sense. This is considered from the perspective of syntactic consistency of expr. Because I discovered that expr parser supports ignoring the last comma on type of array or type of map, which is much like Python unlike JSON. For example, the following statements can be parsed via expr parser

[
   1,
   2,
]
{
  "1": 1,
  "2": 2,
}

So from this point of view, many users may naturally think that the last comma will be ignored by the parser. However, if the user finds that the function call is not allowed to add a comma at the end. This can be confusing.

@antonmedv

Hmm. This is true. We do allow comma in arrays & maps. Let me think on it bit more.

@antonmedvantonmedv reopened this Mar 8, 2025
@zhuliquanzhuliquan force-pushed the feature-last_arg_comma branch from 685ad2c to 2eed2d8 Compare March 9, 2025 02:43
@antonmedv

Well, let's add support for this!

@antonmedvantonmedv changed the title Feature last arg comma Allow tailing comma in arguments Mar 9, 2025
@antonmedvantonmedv merged commit 8f83203 into expr-lang:master Mar 9, 2025
16 checks passed
@zhuliquanzhuliquan deleted the feature-last_arg_comma branch March 9, 2025 09:53
SimFG pushed a commit to SimFG/expr that referenced this pull request Apr 15, 2025
* feat: extract code for compiling equal operator

* feat: support last argument append with comma

---------

Co-authored-by: Anton Medvedev <[email protected]>
Sign up for free to join this conversation on . Already have an account? Sign in to comment
None yet

Successfully merging this pull request may close these issues.