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
On Tuesday, 8 November 2022 at 13:05:09 UTC, Ali Çehreli wrote:
Yes. Classes are reference types in D. Class variables are
implemented as pointers. Their default value is null.
Ali
Thanks!
On 11/8/22 04:53, Alexander Zhirov wrote:
> On Tuesday, 8 November 2022 at 12:43:47 UTC, Adam D Ruppe wrote:
>> Just use plain `string`.
>
> So it's always working with thick pointers?
Yes, D's arrays are fat pointers. strings are arrays of immutable(char).
>> nope, an object isn't created
Thanks for answers!
On Tuesday, 8 November 2022 at 12:43:47 UTC, Adam D Ruppe wrote:
You should almost never use `ref string`. Just use plain
`string`.
So it's always working with thick pointers?
nope, an object isn't created there at all. you should use `new
C`.
If I create just `A c`,
On Tuesday, 8 November 2022 at 12:30:50 UTC, Alexander Zhirov
wrote:
Do I understand correctly that in order for me to pass a string
when creating an object, I must pass it by value?
You should almost never use `ref string`. Just use plain `string`.
In fact, ref in general in D is a lot more
On Tuesday, 8 November 2022 at 12:30:50 UTC, Alexander Zhirov
wrote:
Do I understand correctly that in order for me to pass a string
when creating an object, I must pass it by value? And if I have
a variable containing a string, can I pass it by reference?
Should I always do constructor
On Tuesday, 8 November 2022 at 12:30:50 UTC, Alexander Zhirov
wrote:
A c;
this declaration not creates class instance. you should use "new".
btw, struct have other behavoiur
Do I understand correctly that in order for me to pass a string
when creating an object, I must pass it by value? And if I have a
variable containing a string, can I pass it by reference?
Should I always do constructor overloading for a type and a
reference to it?
In the case of the variable