PhobosWatch: manifest => enum

Janice Caron caron800 at googlemail.com
Fri Dec 28 12:03:34 PST 2007


On 12/28/07, Walter Bright <newshound1 at digitalmars.com> wrote:
> Janice Caron wrote:
> > y is a /copy/ of x, and clearly it should be possible to make a copy
> > of a const thing and have the copy be mutable.
>
> That doesn't work for structs or classes.

It doesn't? For structs

    struct S {}
    const S x;
    auto y = x;

By my reckoning x has type invariant(S) (which you could treat as
const(S) if you wanted), and y would have type S. And for classes

    class C {}
    const C x;
    auto y = x;

...You're right, it doesn't work for classes. But is that really a
problem? Isn't

    class C {}
    enum { C x; }
    auto y = x;

exactly the same problem?



> Just for fun, how would we define a tail const member function?

Yeah, I agreed, it wouldn't work for classes. Still don't see any
problem for structs though. I guess you're going to remind me that
structs and classes must behave the same though - in which case you'll
win the argument! :-)


> Believe me, we've been down this road for a year, trying all kinds of
> things. It doesn't work. We can get tantalizingly close to closing the
> circle, but cannot quite get there.

Hey ho. I guess we can live with enum then. But I still think you're
going to have a problem with

    class C {}
    enum { C x; }
    auto y = x;



More information about the Digitalmars-d mailing list