Follow-up discussion for removing pub, pub(set) and priv in Cadence 1.0

Going over the feedback, these seem to be the themes:

  1. Required time/effort to specify public access for new code

    i have developed a deep frustration with the change because it just takes so much longer to write contracts in cadence

  2. Required time/effort to migrate

    going from pub to access(all) takes a lot of effort when you consider you have to do it 20-200 times on each contract

For #1:

Does it take longer because the access(all) keyword is longer than pub? Is your concern purely about the effort of writing, or also about reading? To address the writing concern, maybe tooling (IDE completion) could help? If reading is a concern: One of the goals of the FLIP was to unify the access modifier syntax to simply access(...). Maybe the simplification is not worth the effort it results in?

For #2:

Could tooling help here? The type checker already reports a suggested fix for changing pub to access(all) (introduced in https://github.com/onflow/cadence/pull/2767).

Tooling could automate this further, by applying the migration automatically, but this is potentially dangerous: With the change to allow references to be downcasted, public functions and fields are not โ€œprotectedโ€ anymore by interfaces/restricted types.

You really want to audit your programs and double check if access was previously pub, but actually protected, or really pub in the sense that anyone can access it.

i assume the reason for this change was to help make devs become more aware of the access modifiers?

The intent was not to make developers aware of the access modifiers, but more so the changes to access control (safe downcasting/entitlements) requires developers to be aware and re-evaluate access modifiers.

Basically: See it as a chance to audit your code, and ensure that access control is and stays correct. If you have still have lot of access(all) after the migration, itโ€™s possible that there are more than there should be (I wouldnโ€™t call it a โ€œcode smellโ€, but still something to look into).

Like the team has pointed out, e.g. in the last update, it very much understands that the effort for this migration is substantial. Still, we hope that this investment by the current community will be beneficial in the long-term and will help both existing developers writing new contracts, and new developers learning Cadence.