Is public by default an unsafe default?
Timon Gehr
timon.gehr at gmx.ch
Thu May 2 11:45:57 UTC 2024
On 5/2/24 13:01, Dukc wrote:
> On Wednesday, 1 May 2024 at 11:52:30 UTC, NotYouAgain wrote:
>>
>> Question 1 - is 'public by default' a sensible default for a language
>> that is aiming to be safe by default?
>
> It's sensible - that's how C works after all.
Arguably it is a bit more complicated in C. You would usually explicitly
include a declaration in a header file to make symbols of a library
visible to users. "Private" symbols would just not appear in the header
file, and I think not including something in a header file is the
default option. (Of course, there is no protection against other code
making a declaration manually, but I think technically even in D you can
access private symbols over their mangled name.)
More information about the Digitalmars-d
mailing list