cast(public)
Ary Borenszweig
ary at esperanto.org.ar
Sat Jul 18 08:45:05 PDT 2009
downs escribió:
> Ary Borenszweig wrote:
>> downs escribió:
>>> dsimcha wrote:
>>>> 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.
>>>> }
>>> I can second this.
>>>
>>> For instance, in Phobos1 there is no way to create a Socket from a
>>> file handle, so I have to monkey with offsets in my IRC bot code.
>> Did you ask for an enhancement?
>
> Phobos*1*.
Well, anyway, casting things to public is not the solution. Phobos1
should still be maintained. It's silly that just a couple of people are
working on the standard library...
More information about the Digitalmars-d
mailing list