Using closure in function scope to make "real" private class members
Ola Fosheim Grøstad
ola.fosheim.grostad at gmail.com
Tue Jun 7 09:05:36 UTC 2022
On Tuesday, 7 June 2022 at 08:45:49 UTC, zjh wrote:
> `Class privacy` is an important and simple problem.
> If you solve it, you can attract `c++ users` easily.
There are many approaches to encapsulation. Beta, the successor
to Simula (the first OOP language) did it on a syntactical level
which in some ways is more elegant. There are many takes on
encapsulation, most follow Simula, but there is nothing
particularly wrong with what D has chosen here.
Maybe «package» and «external» should not have been added! Think
about generic programming first, how many cases do you need to
deal with? 2 is ok, but annoying. 3 is a bit much. 4, 5, 6++ is
way too much.
And you are wrong about C++ programmers. I am a C++ programmer.
This is not what makes them complain. Go through the forum
archives and you'll see what they complain about.
> The `success` of c++ is to constantly meet the `needs` of
> different people.
The success of C++ comes down to it being the first OO-language
suitable for desktop applications that made it big, then add
performance and being compatible with C.
> Look at the latest `rust` and `other languages`. Which is not
> `complicated`? Even `'go'` has added 'generic'.
Rust and Go are not complicated.
Rust makes memory management complicated by requiring a
tree-structure. The language itself isn't complicated.
Go is not complicated. Go makes error-handling complicated by not
having proper exceptions.
The first batch of Rust users complained about it being too
complicated and they have put a serious amount of effort into
making memory management annotations less cumbersome.
Go was released as a rather minimal language and has only made
marginal additions. Their take on generics is minimal.
TLDR; I strongly disagree.
More information about the Digitalmars-d
mailing list