Is public by default an unsafe default?
WhoMeAgain
tedious at bore.com
Wed May 1 17:19:51 UTC 2024
On Wednesday, 1 May 2024 at 11:52:30 UTC, NotYouAgain wrote:
> No doubt this will create controversy too.. why.. I don't
> know... but anyway....
>
> Declarations within a D module (other than import declarations)
> are public by default.
> This includes public by default in a class too btw.
>
> Programmers from many of the other major languages will have to
> deal with this surprise (in addition to the surprise of how
> private has taken on a completely new meaning in D).
It was neither a surprise nor anything to deal with for me. My
previous "major" languages, one had a separate interface section,
and the other used namespaces.
> Question 1 - is 'public by default' a sensible default for a
> language that is aiming to be safe by default?
visibility has nothing to do with memory safety
> Question 2 - if public is not a sensible default for a language
> that is aiming to be safe by default, is it too late to change
> it?
Yes.
> Question 3 - if a change was made, what would become the new
> default?
This wont change, it would break existing code, and has zero
benefit.
> Please be respectful in your comments, if you have anything to
> say.
"If you have to ask for respect then you do not deserve it" -
Abraham Lincoln
More information about the Digitalmars-d
mailing list