proposal: Go 2: #63406
Labels
FrozenDueToAge
LanguageChange
Suggested changes to the Go language
Proposal
v2
An incompatible library change
Milestone
Author background
Intermediate
Python, Ruby
Related proposals
Not exactly, but there is one (a heap backed by a slice) Here. But above proposal is on hold and dosen't server the purpose of removing boiler plate code completely and get a data type for integer Heap. Which I am proposing in current proposal.
No, it dosen't affect error handleing.
No
Proposal
Implementing a integer based heap and implementing all the interface functions, can be reduced for integers. We can provide a integer heap, like it is given in a actual package help doc container/heap. programmer can use this as data type to create new integer heap without having to implement all the function of heap interface. Code in the end of this proposal is an example how this data type will look. This makes creating and using int heap a lot faster (in implementation).
This is inspired from
sort.Ints
andsort.Strings
where altough we can implement an interface and make a sorting implementation for int slice and string slice but making it availalbe for basic data types likeint
float
string
etc saves boilerplate code and help programmer write code without frustration of implementing interface for basic data types likeint
.The changes to language is minimal. Adding one concrete implementation of int heap with all necessary function/interface already implemented. To understand better look at the code in the end of this proposal.
Change will happen to spec of
container/heap
package. Changelog informing about a new way to init integer heap.Dear students, no more implementing of
Less
Swap
Push
Pop
for simple heap use. Just initialize your variable likevar h IntHeap
and you get the functionality as you would get earlier after implementing all the functions yourself.Yes
It overlaps in a way, where it allows progammer to use interface and implement heap for his/her favourite data type, while still leaving room for programmer who don't want to implement a fairly advanced data structure every time. Same think as in
sort.Ints
andsort.Floats
.No, performance is not the goal here.
Costs
Easier, abstract out the interface implementation if you don't really want to know.
Don't know, but can figure out if someone points to right resources.
Don't know, but can figure out if someone points to right resources.
Don't know, but can figure out if someone points to right resources.
Don't know, but can figure out if someone points to right resources.
The text was updated successfully, but these errors were encountered: