Discussion Thread: DIP 1039--Static Arrays with Inferred Length--Community Review Round 1
jmh530
john.michael.hall at gmail.com
Mon Jan 11 22:28:04 UTC 2021
On Monday, 11 January 2021 at 21:33:36 UTC, Paul Backus wrote:
> On Monday, 11 January 2021 at 21:17:20 UTC, jmh530 wrote:
>> Of course, the typical response would be, "well why not use
>> alias s = static array". I would ask what about an @nogc
>> unittest where the author is trying to limit calls to
>> functions that aren't really central to what is being tested.
>
> I've used std.array.staticArray for @nogc unit tests. It works
> fine, and the fact that it has a descriptive name makes it a
> lot more readable than something like `[1, 2, 3]s`.
I know it can be used. My main point was "where the author is
trying to limit calls to functions that aren't really central to
what is being tested".
Consider
@nogc unittest
{
assert([1, 2]s.nogcFunction == value);
}
vs
@nogc unittest
{
import std.array: staticArray;
assert([1, 2].staticArray.nogcFunction == value);
}
Not really different enough for me to care all that much, but the
first one avoids the import and is a bit simpler.
I didn't really feel that strongly about the DIP. My comment was
more that if that literal syntax were adopted, I would use it.
There's a lot of literals that I rarely make use of and have to
look up what it is. If I see 1.05L, I'm like "how could that be a
long?" Until I look it up and find out it's a real literal.
However, I imagine that people out there do make use of these
things (maybe not for reals so much, given the hate a lot of
people give them, but other ones).
More information about the Digitalmars-d-announce
mailing list