D has become unbearable and it needs to stop
Chris Katko
ckatko at gmail.com
Fri Jun 16 19:11:10 UTC 2023
On Friday, 16 June 2023 at 02:05:21 UTC, Walter Bright wrote:
> On 6/14/2023 7:44 PM, Chris Katko wrote:
>> Tell any other object about yourself in the constructor?
>> segfault. Because your object isn't constructed till _after_
>> the constructor runs. There's a gotcha.
>
> All objects are default constructed before the constructor is
> called.
>
> I'll need an example?
I misremembered a bit when summarizing, from this thread last
year:
https://forum.dlang.org/post/uvjvtzidbqartwkbbaww@forum.dlang.org
Code works fine when you directly send a reference during
construction. But if you access it from an absolute path like
module.classinstance.variable it crashes.
That is not something that is obvious, at least to me. If, during
construction, I can send a reference to [this] to a called
function just fine, but not refer to the same object through its
absolute path until after construction, that's counter-intuitive
/ a gotcha, for me.
Note: on re-reading my old post I see typos that were corrected
in my later posts in the thread. To be clear, I'm not referring
to module.CLASSTYPE.variable anywhere. It's
module.classInstance.variable.
More information about the Digitalmars-d
mailing list