Sealed classes - would you want them in D?

KingJoffrey KingJoffrey at KingJoffrey.com
Thu May 17 01:36:47 UTC 2018


On Wednesday, 16 May 2018 at 16:43:31 UTC, Walter Bright wrote:
>
> I had no idea. It's either parallel gestation of a great idea, 
> or they took it from D!

the splitting of the atom was a great idea too..now the world is 
on the brink of destruction (according to some).

how about adding a 'private' attribute on the class, which would 
mean, private inside the class is only accessible inside the 
class.

I presume the private attribute on the class, is not currently 
valid in D?

This seems unlikely to break anything, while giving the 
programmer back the control to strategically define interfaces 
that *must* be used.

My neighbour likes to back his car into his driveway.
To do so, he drives over my lawn in turns into his driveway.
Why? Because he doesn't respect the interface! (his driveway, is 
his interface, but cause I have no barrier around my lawn, he can 
do what he likes).

Yeah, i know, one class per module might solve this, sure...(put 
a fence around your lawn approach - but I like it without a 
fence.).

I really do prefer the 'program to interfaces' approach, and, 
occasionally I would like to have more than one class in the same 
module (where I deem that appropriate), and still have their 
interfaces respected.

I cannot do this in D.

Is there no way this can be accomodated in D (without breaking 
how things currently work)?



More information about the Digitalmars-d mailing list