On Sunday, 8 August 2021 at 04:30:12 UTC, rikki cattermole wrote:
So a field that will automatically be resolved to as part of the behavior of generated toString methods.

No. A default property can be another object altogether. The best use case I can think of is a default collection for a class such as lobjComputers.computers in my example.

That really isn't what alias this is used for commonly. I.e.

I didn't know alias this even existed a month ago so I cannot comment for what's oftenly used; I just stated that I was pointed to alias this when I asked for default properties, it worked, but later on when reading manuals/posts/etc it was obvious alias this was something wholly different -that's why I got rid of all alias this on my code, not the least when I learned of Walter's stance on this one.

struct ValueReference {
        private {
                SomethingElse* impl;
        }

        bool isNull() { return impl is null; }

        scope ref ValueType _get() { return impl.thingy; }

        alias _get this;
}

Only the problem is, this also works for classes and whole pile of extra cases.


Reply via email to