Obsecure problem 1

FeepingCreature feepingcreature at gmail.com
Sun Jul 31 14:52:03 UTC 2022


On Sunday, 31 July 2022 at 07:43:06 UTC, Salih Dincer wrote:
> Why are you using const for strings? After all, they are 
> protected by immutable. Moreover, since you do not use refs, 
> copies are taken in every function and also you have created 
> extra copy for results.
>

Note sure if I'm misunderstanding, but: D does not copy strings 
on value passing, because they're inherently reference types.

You can think of a string (or any array) as a `struct { size_t 
length; T* ptr; }` combined with a bunch of syntax magic.


More information about the Digitalmars-d-learn mailing list