Poll: a nonstate keyword

Janice Caron caron800 at googlemail.com
Sat May 31 09:41:24 PDT 2008


On 31/05/2008, Fawzi Mohamed <fmohamed at mac.com> wrote:
>  It seems that with a safe no_state and a cast this is possible, so yes I
> very much want no_state.

But it's likely also to be possible /without/ nostate.

As I noted in my first post on this thread, only a small handful of
use-cases for nostate (aka mutable, aka unpaintable, etc) have been
identified. One of these uses is caching (aka memoization). The
current plan is to make caching available as a library solution, and
so *therefore*, you will not need "nostate" in order to do this.

I have no idea whether or not the library solution will be considered
pure. I imagine that if it can be proven safe, then it will count as
pure. If not, well, there's always explicit casting.

So, given that, do you /still/ want nostate? Remember that (like
explicit casts and unions) it opens the door to /serious/ abuse of the
const system, just like in C++. Inexperienced programmers may well
think to themselves: "I can't get this program to compile, unless I
make member x mutable, so I'll do that". It seems to me that instead
of opening that door, a better solution is (1) identify all reasonable
use-cases (and we've only managed to come up with three or four so
far, so even if we've missed a few, it's clearly not a big number),
and then (2) provide alternative solutions for each of those
use-cases.

What do you think?



More information about the Digitalmars-d mailing list