Feedback Thread: DIP 1039--Static Arrays with Inferred Length--Community Review Round 1
Basile B.
b2.temp at gmx.com
Wed Jan 6 10:19:01 UTC 2021
On Wednesday, 6 January 2021 at 09:23:34 UTC, Mike Parker wrote:
> This is the feedback thread for the first round of Community
> Review of DIP 1039, "Static Arrays with Inferred Length".
I'd like to see a rationale for this restriction:
---
int[$] bar(int[2] arr) // Error: not allowed in
functions declarations
{
return [3, 4];
}
---
as `int[$]` would be like `auto` but with a "hint" on how to
convert the result.
It looks reasonable not to allow it, in a first time, however.
AFAIK dmd internal does not contain anything giving some hint on
the return type inferrence.
Also if I trust the comment "not allowed in functions
declarations" then
---
void bar(int[$] arr = [1,2]);
---
would be rejected as this use case is like a variable declaration
with initializer so the dollar substitution at compile-time is
possible.
1. Globally the examples are used to describe the semantics but
there is not enough of them. There should be a clear behavior
defined for each place where a type can be used. Why is this
allowed here, why not here.
2. For now the DIP does not explain what was the problem with the
first attempt and how the new design addresses the problem that
lead the work to be reverted.
To conclude, even if the change looks ok, the document lacks of
accuracy.
More information about the Digitalmars-d
mailing list