April 11, 2018
On Wednesday, 11 April 2018 at 17:58:25 UTC, Jonathan M Davis wrote:
> On Sunday, April 08, 2018 13:00:02 bauss via Digitalmars-d wrote:
>> [...]
>
> I don't know. It could be argued either way. I think that the logic as to why
>
> [...]

The thing is, it makes no sense why it shouldn't be legal since you can just cast to the base type, by that alone you're escaping the restriction that it's supposed to have.

And it really goes against that private is module level.

If it was module level then you should be able to access the member regardless of the reference to it.
June 11, 2018
On 4/11/18 3:13 PM, bauss wrote:
> On Wednesday, 11 April 2018 at 17:58:25 UTC, Jonathan M Davis wrote:
>> On Sunday, April 08, 2018 13:00:02 bauss via Digitalmars-d wrote:
>>> [...]
>>
>> I don't know. It could be argued either way. I think that the logic as to why
>>
>> [...]
> 
> The thing is, it makes no sense why it shouldn't be legal since you can just cast to the base type, by that alone you're escaping the restriction that it's supposed to have.
> 
> And it really goes against that private is module level.
> 
> If it was module level then you should be able to access the member regardless of the reference to it.

Just going through old messages on the NG.

I filed a bug about a similar thing (calling private functions instead of using private variables), but it seemed to be agreed upon that this is expected behavior:

https://issues.dlang.org/show_bug.cgi?id=15897

You may find some more insight from reading that discussion. I don't agree with the conclusion, as it is very surprising behavior to me.

-Steve
June 12, 2018
On Monday, 11 June 2018 at 15:41:57 UTC, Steven Schveighoffer wrote:
> On 4/11/18 3:13 PM, bauss wrote:
>> On Wednesday, 11 April 2018 at 17:58:25 UTC, Jonathan M Davis wrote:
>>> On Sunday, April 08, 2018 13:00:02 bauss via Digitalmars-d wrote:
>>>> [...]
>>>
>>> I don't know. It could be argued either way. I think that the logic as to why
>>>
>>> [...]
>> 
>> The thing is, it makes no sense why it shouldn't be legal since you can just cast to the base type, by that alone you're escaping the restriction that it's supposed to have.
>> 
>> And it really goes against that private is module level.
>> 
>> If it was module level then you should be able to access the member regardless of the reference to it.
>
> Just going through old messages on the NG.
>
> I filed a bug about a similar thing (calling private functions instead of using private variables), but it seemed to be agreed upon that this is expected behavior:
>
> https://issues.dlang.org/show_bug.cgi?id=15897
>
> You may find some more insight from reading that discussion. I don't agree with the conclusion, as it is very surprising behavior to me.
>
> -Steve

It goes against everything OOP and it goes against D's own private.
August 30, 2018
On Monday, 11 June 2018 at 15:41:57 UTC, Steven Schveighoffer wrote:
> I filed a bug about a similar thing (calling private functions instead of using private variables), but it seemed to be agreed upon that this is expected behavior:
>
> https://issues.dlang.org/show_bug.cgi?id=15897
>
> You may find some more insight from reading that discussion. I don't agree with the conclusion, as it is very surprising behavior to me.
>
> -Steve

Not the same, bauss' case is a template method that wouldn't get the depreciation warning if it wasn't templated. Template instances not always having the same access privileges as their template declaration's is definitely a bug.
August 30, 2018
On Thursday, 30 August 2018 at 12:18:10 UTC, Elie Morisse wrote:
> On Monday, 11 June 2018 at 15:41:57 UTC, Steven Schveighoffer wrote:
>> I filed a bug about a similar thing (calling private functions instead of using private variables), but it seemed to be agreed upon that this is expected behavior:
>>
>> https://issues.dlang.org/show_bug.cgi?id=15897
>>
>> You may find some more insight from reading that discussion. I don't agree with the conclusion, as it is very surprising behavior to me.
>>
>> -Steve
>
> Not the same, bauss' case is a template method that wouldn't get the depreciation warning if it wasn't templated. Template instances not always having the same access privileges as their template declaration's is definitely a bug.

Or actually since I didn't test the code it's more likely just due to T being Bar, in which case there's no reason to make the cast to Foo mandatory since Foo's field get accessed from Foo's method.
1 2 3
Next ›   Last »