Re: How add class or struct member after construction?

2020-11-08 Thread Jacob Carlborg via Digitalmars-d-learn
On 2020-11-05 23:48, Marcone wrote: How add class or struct member after construction? Is it possible in D? How? It depends on what needs you have. You can declare a free function that takes the class/struct as the first parameter and call it like a method [1]: class Foo { int

Re: How add class or struct member after construction?

2020-11-05 Thread Simen Kjærås via Digitalmars-d-learn
On Thursday, 5 November 2020 at 22:48:38 UTC, Marcone wrote: How add class or struct member after construction? Is it possible in D? How? This depends a lot on what you mean. The short answer is no - you cannot. However, given some limitations, it is possible. What sort of members do you

Re: How add class or struct member after construction?

2020-11-05 Thread H. S. Teoh via Digitalmars-d-learn
On Thu, Nov 05, 2020 at 10:48:38PM +, Marcone via Digitalmars-d-learn wrote: > How add class or struct member after construction? Is it possible in > D? How? You can't, because D is statically-typed. However, you *can* implement something equivalent manually by other means, depending o

How add class or struct member after construction?

2020-11-05 Thread Marcone via Digitalmars-d-learn
How add class or struct member after construction? Is it possible in D? How?