Sealed classes - would you want them in D? (v2)

Gheorghe Gabriel knoppy273 at live.com
Fri May 18 16:07:26 UTC 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#..


More information about the Digitalmars-d mailing list