C++ still doesn't have good loop syntax
Kapendev
alexandroskapretsos at gmail.com
Wed Jul 15 19:52:14 UTC 2026
On Wednesday, 15 July 2026 at 19:36:47 UTC, user1234 wrote:
> On Wednesday, 15 July 2026 at 19:23:50 UTC, Kapendev wrote:
>> On Wednesday, 15 July 2026 at 19:06:50 UTC, user1234 wrote:
>>> On Wednesday, 15 July 2026 at 17:02:10 UTC, Adam D. Ruppe
>>> wrote:
>>>> [...]
>>>
>>> IMO that's a workaround. Imagine that array literals are
>>> static arrays by default, then no problem. Eventually you can
>>> turn them into dynamic arrays using implicit convertion /
>>> type inference. However truth is that D cannot change such a
>>> thing given its age.
>>
>> The other solution I can think of that Nim is doing something
>> like this:
>> ```d
>> auto static_array = $[1, 2, 3]; // int[3]
>> ```
>>
>> You can replace the `$` with any character, not important.
>
> Yes sure, in the great tradition of D we could also imagine a
> DotExp property, i.e
>
> ```d
> auto static_array = [1, 2, 3].staticarrayof;
> ```
>
> 🙃
This one is OK too, just paying for a template there.
The good thing about it is that it's not a language change.
Now, the choice between what `[item1, item2]` should be by
default is not important in my opinion, but I get it being weird
or annoying for some.
More information about the Digitalmars-d
mailing list