Passing a string by reference
IGotD-
nise at nise.com
Wed Nov 9 11:54:06 UTC 2022
On Tuesday, 8 November 2022 at 12:43:47 UTC, Adam D Ruppe wrote:
>
> In fact, ref in general in D is a lot more rare than in
> languages like C++. The main reason to use it for arrays is
> when you need changes to the length to be visible to the
> caller... which is fairly rare.
>
In general many parameters are passed as const, the called
function never changes the parameter. Which brings the question,
will the compiler optimize the parameter so that the string is
only passed as a pointer underneath when it knows it is a const?
More information about the Digitalmars-d-learn
mailing list