On 1/9/21 3:20 PM, Q. Schroll wrote:
Yes. Actually, I need it for slices, but only pointer part of it really
mattered.
A Derived[] is implicitly a const(Base)[], not a Base[].
A void delegate() @safe[] is implicitly a const(void delegate())[].
But it seems a void function() @safe[] **isn't** im
On Saturday, 9 January 2021 at 18:16:04 UTC, Q. Schroll wrote:
This makes no sense in my head. Is there some reason I'm unable
to see?
And yes, I think it should work likewise for function pointers,
too.
On Sunday, 10 January 2021 at 00:44:26 UTC, Q. Schroll wrote:
Car[] cars = ...;
Vehicle[] vehicles = cars;
vehicles[0] = new Boat; // err...
// cars[0] is a Boat now!?
Now what? Do what Java does and throw an Exception? Or use
const to prevent mutation?
Yes, you are right:
```
Deri
On Saturday, 9 January 2021 at 21:57:43 UTC, sighoya wrote:
On Saturday, 9 January 2021 at 20:20:38 UTC, Q. Schroll wrote:
That's not what I mean. You copy the reference. That's not
what referencing meant.
Derived d = new Derived();
Base* bp = &d; // fails
const(Base) cbp = &d; // compil
On Saturday, 9 January 2021 at 20:20:38 UTC, Q. Schroll wrote:
That's not what I mean. You copy the reference. That's not what
referencing meant.
Derived d = new Derived();
Base* bp = &d; // fails
const(Base) cbp = &d; // compiles.
Generally, allowing covariant assignment for the Ptr, i
On Saturday, 9 January 2021 at 20:00:35 UTC, Jacob Carlborg wrote:
On 2021-01-09 19:16, Q. Schroll wrote:
Say I have a class hierarchy like this:
class Base { }
class Derived : Base { }
A Derived object cannot be referenced as a Base object, but as
a const(Base) object. That makes sense t
On 2021-01-09 19:16, Q. Schroll wrote:
Say I have a class hierarchy like this:
class Base { }
class Derived : Base { }
A Derived object cannot be referenced as a Base object, but as a
const(Base) object. That makes sense to me.
It can:
Base b = new Derived();
One can replace Base by a
Say I have a class hierarchy like this:
class Base { }
class Derived : Base { }
A Derived object cannot be referenced as a Base object, but as a
const(Base) object. That makes sense to me.
One can replace Base by a @system delegate type (SysDG) and
Derived by a @safe delegate type (SafeDG)