auto arr = [1, 2, 3] should be a static array, not a GC allocated array
Araq
rumpf_a at web.de
Sat Jul 16 15:41:04 UTC 2022
On Saturday, 16 July 2022 at 15:12:19 UTC, Ogi wrote:
> On Thursday, 14 July 2022 at 13:30:58 UTC, jfondren wrote:
>> On Thursday, 14 July 2022 at 13:14:59 UTC, ryuukk_ wrote:
>>> It is misleading, nobody expect this to be GC allocated
>>
>> People expect that who try to append to it later on in the
>> function.
>
> And this also should be killed with fire. We need a clean
> distinction between static arrays, GC-controlled dynamic
> arrays, and slices.
Correct but that's just one out of many examples where C++ is
simply better designed. C++'s references work better than D's
`inout`, C++'s const system works better as it allows for
reference counted containers ("logical constness"), D's postblits
had to be replaced with copy constructors (like C++ does it),
`shared` doesn't mean anything (C++ lacks it), D's class
construct introduces a value vs pointer semantics schism that C++
consciously avoided, D's class construct comes with a monitor
(C++ does not have this overhead), C++ does not misuse the `enum`
keyword, C++ lacks an effect system like @nogc @safe @etc that
simply gets in the way, C++ doesn't need "interface", it allows
for multiple inheritance instead so that's an entire entity that
it lacks as it doesn't need it.
Now you can disagree with this list all you want and point out
details which I got wrong but the point here is: Don't be
surprised that D never really replaced C++, it's not the lack of
marketing and it's not the lack of manpower either, the language
is not designed all that well and it didn't learn much from C++.
More information about the Digitalmars-d
mailing list