Community
Participate
Working Groups
Is it relevant to enable multiple name declaration with a single "var" or "val" statement? For example: var String a, b The grammar rule could be update to: XVariableDeclaration returns XExpression: {XVariableDeclaration} (writeable?='var'|'val') names+=XVariableDeclarationUnit (',' names+=XVariableDeclarationUnit)* ; XVariableDeclarationUnit: (=>(name=ValidID ':' type=JvmTypeReference) | name=ValidID) ('=' right=XExpression)? ;
*** Bug 404140 has been marked as a duplicate of this bug. ***
same for members in xtend classes
I did something similar for Jbase, so I can work on that, but in September. The proposed change, though, would break existing languages. I implemented that using additional declarations, reusing the same type.
I could work on that in the near future, but I'd like to know which form should we implement: val {type} {i} = {e}, {type} {i} = {e}, ... or val {type} {i} = {2}, {i} = {e}, ... I mean, should the declared type optionally appear only in the first declaration, or also in the other declarations? If no type is declared, should the following declarations respect the inferred type of the first declaration? Other ideas?
My opinion is if the type is specified, it should be applied to the following declarations. For example: var int a = 45, b = 47 means that a and b are both int. var a = 45, b = 45.0 means that the types of a and b are inferred from the expressions. I'm not convince about the specification of the type in the comma list, e.g.: var int a = 45, double b = 47 I think it include less readable code.