Proposal: implicitly typed array creation expression with size #683
Unanswered
Tan90909090
asked this question in
General
Replies: 3 comments
-
Is this a problem? I think this is a feature, not a bug. |
Beta Was this translation helpful? Give feedback.
0 replies
-
Why? |
Beta Was this translation helpful? Give feedback.
0 replies
-
Why not javascript like simplicity with type and size inference?
|
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Background
We have several ways to create array.
Firstly, we can specify array size:
Compiler detects a mismatch between specified size and array-initializer's length and reports an error:
Secondly, we can omit element type. Compiler infers element type:
Problem
Currently, we can not combine both features:
Proposal
Let's allow implicitly typed array creation expression with size.
Syntax may change like this:
array_creation_expression : 'new' non_array_type '[' expression_list ']' rank_specifier* array_initializer? | 'new' array_type array_initializer | 'new' rank_specifier array_initializer + | 'new' '[' expression_list ']' array_initializer ;
Beta Was this translation helpful? Give feedback.
All reactions