unpaintable (the solution to logical const)
Kevin Bealer
kevinbealer at gmail.com
Sat Apr 5 19:53:37 PDT 2008
Janice Caron Wrote:
...
> What we do is this: we classify every field of a class/struct/union as
> being either "paintable" or "unpaintable". (Fields which would be
> called "mutable" in C++ are called "unpaintable" here).
...
I'm not convinced that you and Steven are right about this, but this idea by itself
seems interesting ... in a way, it seems like a way to parameterize a type on type
modifiers, i.e. in the same way that templates currently can parameterize on types.
This might be interesting for a number of different applications. If nothing else, it
would be interesting if a function could do something like this:
int foo(typemod C1, typemod C2, T2)(C1 char[] a, C2 T2 b)
{
// do something non-mutating with a and b.
}
This would allow parameterizing on (and maybe deduction of) type modifiers
like const and volatile and permit code to be written with both invariant and
non-invariant data, reducing code duplication. Of course, some duplication
could probably be removed now using mixins but its more complex.
Kevin
More information about the Digitalmars-d
mailing list