Adding a new design constraint to D

forkit forkit at gmail.com
Sun Jun 19 05:41:03 UTC 2022


On Sunday, 19 June 2022 at 02:39:52 UTC, Paul Backus wrote:
>
> ..
> It's funny that you say this, because this is exactly how 
> information hiding works in the Common Lisp Object System:
> ...
>
> Source: https://en.wikipedia.org/wiki/Common_Lisp_Object_System
>
> A "package" in Common Lisp is more or less the same thing as a 
> module in D: a namespace for symbol definitions.
>
> If you are willing to bite the bullet here and say that CLOS is 
> "not OOP" because it lacks encapsulation, then fair enough, but 
> at that point I think you must admit that your idea of what 
> counts as OOP is not shared by most developers (including Alan 
> Kay himself, who cited Lisp as an example of OOP done right).

Well sure. The earth rotates around the sun.

If someone tells me the sun rotates around the earth, thent I can 
say that is factually incorrect.

There are no 'facts' when it comes to describing what OOP is ;-)

Anyone is free to make anything up, to suit what they think it 
is, or should be.

But to me, an object is a self-contained encapsulated unit of 
abstraction. By that I mean is has control of its own state and 
behaviour. For this to be possible, it needs to be able to 'hide' 
stuff from the outside world (to ensure the outside world is not 
changing its state or behaviour willy nilly.. )

It escapes my comprehension, as to why D cannot provide compiler 
support for this design, whereas other major langauges do.

Was D targetting CLOS programmers?

Was it targetting C++ programmers, but insisting the change their 
way of thinking if they come over to D?

Seems like such a simple, useful feature, to be able to say "this 
is private to this class, so compiler, please enforce this at 
compile time in case anyone else tries to change me without my 
permission".

I've been able to do exactly this, for 20+ years! And C++ has 
provided this to its users for considerably longer. Even Swift, a 
relatively new language, can do this - no problem whatsoever.

I'd like to know what the so called 'tradeoff' is, for not having 
this 'option', cause is sure seems a tradeoff to help the 
compiler writer, and not the programmer.


More information about the Digitalmars-d mailing list