May 18, 2018
On Friday, 18 May 2018 at 15:40:52 UTC, KingJoffrey wrote:

> This discussion (at least my reason for being involved in it) is about breaking this idiotic (in my opinion) concept that D enforces on 'everyone' - i.e the one class per module, or everything is public, and you have no say in it.
>
> I don't necessarily object to the freedom the D module provides (i.e to bypass your interfaces, even accidently). What I object to is the 'i.e the one class per module, or everything is public, and you have no say in it.'

I'm not saying I oppose making this change, but "evolution of the language" takes the form of adding features but never eliminating any. If I see

class A {
   private int x;
   private(this) int y;
}

it kind of makes my head hurt, and I've been using D for five years. The justification I've seen for complications like private vs public is that it's necessary for large programs. There's something wrong if a single module is considered large.

Unlike most of the people that post here, I work with beginning programmers. In almost all cases, decisions are made on the basis of appeal to 20-year C++ veterans, but at least I can say I raised the issue.
May 18, 2018
On Friday, 18 May 2018 at 15:40:52 UTC, KingJoffrey wrote:
> On Friday, 18 May 2018 at 14:32:33 UTC, bachmeier wrote:
>> [...]
>
> This is simply unavoidable - and, that 'surprise' you mention, is already there - it's not dependent on, or in any way related, to any proposal that might result from this discussion.
>
> The D 'private is really public in a module' concept, is here to stay (sadly, but it's true).
>
>
>> [...]
>
> C++ is a complex beast, as a result of both needing to accomodate change (evolve), and not wanting to break backwards compatability.
>
> It's still *the* most powerful and flexible tool available for programmers.
>
> Beginner programmers would do well to keep that in mind.
>
> A class is just an abstract type, a tool for those that think it is useful in the solution for their problem domain.
>
> In any case, this discussion is not about convincing you of the value of classes - you should already know that if you are programmer.
>
> This discussion (at least my reason for being involved in it) is about breaking this idiotic (in my opinion) concept that D enforces on 'everyone' - i.e the one class per module, or everything is public, and you have no say in it.
>
> I don't necessarily object to the freedom the D module provides (i.e to bypass your interfaces, even accidently). What I object to is the 'i.e the one class per module, or everything is public, and you have no say in it.'
>
> A proposal that empowers the programmer to use the module for more than just a container for single class, coupled with static compile time verification - i.e you can't accidently access your private(this) T as it would be a compile time error, would be good for D (in my opinion), because those that have enjoyed having this capability in other mainstream langauges for literally decades!, won't be shut out from using D.
>
> It will attract more programmers, not less - and trust me, D better get more programmers using it, cause 18 years on, and it hasn't got that far, really.
>
> To get more programmers, you might want to be more open to accomodating their needs too.
>
> Although I do wonder, sometimes, whether the aim if D is just to be this cosy little langauge that not many use, except for those that do.

Sometimes, I really need to put 2-3 or more different classes in a module and I don't want them to share private members (friend classes). The current solution is to create an individual module for each class, but I don't like it when my class logic-strucrure fits better in the same module. A better solution could be private(this). I am sure that D really needs something like this. I have been talking with my friend programmers for 4 hours and they don't like the fact that D classes couldn't protect thier members in the same module. So they stuck on java and c#..
May 18, 2018
On Friday, 18 May 2018 at 15:57:06 UTC, bachmeier wrote:
> On Friday, 18 May 2018 at 15:40:52 UTC, KingJo
>
> class A {
>    private int x;
>    private(this) int y;
> }
>

I agree that this looks a bit strange.
My initial proposal was "sealed" instead "private(this)" today.
May 18, 2018
On 5/18/18 12:07 PM, Gheorghe Gabriel wrote:

> Sometimes, I really need to put 2-3 or more different classes in a module and I don't want them to share private members (friend classes). The current solution is to create an individual module for each class, but I don't like it when my class logic-strucrure fits better in the same module. A better solution could be private(this). I am sure that D really needs something like this. I have been talking with my friend programmers for 4 hours and they don't like the fact that D classes couldn't protect thier members in the same module. So they stuck on java and c#..

You can "simulate" this by putting the classes into their own submodules of the same package.

I.e. you want:

module mod;

class C {

 private int _x;
 int x() { return _x; }

}

void foo(C c)
{
   auto x = c._x; // Oops, this should be an error
}

You can do this via:

mod/priv.d:
module mod.priv; // name however you like

class C { ... }

mod/package.d:
module mod;
public import mod.priv; // name isn't really important here

void foo(C c)
{
   auto x = c._x; // Truly an error
}

user.d:

import mod; // imports both foo and C as if they were both in the same module

-Steve
May 18, 2018
On Friday, 18 May 2018 at 11:41:33 UTC, KingJoffrey wrote:
> On Friday, 18 May 2018 at 09:07:57 UTC, Dave Jones wrote:
>>
>> FFS you're so dramatic. First the world is ending because private doesnt work as you expected. Then D is utterly useless without the changes you want. Now we live in some dystopian nightmare where we are all slaves to the Dlang spec.
>>
>> [..dadadadadaaaaa...]
>

> Thanks Dave.

You're welcome Joffers.


> You make my case  (i.e. The D community is too small, and insufficiently diverse to discuss this any further.)

You just reinforce the case that you have a tendency to drama and hyperbole.


> Except, that I'd add to that, that far too many are pretty immature too.

I'd rather be pretty and immature than young and stupid.


> Good luck with your dlang thing...18+ years old and still < 1000 programmers (perhaps a lot less). (and if you have more than one class in a file, you have no more encapsulation - I love it).

Oh here we go again... if people don't genuflect to Joffer's kingly wisdom he storms out like a pouty little tyrant muttering "good luck with your crappy language.. hhmmmppff idiots"


May 18, 2018
On Friday, 18 May 2018 at 15:40:52 UTC, KingJoffrey wrote:
> On Friday, 18 May 2018 at 14:32:33 UTC, bachmeier wrote:
>>
>>
> It will attract more programmers, not less - and trust me, D better get more programmers using it, cause 18 years on, and it hasn't got that far, really.

"Ohh Arya you will never be a lady if you keep walking around in your underclothes, even if it is just inside our chambers. You'll never have any friends or be popular, no one will ask you to the ball. You'll never be a lady."

Ohh the drama...

May 18, 2018
On Friday, 18 May 2018 at 17:59:04 UTC, Dave Jones wrote:
> On Friday, 18 May 2018 at 15:40:52 UTC, KingJoffrey wrote:
>> On Friday, 18 May 2018 at 14:32:33 UTC, bachmeier wrote:
>>>
>>>
>> It will attract more programmers, not less - and trust me, D better get more programmers using it, cause 18 years on, and it hasn't got that far, really.
>
> "Ohh Arya you will never be a lady if you keep walking around in your underclothes, even if it is just inside our chambers. You'll never have any friends or be popular, no one will ask you to the ball. You'll never be a lady."
>
> Ohh the drama...

Let's just stop this part of the convo since it's clearly not going to bring us anywhere
May 18, 2018
On Friday, 18 May 2018 at 18:12:55 UTC, Chris M. wrote:
> On Friday, 18 May 2018 at 17:59:04 UTC, Dave Jones wrote:
>> On Friday, 18 May 2018 at 15:40:52 UTC, KingJoffrey wrote:
>>> On Friday, 18 May 2018 at 14:32:33 UTC, bachmeier wrote:
>>>>
>>>>
>>> It will attract more programmers, not less - and trust me, D better get more programmers using it, cause 18 years on, and it hasn't got that far, really.
>>
>> "Ohh Arya you will never be a lady if you keep walking around in your underclothes, even if it is just inside our chambers. You'll never have any friends or be popular, no one will ask you to the ball. You'll never be a lady."
>>
>> Ohh the drama...
>
> Let's just stop this part of the convo since it's clearly not going to bring us anywhere

So lets stop the pointless gentle mockery and concentrate solely on the pointless.

Sounds like a plan!


May 18, 2018
On Friday, 18 May 2018 at 20:30:21 UTC, Dave Jones wrote:
> On Friday, 18 May 2018 at 18:12:55 UTC, Chris M. wrote:
>> On Friday, 18 May 2018 at 17:59:04 UTC, Dave Jones wrote:
>>> On Friday, 18 May 2018 at 15:40:52 UTC, KingJoffrey wrote:
>>>> On Friday, 18 May 2018 at 14:32:33 UTC, bachmeier wrote:
>>>>>
>>>>>
>>>> It will attract more programmers, not less - and trust me, D better get more programmers using it, cause 18 years on, and it hasn't got that far, really.
>>>
>>> "Ohh Arya you will never be a lady if you keep walking around in your underclothes, even if it is just inside our chambers. You'll never have any friends or be popular, no one will ask you to the ball. You'll never be a lady."
>>>
>>> Ohh the drama...
>>
>> Let's just stop this part of the convo since it's clearly not going to bring us anywhere
>
> So lets stop the pointless gentle mockery and concentrate solely on the pointless.
>
> Sounds like a plan!

The only thing that's going to drive this discussion forward is a few example use-cases (potentially borrowed from other languages that ran into similar 'problems'). I am new to D myself and how private works did surprise me but using the module/package method seems elegant enough to me.
May 19, 2018
On Friday, 18 May 2018 at 22:10:51 UTC, Maurice Huuskes wrote:
>
> The only thing that's going to drive this discussion forward is a few example use-cases (potentially borrowed from other languages that ran into similar 'problems'). I am new to D myself and how private works did surprise me but using the module/package method seems elegant enough to me.

I'll be honest. If people in the D community need to be provided with 'use cases' whereby private should not morph in public, then ya' all have bigger problems than you realise ;-)

should immutable morph into mutable?
(cause that might be convenient on rare occasions)

should const just morph in non-constant
(cause that might be convenient on rare occasions)

should safe morph into unsafe
(cause that might be convenient on rare occasions)

so why should private morph into public?
(oh.. i know...cause that might be convenient on rare occasions)

it's a really odd design decision to relax that rule just for 'private', and, it can have a really big impact on software quality (not to mention security).

it means, now you have to 'extra care'. cause the compiler won't tell you that you accidently accessed the private part - you'll have to work that out during your debugging sessions.

or, it means you have to find some hack to get around it.. (one class per module).

the option to stop private morphing into public, and the option to have compile time check of your semantics, is what the vast majority of programmers in the world already enjoy. Come on D. get with it!

But in any case, ya' all decided - cause D has no place in my development team until I can have more than one class in a module, and not be told that my private parts have to be public.

I believe this will continue to hold back D - until it empowers the programmer to have that control.