Remaining const niggles #1 - Custom POD types

Janice Caron caron800 at googlemail.com
Mon Feb 18 10:18:14 PST 2008


On 18/02/2008, Christopher Wright <dhasenan at gmail.com> wrote:
> opImplicitCast allows you to define a copy mechanism from a const UDT to
> a non-const UDT,

That actually does seem a bit mad though. I mean - not your idea -
just having to do it. Can you even /imagine/ having to do that in C++!
Imagine having to expain it to a potential convert: "Yes, I gave my
struct S an implicit casting function which returns ... er ... another
S. What do you mean: Why can't it do that all by itself!?". Having to
do that explicitly, in every single struct you make ... well, honestly
it just makes the D programming language look a bit pathetic.

This is not a difficult thing for Walter et al to fix. The rules I
came up with earlier weren't meant for humans - they were a first stab
at rules for the compiler. But here's the easier to understand rule,
the principle, so to speak: "If the compiler can prove that copying is
safe, allow the copy". Really, that's the only rule I'm asking for.



More information about the Digitalmars-d mailing list