sway
sway copied to clipboard
Make `store` and `get` in the storage library private
Simply remove the pub
keyword from store
and get
here: https://github.com/FuelLabs/sway/blob/master/sway-lib-std/src/storage.sw. This is a breaking change that also requires documentation update. Also, as static arrays don't work in storage right now, this will be a bit limiting but that's probably fine in the short term as the benefits of not exposing store
and get
(which are basically footguns) outweigh the benefits of enabling reading and writing arrays.
If we are going to put every thing thatll ever have storage functionality in the storage.sw file, this is fine, if not this is not good
Agreed this is a short term solution until we have more flavours of pub
.
Should any content that uses store
& get
be deleted entirely since it will no longer be usable?
There may be more libraries that need to do storage of custom structs. I dont think the benefits of privating store
/get
outweigh the losses. I dont think anyone is even trying to use these functions unless they know what they are doing?
There may be more libraries that need to do storage of custom structs. I dont think the benefits of privating
store
/get
outweigh the losses. I dont think anyone is even trying to use these functions unless they know what they are doing?
I believe the sway libs repo uses these. It doesn't make sense to make them private because of worries of users using them incorrectly, it's akin to using an array index incorrectly... no point in nuking arrays from a language.
It's breaking, it has already been used and it exists in GH so people can look it up and copy/paste or recreate on their own. We also have it tested so it's better to maintain rather than apply the safety wheels to everything.
I do agree and I'm starting to lean toward not doing this. @Braqzen the reasons you provide are exactly why this hasn't been done yet.
The good thing about store
and get
is that they provide a low level API that's pretty close to asm
but not really asm
. Users who want to manipulate storage slots manually (this should be rare) can use these instead of using asm
blocks.
In light of the discussions above, I'm closing this issue.