Poll: a nonstate keyword

Janice Caron caron800 at googlemail.com
Thu May 29 23:08:35 PDT 2008


On 29/05/2008, Fawzi Mohamed <fmohamed at mac.com> wrote:
> but can break invariant

That part is not correct. A couple of months back, I submitted a paper
to Walter and the gang, based on these ideas, in which I showed that
the transitive closure of const/invariant remained fully intact under
this model. Andrei confirmed that I was correct, and subsequently
tried to help explain it to Walter.

> and introduce subtle bugs.

That part is probably true, but it depends on whether or not people
"get it", which I think is what Steven was asking. Consider the
following (legal) code

    struct A
    {
        static int n;
    }

    invariant A a;
    a.n = 42;

I don't think anyone would argue that "static breaks invariant", but
could you say that code like the above "introduces subtle bugs"?
Maybe. Maybe not. It depends on understanding.

"nonstate" has been known by other names in previous discussions,
including "unpaintable". (There was quite a long thread with that
one). The general feeling over at Phobos is that the number of
use-cases is small enough that a handful of library solutions could
eliminate the need for the keyword. The problem, as I see it, is that
those library solutions have been talked about, but not yet
implemented. Consequently, there is still a perceived need for
"nonstate" - a perceived need which would go away as soon as those
alternative solutions were made available.



More information about the Digitalmars-d mailing list