Why is D unpopular
jmh530
john.michael.hall at gmail.com
Mon Jun 13 12:33:32 UTC 2022
On Monday, 13 June 2022 at 03:46:52 UTC, Mike Parker wrote:
> [snip]
> This is the reason I think it's a useless feature. If you have
> access to the module, you have access to the internal members
> of the class. It's no different than having a class per file in
> Java. At some point, it comes down to coding conventions (e.g.,
> all internal access to private members within a Java class must
> explicitly go through the public interface).
>
> How does this feature bring any benefit that can't be had by
> putting `Foo` in a separate module? That's the question you
> have to answer.
A fair point, but one of the arguments (over who knows how many
pages at this point...) is that some people want to be able to
have some way to ensure that the only way to access internal
members is controlled through the class itself. You would reply
that there is an alternative, which is to put that class in a
separate module. It is a little like @safe (in a project with no
dependencies, is @safe useless because the programmer has access
to all the code and can verify themselves whether there are any
errors?). Some people want guarantees. The people arguing for
this want the guarantee that if they write some other function
*in the module* that tries to access one of this internal
members, then they get an error. Now, that's not something that
has been a concern to me, but I don't necessarily think it is a
useless feature.
More information about the Digitalmars-d
mailing list