From 07b4ddaca46ece33a1a494722fdb71bec739ed4d Mon Sep 17 00:00:00 2001 From: Daniel Sainati Date: Fri, 5 May 2023 10:57:10 -0400 Subject: [PATCH 1/6] add FLIP --- cadence/2023-05-05-remove-priv-and-pub.md | 56 +++++++++++++++++++++++ 1 file changed, 56 insertions(+) create mode 100644 cadence/2023-05-05-remove-priv-and-pub.md diff --git a/cadence/2023-05-05-remove-priv-and-pub.md b/cadence/2023-05-05-remove-priv-and-pub.md new file mode 100644 index 00000000..3ced8e24 --- /dev/null +++ b/cadence/2023-05-05-remove-priv-and-pub.md @@ -0,0 +1,56 @@ +--- +status: proposed +flip: NNN (do not set) +authors: Daniel Sainati (daniel.sainati@dapperlabs.com) +sponsor: Daniel Sainati (daniel.sainati@dapperlabs.com) +updated: 2023-05-05 +--- + +# Remove `pub` and `priv` aliases for access modifiers + +## Objective + +This FLIP proposes to remove the `pub` alias for `access(all)` and the `priv` +modifier for `access(self)`, requiring all code to use these longer forms instead +of the shortened ones. + +## Motivation + +The proposed entitlements changes in [the entitlements FLIP](https://github.com/onflow/flips/pull/54) +will add a new `access(X)` modifier for entitled access, which will likely be used frequently +in many contracts. It would be more consistent with this new `access(X)` syntax for `pub` +and `priv` to be `access(all)` and `access(self)` respectively. + +## User Benefit + +This will increase the readability and consistency of user code. + +## Design Proposal + +The proposal is simple: just remove the `pub` and `priv` aliases. No other +changes will be necessary. + +### Drawbacks + +This will increase the verbosity of all code, as well as break every single contract +that exists, as it is extremely unlikely that there is any code on Mainnet currently that +does not use at least one `pub` modifier. However, as discussed in the next section, this may be +an benefit rather than a drawback. + +### Compatibility + +This is not backwards compatible, and will indeed break every existing contract. However, +given that the aforementioned entitlements change is also going to require a rewrite of all +code currently deployed to Mainnet, a change such as this that statically breaks all of that code +will alert developers that changes are required, rather than allowing potentially newly unsafe +code to slip through undetected. + +### User Impact + +This is going to require all code to be updated to not use the deprecated modifiers. It would +be possible to write a migration assistant that would automatically replace the `pub` and `priv` +modifiers with their equivalent long forms, but it is unclear if we would want to do this, given +that a stated goal of this change is to make developers manually consider which `pub` methods are +truly `access(all)` and which should be rewritten to use entitlements. + +## Questions and Discussion Topics From 9d9b6546af172ee410be2abbb3b5d533e816f7e1 Mon Sep 17 00:00:00 2001 From: Daniel Sainati Date: Wed, 24 May 2023 18:59:29 -0400 Subject: [PATCH 2/6] add language proposing the removal of pub(set) --- cadence/2023-05-05-remove-priv-and-pub.md | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/cadence/2023-05-05-remove-priv-and-pub.md b/cadence/2023-05-05-remove-priv-and-pub.md index 3ced8e24..961ec4f1 100644 --- a/cadence/2023-05-05-remove-priv-and-pub.md +++ b/cadence/2023-05-05-remove-priv-and-pub.md @@ -14,6 +14,11 @@ This FLIP proposes to remove the `pub` alias for `access(all)` and the `priv` modifier for `access(self)`, requiring all code to use these longer forms instead of the shortened ones. +This also proposes to remove the `pub(set)` access keyword, which was previously used to make +variables publicly settable. This is not a common case, and in order to simplify the language, +we also propose to remove it. If users wish to have a field be publicly settable, they should write +a public mutator function for that field. + ## Motivation The proposed entitlements changes in [the entitlements FLIP](https://github.com/onflow/flips/pull/54) From 4172dbfd2378dc936dfde27777934156c065466b Mon Sep 17 00:00:00 2001 From: Daniel Sainati Date: Thu, 25 May 2023 12:06:55 -0400 Subject: [PATCH 3/6] more info about removing pub set --- cadence/2023-05-05-remove-priv-and-pub.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cadence/2023-05-05-remove-priv-and-pub.md b/cadence/2023-05-05-remove-priv-and-pub.md index 961ec4f1..3cbfb4e9 100644 --- a/cadence/2023-05-05-remove-priv-and-pub.md +++ b/cadence/2023-05-05-remove-priv-and-pub.md @@ -32,8 +32,8 @@ This will increase the readability and consistency of user code. ## Design Proposal -The proposal is simple: just remove the `pub` and `priv` aliases. No other -changes will be necessary. +The proposal is simple: just remove the `pub` and `priv` aliases. `pub(set)` will +also be removed. ### Drawbacks From 52d0ad9bb5d5bf3fa08e18674d76ce797b5beca0 Mon Sep 17 00:00:00 2001 From: Daniel Sainati Date: Thu, 25 May 2023 14:43:58 -0400 Subject: [PATCH 4/6] Update cadence/2023-05-05-remove-priv-and-pub.md MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Bastian Müller --- cadence/2023-05-05-remove-priv-and-pub.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cadence/2023-05-05-remove-priv-and-pub.md b/cadence/2023-05-05-remove-priv-and-pub.md index 3cbfb4e9..23651c8f 100644 --- a/cadence/2023-05-05-remove-priv-and-pub.md +++ b/cadence/2023-05-05-remove-priv-and-pub.md @@ -1,12 +1,12 @@ --- status: proposed -flip: NNN (do not set) +flip: 84 authors: Daniel Sainati (daniel.sainati@dapperlabs.com) sponsor: Daniel Sainati (daniel.sainati@dapperlabs.com) updated: 2023-05-05 --- -# Remove `pub` and `priv` aliases for access modifiers +# FLIP 84: Remove `pub` and `priv` aliases for access modifiers ## Objective From d80cb4312b783d2050a047a14fefebaa86d961b0 Mon Sep 17 00:00:00 2001 From: Daniel Sainati Date: Thu, 25 May 2023 14:45:25 -0400 Subject: [PATCH 5/6] rename --- ...-05-remove-priv-and-pub.md => 20230505-remove-priv-and-pub.md} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename cadence/{2023-05-05-remove-priv-and-pub.md => 20230505-remove-priv-and-pub.md} (100%) diff --git a/cadence/2023-05-05-remove-priv-and-pub.md b/cadence/20230505-remove-priv-and-pub.md similarity index 100% rename from cadence/2023-05-05-remove-priv-and-pub.md rename to cadence/20230505-remove-priv-and-pub.md From c14ad7fff2ec7ecf6d14e412f7267b8eeb4bf915 Mon Sep 17 00:00:00 2001 From: Daniel Sainati Date: Tue, 20 Jun 2023 13:07:29 -0400 Subject: [PATCH 6/6] accept flip --- cadence/20230505-remove-priv-and-pub.md | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/cadence/20230505-remove-priv-and-pub.md b/cadence/20230505-remove-priv-and-pub.md index 23651c8f..d020508e 100644 --- a/cadence/20230505-remove-priv-and-pub.md +++ b/cadence/20230505-remove-priv-and-pub.md @@ -1,5 +1,5 @@ --- -status: proposed +status: accepted flip: 84 authors: Daniel Sainati (daniel.sainati@dapperlabs.com) sponsor: Daniel Sainati (daniel.sainati@dapperlabs.com) @@ -42,6 +42,9 @@ that exists, as it is extremely unlikely that there is any code on Mainnet curre does not use at least one `pub` modifier. However, as discussed in the next section, this may be an benefit rather than a drawback. +Additionally, any existing `pub(set)` fields will need to be replaced with `access(all)` fields, and be given +a setter function explicitly in order to regain their previous functionality. + ### Compatibility This is not backwards compatible, and will indeed break every existing contract. However,