Separate slices and dynamic arrays

monkyyy crazymonkyyy at gmail.com
Sat Aug 3 00:38:04 UTC 2024


On Friday, 2 August 2024 at 21:43:33 UTC, Quirin Schroll wrote:
>
> I think your confusion is somewhat warranted

Im not confused. I just value what the compiler does over the 
spec and over peoples words: Its trivial to write example code 
for either world view that works flawlessly, with a footgun where 
they overlap; therefore d has both world views.

This should be low priority, but above the safe discussions that 
is currently gripping the zeitgeist.

> Walter once proposed deprecating slice append and slice length 
> assignment, and he faced almost unanimous backash.

as he should; unlike this suggestion that would be removing 
features completely

I wouldnt deprecate slice append until a separate built in data 
structure picks up the functionality

> D's slices are what in C++ is a vector or string, a span or 
> string_view, or a valarray, or even something like an output 
> iteratior. My first instinct was: This is either nuts or 
> sublime genius, and it's most definitely the latter.

c++ is overengineered and verbose, d sometimes isnt; it is 95% 
correct as is, idk the compiler details but Id copy and paste the 
code and make minor edits if it was my datastructure with such a 
problem

>  In D, that's a non-issue. If you pass a slice to a function 
> and that function decides to store it, fine. The GC keeps the 
> memory around as needed.

~~I dont actaully think its unsafe or care about safety; everyone 
else's world view does however~~


More information about the dip.ideas mailing list