cast(public)
dsimcha
dsimcha at yahoo.com
Fri Jul 17 08:38:21 PDT 2009
I know I've probably mentioned this one here before, but it was buried in long
threads.
Could we put a feature in the language that allows private member variables to
be cast to public? The idea is that, if a class/struct designer makes
something private, they're saying it's a bad idea to mess with it, and that
you do so at your own risk. However, I think there needs to be a back door to
cowboy this one, because otherwise private/protected is just too restrictive
for a language like D. It would work something like this:
struct Foo {
private uint bar;
}
void main() {
Foo foo;
foo.bar++; // error
(cast(public) foo.bar)++; // Works.
}
More information about the Digitalmars-d
mailing list