Returning variable-sized stack data

IchorDev zxinsworld at gmail.com
Sat Aug 17 12:55:15 UTC 2024


On Tuesday, 13 August 2024 at 10:53:40 UTC, ryuukk_ wrote:
> On Tuesday, 13 August 2024 at 09:55:28 UTC, Quirin Schroll 
> wrote:
> I don't use a personal language based on D, i use D with a 
> custom runtime, big difference, because of that i can target 
> both consoles and WebAssembly, you can't with your C#/Java'd D

Why can’t any given video games console use DRuntime?

>>>> […]
>
> It would have never been an issue if D made the right call of 
> not expecting `[1,2,3]` to be GC allocated without requiring 
> `new`, fix that mistake, don't put another mistake on top of it

I agree that `new` on a stack allocation is utterly confusing. 
One of the first things you’re taught about D and how to avoid 
heap allocations is that `new` *always* heap allocates. Obviously 
it was just done that way so that it can just fall back to a heap 
allocation if you turn off DIP1000, but it’s not nice when you 
ONLY ever want a stack allocation. I hope that element of 
DIP1000’s syntax will be replaced by something more amicable.
Prepending allocating array literals with `new` is interesting. 
Sometimes it’s even optimised to be on the stack anyway. And what 
about `x ~ y`? There are some scenarios where hiding a heap 
allocation just makes things look nicer. That said, using array 
literals to set static arrays in `@nogc` code is easy to get 
wrong, resulting in a confusing error. And in BetterC the 
necessary array copy function sometimes fails to manifest, so you 
get a linker error.

> […]
>
> C# is a JIT/GC language
>
> D was not, it slowly became one

Uh… D didn’t become a JIT language though.

I think I’m going to keep an eye on what happens at the DIP1000 
meeting and see where to go with this from there. Maybe they’ll 
have come up with something much better than this or `scope`, or 
not.


More information about the dip.ideas mailing list