PhobosWatch: manifest => enum

Janice Caron caron800 at googlemail.com
Sat Dec 29 19:15:02 PST 2007


On 12/29/07, Walter Bright <newshound1 at digitalmars.com> wrote:
> What do we do with:
>
>         const MyInt m = 3;
>         auto n = m;
>
> Does n get const or not? If it is, now it is behaving differently from
> other types, and so is not a plug-in replacement. If it does not, what
> happens if MyInt has a pointer member? Suddenly, the const gets stripped
> from the pointer, and there is no const-correctness.

In full agreement with you, Walter, having understood all your points
(at last), but what if we allowed:

    const MyInt m = 3;
    auto n = m.dup;

It would be no trouble at all for MyInt to supply a dup() function
whose return value had type MyInt.

The only question is, will it work for plain ints?

    const int m = 3;
    auto n = m.dup;

And if not, can it be made to work? (That is, can we implement dup for
all primitive types?)



More information about the Digitalmars-d mailing list