Re: Proper way to handle "alias this" deprecation for classes

2023-05-07 Thread Ali Çehreli via Digitalmars-d-learn
On 5/7/23 13:44, Chris Piker wrote: > to fix the problem I > just delete the alias this line from dpq2, see what unit tests and app > code it breaks, then fix each of those. Yes but I neglected the lvalue/rvalue issue. In some cases the code won't compile if the return type of the newly

Re: Proper way to handle "alias this" deprecation for classes

2023-05-07 Thread Chris Piker via Digitalmars-d-learn
On Sunday, 7 May 2023 at 21:04:05 UTC, Inkrementator wrote: On Sunday, 7 May 2023 at 18:19:04 UTC, Ali Çehreli wrote: alias this is for implicit type conversions, which can be achieved explicitly as well. Open question to everybody: What you're opinion on using opCast for this? Since it's a

core.simd ubyte16 initialization weirdness.

2023-05-07 Thread realhet via Digitalmars-d-learn
Hello, ``` import std, core.simd; void main() { enum ubyte16 good1 = mixin([1, 2, 3, 4]), bad = [1, 2, 3, 4]; static immutable ubyte16 good2 = mixin([1, 2, 3, 4]), crash = [1, 2, 3, 4]; pragma(msg, good1); pragma(msg, bad); pragma(msg,

Re: Proper way to handle "alias this" deprecation for classes

2023-05-07 Thread Inkrementator via Digitalmars-d-learn
On Sunday, 7 May 2023 at 18:19:04 UTC, Ali Çehreli wrote: alias this is for implicit type conversions, which can be achieved explicitly as well. Open question to everybody: What you're opinion on using opCast for this? Since it's a type conversion, it seems fitting to me. And another

Re: Proper way to handle "alias this" deprecation for classes

2023-05-07 Thread Chris Piker via Digitalmars-d-learn
On Sunday, 7 May 2023 at 18:19:04 UTC, Ali Çehreli wrote: auto main() { auto c = new C(); // The same type conversion is now explicit: foo(c.asIntPtr); } Hi Ali Ah, very clear explanation, thanks! So basically to fix the problem I just delete the alias this line from dpq2, see

Re: Proper way to handle "alias this" deprecation for classes

2023-05-07 Thread Ali Çehreli via Digitalmars-d-learn
On 5/7/23 10:55, Chris Piker wrote: > According to dmd 2.103, alias this is > deprecated for classes, so I'd like to correct the problem. alias this is for implicit type conversions, which can be achieved explicitly as well. Given the following old code: class C { int* result; alias

Proper way to handle "alias this" deprecation for classes

2023-05-07 Thread Chris Piker via Digitalmars-d-learn
Hi D One of the dependencies for my project has a class that makes use of the `alias x this` construct. According to dmd 2.103, alias this is deprecated for classes, so I'd like to correct the problem. Is there a specific paragraph or two that I can read to find out what is the