[New Feature] Allow spread operator in list-constructor-expr
#35351
Replies: 3 comments 7 replies
-
Update on syntax-related changes. Current syntax: New syntax: Current syntax tree structure.
Currently, for the expressions we allow comma separated expression list. Notice the type is So the proposed new structure.
Notice spread operator syntax will be |
Beta Was this translation helpful? Give feedback.
-
Update on the semantics. CC: @hasithaa @MaryamZi @gimantha @pcnfernando The static type of the expression in a spread-member must allow only list values, i.e. subtype of Implemented an inner class named Inner Class (click to expand) /**
* Implementation of list constructor spread operator.
*
* @since 2201.1.0
*/
public static class BLangListConstructorSpreadOpExpr extends BLangExpression {
private BLangExpression expr;
public BLangExpression getExpression() {
return expr;
}
public void setExpression(ExpressionNode expr) {
this.expr = (BLangExpression) expr;
}
@Override
public NodeKind getKind() {
return NodeKind.LIST_CONSTRUCTOR_SPREAD_OP;
}
@Override
public void accept(BLangNodeVisitor visitor) {
visitor.visit(this);
}
@Override
public <T> void accept(BLangNodeAnalyzer<T> analyzer, T props) {
analyzer.visit(this, props);
}
@Override
public <T, R> R apply(BLangNodeTransformer<T, R> modifier, T props) {
return modifier.transform(this, props);
}
} |
Beta Was this translation helpful? Give feedback.
-
@lochana-chathura Why do we need a class for spread members? can't we just have an expression field in |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
This is to discuss and give updates on implementing the spread operator support in
list-constructor-expr
.Spec Issue: ballerina-platform/ballerina-spec#52
Lang issue: #35178
Upstream branch: spread-operator
Samples:
Beta Was this translation helpful? Give feedback.
All reactions