digitalmars.D - Copy constructors and IsExpression
- Stanislav Blinov (29/29) Jun 01 2020 https://dlang.org/spec/expression.html#is_expression
- kinke (2/5) Jun 01 2020 Very likely, as in not adapted after the addition of copy ctors.
- Stanislav Blinov (8/13) Jun 02 2020 Hm, having slept on it, I think, if `is(A:B)` did the check, this
https://dlang.org/spec/expression.html#is_expression ...specifically, the second form, i.e. `is(Type : TypeSpecialization)`: "The condition is satisfied if Type is semantically correct and it is the same as or can be implicitly converted to TypeSpecialization". Copy constructors expand the realm of implicit conversions, yet the IsExpression doesn't seem to consider them: --- struct S { int* ptr; // note the pointer this(ref scope const S) { /* ... */ } } S copy(ref const S s) { return s; } // OK void takesMutable(S s) {} void givesConst() { const S s; takesMutable(s); // OK } static assert(is(const(S) : S)); // Asserts --- Was the implementation intentionally not amended to allow for copy constructors, or was this an oversight? It does, after all, accept conversions provided by the `alias this`, so why not copy ctors? There are a few areas of the language and libraries, including druntime, that are ignoring copy constructors (for example, arrays). Is this also one of those? On another note, is there really no way of recovering password here? I keep forgetting it on a regular basis.
Jun 01 2020
On Monday, 1 June 2020 at 15:48:21 UTC, Stanislav Blinov wrote:There are a few areas of the language and libraries, including druntime, that are ignoring copy constructors (for example, arrays). Is this also one of those?Very likely, as in not adapted after the addition of copy ctors.
Jun 01 2020
On Monday, 1 June 2020 at 19:40:05 UTC, kinke wrote:On Monday, 1 June 2020 at 15:48:21 UTC, Stanislav Blinov wrote:Hm, having slept on it, I think, if `is(A:B)` did the check, this could blow up as a chicken-or-egg: ``` struct S { this(T)(ref scope T) if (!is(T : S)) { /* ... */ } } ```There are a few areas of the language and libraries, including druntime, that are ignoring copy constructors (for example, arrays). Is this also one of those?Very likely, as in not adapted after the addition of copy ctors.
Jun 02 2020