Sealed classes - would you want them in D?

KingJoffrey KingJoffrey at KingJoffrey.com
Wed May 16 02:05:29 UTC 2018


On Tuesday, 15 May 2018 at 15:19:33 UTC, Jesse Phillips wrote:
> On Tuesday, 15 May 2018 at 10:19:58 UTC, KingJoffrey wrote:
>> My own code in D had bugs, cause I didn't realise all my 
>> private parts were not just visible, but accessible by all the 
>> so called 'friends' around me. They could reach in a do 
>> whatever they want! Without my consent!
>
> You've peaked my interest, could you give some details on one 
> or more of these bugs?

It's simple.

Write a non-member function, contained in the same module as a 
class, and accidently use a private class member instead of the 
public getter/setter defined by the interface of that class.

It's human error, that will occur time and time again, but will 
*never* get picked up in D, except through a debugging session, 
because D does not consider this an error.

How can it, if private is not really private?

Now the burden is back on the programmer again.

Be careful what you put into a module.




More information about the Digitalmars-d mailing list