proposal: Go 2: sync/atomic: type modifiers as an addition to types #29501
Labels
LanguageChange
NeedsInvestigation
Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Proposal
v2
A language change or incompatible library change
Milestone
Meta
For example:
All of us seen golang's Atomic package. It's quite unnatural way of defining atomic vars isn't it?
My proposal is to introduce type prefixes subsystem.In another words: make simple,readable way for making data atomic, shared, imutable, etc
Proposal
Example:
--Golang today:
--With descibed feature:
Ofcourse, there are several issues:
1)Loosing opportunity to modify variable in non-atomic way
2)(much) Increasing internal compiler complexity
-For the first one, cure is to use & operator which should has *int64 return type, not atomic *int64 nor
*(atomic int64). It would be nice, because force changing variable which is atomic indicates issuses in architecture.
(see EDIT)
-For the second one, my proposal is to make a kind of system, that describes variable in much abstract way, in order to allow inserting custom code before and after any kind of operation with variable. In another words: make Pre-acess and Post-acess parts in data operation model, used in code generation process. I think it won't be much penalty, because such thing will allow future modifications in that way to be easier to implement.
For swap and compare-and-swap there is still Atomic package.
P.S Another such modifiers I would like to see are "const" and "binary serialisable"(loading from []byte exactly in ram)(hello protobuf!). You are welcome to suggest your ones.
Edit
I see my mistake, the & operator really should have *(atomic int64) return type (adress of atomic , not content) ,and it won't be a cure.
The text was updated successfully, but these errors were encountered: