I really like languages where private functions are fewer keystrokes than public functions.
Unfortunately 'protected' is longer than 'public', or 'pub(crate)' and 'pub'.
Have any languages solved this? E.g. 'fn foo', 'pkg fn foo', 'public fn foo' would work.
miniblog.
Related Posts
Should code completion offer private methods/fields?
If the user chooses a private method, you can offer a quickfix to change its visibility. It's clutter though.
I frequently find myself wanting fields that I haven't exposed yet, and frustrated that the IDE hides them.
I feel like increasing visibility of a function/type should require more verbosity. I don't know of any PL that follows this design principle for >2 levels though.
Ordered by verbosity:
public, private, protected
, pub, pub(crate)
Has any PL solved this?
Rust has an elegant solution to testing private functions: you put the test in the file that defines the function. It generally works well.
I've even seen people argue that it makes mocking much less necessary! I've not felt the need to mock in Rust so far.